netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* skbuff: Move new code into __copy_skb_header
@ 2009-05-23  8:11 Herbert Xu
  2009-05-23  8:19 ` Johannes Berg
  2009-05-25  7:40 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Herbert Xu @ 2009-05-23  8:11 UTC (permalink / raw)
  To: David S. Miller, netdev
  Cc: Paul Moore, Sujith, Johannes Berg, John W. Linville

Hi:

skbuff: Move new __skb_clone code into __copy_skb_header

It seems that people just keep on adding stuff to __skb_clone
instead __copy_skb_header.  This is wrong as it means your brand-new
attributes won't always get copied as you intended.

This patch moves them to the right place, and adds a comment to
prevent this from happening again.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index e505b53..cb58b4b 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -538,6 +538,7 @@ static void __copy_skb_header(struct sk_buff *new, const struct sk_buff *old)
 #endif
 	new->protocol		= old->protocol;
 	new->mark		= old->mark;
+	new->iif		= old->iif;
 	__nf_copy(new, old);
 #if defined(CONFIG_NETFILTER_XT_TARGET_TRACE) || \
     defined(CONFIG_NETFILTER_XT_TARGET_TRACE_MODULE)
@@ -550,10 +551,18 @@ static void __copy_skb_header(struct sk_buff *new, const struct sk_buff *old)
 #endif
 #endif
 	new->vlan_tci		= old->vlan_tci;
+#if defined(CONFIG_MAC80211) || defined(CONFIG_MAC80211_MODULE)
+	new->do_not_encrypt	= old->do_not_encrypt;
+	new->requeue		= old->requeue;
+#endif
 
 	skb_copy_secmark(new, old);
 }
 
+/*
+ * You should not add any new code to this function.  Add it to
+ * __copy_skb_header above instead.
+ */
 static struct sk_buff *__skb_clone(struct sk_buff *n, struct sk_buff *skb)
 {
 #define C(x) n->x = skb->x
@@ -569,16 +578,11 @@ static struct sk_buff *__skb_clone(struct sk_buff *n, struct sk_buff *skb)
 	n->cloned = 1;
 	n->nohdr = 0;
 	n->destructor = NULL;
-	C(iif);
 	C(tail);
 	C(end);
 	C(head);
 	C(data);
 	C(truesize);
-#if defined(CONFIG_MAC80211) || defined(CONFIG_MAC80211_MODULE)
-	C(do_not_encrypt);
-	C(requeue);
-#endif
 	atomic_set(&n->users, 1);
 
 	atomic_inc(&(skb_shinfo(skb)->dataref));

Thanks,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: skbuff: Move new code into __copy_skb_header
  2009-05-23  8:11 skbuff: Move new code into __copy_skb_header Herbert Xu
@ 2009-05-23  8:19 ` Johannes Berg
  2009-05-25  7:40 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Johannes Berg @ 2009-05-23  8:19 UTC (permalink / raw)
  To: Herbert Xu; +Cc: David S. Miller, netdev, Paul Moore, Sujith, John W. Linville

[-- Attachment #1: Type: text/plain, Size: 527 bytes --]

On Sat, 2009-05-23 at 18:11 +1000, Herbert Xu wrote:

> skbuff: Move new __skb_clone code into __copy_skb_header
> 
> It seems that people just keep on adding stuff to __skb_clone
> instead __copy_skb_header.  This is wrong as it means your brand-new
> attributes won't always get copied as you intended.
> 
> This patch moves them to the right place, and adds a comment to
> prevent this from happening again.

Oops, thanks. But on the positive side, I'm getting rid of skb->requeue
again anyway :)

johannes


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: skbuff: Move new code into __copy_skb_header
  2009-05-23  8:11 skbuff: Move new code into __copy_skb_header Herbert Xu
  2009-05-23  8:19 ` Johannes Berg
@ 2009-05-25  7:40 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2009-05-25  7:40 UTC (permalink / raw)
  To: herbert; +Cc: netdev, paul.moore, Sujith.Manoharan, johannes, linville

From: Herbert Xu <herbert@gondor.apana.org.au>
Date: Sat, 23 May 2009 18:11:37 +1000

> skbuff: Move new __skb_clone code into __copy_skb_header
> 
> It seems that people just keep on adding stuff to __skb_clone
> instead __copy_skb_header.  This is wrong as it means your brand-new
> attributes won't always get copied as you intended.
> 
> This patch moves them to the right place, and adds a comment to
> prevent this from happening again.
> 
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Applied to net-next-2.6

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-05-25  7:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-23  8:11 skbuff: Move new code into __copy_skb_header Herbert Xu
2009-05-23  8:19 ` Johannes Berg
2009-05-25  7:40 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).