diff mbox series

[RFC,04/12] net: Make generic dst->child usage more explicit.

Message ID 20171025.230311.1944266209591105385.davem@davemloft.net
State RFC, archived
Delegated to: David Miller
Headers show
Series [RFC,01/12] net: dst->rt_next is unused. | expand

Commit Message

David Miller Oct. 25, 2017, 2:03 p.m. UTC
Only IPSEC (xfrm) routes have a dst->child which is non-NULL.
xfrm routes are identified by dst->xfrm being non-NULL.

Codify this explicitly in dst_destroy().

Signed-off-by: David S. Miller <davem@davemloft.net>
---
 net/core/dst.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Eric Dumazet Oct. 25, 2017, 2:55 p.m. UTC | #1
On Wed, 2017-10-25 at 23:03 +0900, David Miller wrote:
> Only IPSEC (xfrm) routes have a dst->child which is non-NULL.
> xfrm routes are identified by dst->xfrm being non-NULL.
> 
> Codify this explicitly in dst_destroy().
> 
> Signed-off-by: David S. Miller <davem@davemloft.net>
> ---
>  net/core/dst.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/net/core/dst.c b/net/core/dst.c
> index 662a2d4a3d19..6a3c21b8fc8d 100644
> --- a/net/core/dst.c
> +++ b/net/core/dst.c
> @@ -116,12 +116,14 @@ EXPORT_SYMBOL(dst_alloc);
>  
>  struct dst_entry *dst_destroy(struct dst_entry * dst)
>  {
> -	struct dst_entry *child;
> +	struct dst_entry *child = NULL;
>  
>  	smp_rmb();
>  
> -	child = dst->child;
> -
> +#ifdef CONFIG_XFRM
> +	if (dst->xfrm)
> +		child = dst->child;
> +#endif
>  	if (!(dst->flags & DST_NOCOUNT))
>  		dst_entries_add(dst->ops, -1);
>  

You might squash this patch with the following one ;)
David Miller Oct. 26, 2017, 12:19 a.m. UTC | #2
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Wed, 25 Oct 2017 07:55:17 -0700

> You might squash this patch with the following one ;)

Indeed.

The whole bit of changing dst->child is a bit tricky because of
the generic layer need to access it just for the dst destroy
case.

I'll think a bit more about how to transform this cleanly, so
thanks for the feedback.
diff mbox series

Patch

diff --git a/net/core/dst.c b/net/core/dst.c
index 662a2d4a3d19..6a3c21b8fc8d 100644
--- a/net/core/dst.c
+++ b/net/core/dst.c
@@ -116,12 +116,14 @@  EXPORT_SYMBOL(dst_alloc);
 
 struct dst_entry *dst_destroy(struct dst_entry * dst)
 {
-	struct dst_entry *child;
+	struct dst_entry *child = NULL;
 
 	smp_rmb();
 
-	child = dst->child;
-
+#ifdef CONFIG_XFRM
+	if (dst->xfrm)
+		child = dst->child;
+#endif
 	if (!(dst->flags & DST_NOCOUNT))
 		dst_entries_add(dst->ops, -1);