Patchwork net: check for refcount if pop a stacked dst_entry

login
register
mail settings
Submitter Steffen Klassert
Date June 4, 2010, 10:41 a.m.
Message ID <20100604104115.GB13408@secunet.com>
Download mbox | patch
Permalink /patch/54564/
State Superseded
Delegated to: David Miller
Headers show

Comments

Steffen Klassert - June 4, 2010, 10:41 a.m.
xfrm triggers a warning if dst_pop() drops a refcount
on a noref dst. This patch changes dst_pop() to
skb_dst_pop(). skb_dst_pop() drops the refcnt only
on a refcounted dst.

Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
 include/net/dst.h      |    6 +++---
 net/xfrm/xfrm_output.c |    2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
Eric Dumazet - June 4, 2010, 10:51 a.m.
Le vendredi 04 juin 2010 à 12:41 +0200, Steffen Klassert a écrit :
> xfrm triggers a warning if dst_pop() drops a refcount
> on a noref dst. This patch changes dst_pop() to
> skb_dst_pop(). skb_dst_pop() drops the refcnt only
> on a refcounted dst.
> 
> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
> ---
>  include/net/dst.h      |    6 +++---
>  net/xfrm/xfrm_output.c |    2 +-
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/include/net/dst.h b/include/net/dst.h
> index 612069b..acd1538 100644
> --- a/include/net/dst.h
> +++ b/include/net/dst.h
> @@ -250,11 +250,11 @@ static inline void skb_tunnel_rx(struct sk_buff *skb, struct net_device *dev)
>   * Linux networking.  Thus, destinations are stackable.
>   */
>  
> -static inline struct dst_entry *dst_pop(struct dst_entry *dst)
> +static inline struct dst_entry *skb_dst_pop(struct sk_buff *skb)
>  {
> -	struct dst_entry *child = dst_clone(dst->child);
> +	struct dst_entry *child = dst_clone(skb_dst(skb)->child);
>  



> -	dst_release(dst);
> +	skb_dst_drop(skb);
>  	return child;
>  }

Hmm, this might fix the thing, but we probably can do it without the
dst_clone(), if you replace the 

skb_dst_set(skb, dst);

by 

skb_dst_set_noref(skb, dst);

in xfrm_output_one() ?

>  
> diff --git a/net/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c
> index 6a32915..db62a06 100644
> --- a/net/xfrm/xfrm_output.c
> +++ b/net/xfrm/xfrm_output.c
> @@ -95,7 +95,7 @@ resume:
>  			goto error_nolock;
>  		}
>  
> -		dst = dst_pop(dst);
> +		dst = skb_dst_pop(skb);
>  		if (!dst) {
>  			XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTERROR);
>  			err = -EHOSTUNREACH;


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Steffen Klassert - June 4, 2010, 11:23 a.m.
On Fri, Jun 04, 2010 at 12:51:19PM +0200, Eric Dumazet wrote:
> 
> Hmm, this might fix the thing, but we probably can do it without the
> dst_clone(), if you replace the 
> 
> skb_dst_set(skb, dst);
> 
> by 
> 
> skb_dst_set_noref(skb, dst);
> 
> in xfrm_output_one() ?
> 

Yes, this should work too. I'll update the patch to use
skb_dst_set_noref() in xfrm_output_one() and remove the 
dst_clone() in skb_dst_pop().
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/include/net/dst.h b/include/net/dst.h
index 612069b..acd1538 100644
--- a/include/net/dst.h
+++ b/include/net/dst.h
@@ -250,11 +250,11 @@  static inline void skb_tunnel_rx(struct sk_buff *skb, struct net_device *dev)
  * Linux networking.  Thus, destinations are stackable.
  */
 
-static inline struct dst_entry *dst_pop(struct dst_entry *dst)
+static inline struct dst_entry *skb_dst_pop(struct sk_buff *skb)
 {
-	struct dst_entry *child = dst_clone(dst->child);
+	struct dst_entry *child = dst_clone(skb_dst(skb)->child);
 
-	dst_release(dst);
+	skb_dst_drop(skb);
 	return child;
 }
 
diff --git a/net/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c
index 6a32915..db62a06 100644
--- a/net/xfrm/xfrm_output.c
+++ b/net/xfrm/xfrm_output.c
@@ -95,7 +95,7 @@  resume:
 			goto error_nolock;
 		}
 
-		dst = dst_pop(dst);
+		dst = skb_dst_pop(skb);
 		if (!dst) {
 			XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTERROR);
 			err = -EHOSTUNREACH;