diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2009-05-22 18:11:37 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-05-25 03:40:43 -0400 |
commit | 82c49a352e0fd7af7e79a922b863f33f619f3209 (patch) | |
tree | c5a1d8e7f5854076a10fdff6707463aed9d49c1e | |
parent | 45ea4ea2af358fe316c918381c7868f9418cad09 (diff) |
skbuff: Move new code into __copy_skb_header
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>
Thanks,
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/core/skbuff.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/net/core/skbuff.c b/net/core/skbuff.c index d152394b2611..e47afb20b894 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) | |||
538 | #endif | 538 | #endif |
539 | new->protocol = old->protocol; | 539 | new->protocol = old->protocol; |
540 | new->mark = old->mark; | 540 | new->mark = old->mark; |
541 | new->iif = old->iif; | ||
541 | __nf_copy(new, old); | 542 | __nf_copy(new, old); |
542 | #if defined(CONFIG_NETFILTER_XT_TARGET_TRACE) || \ | 543 | #if defined(CONFIG_NETFILTER_XT_TARGET_TRACE) || \ |
543 | defined(CONFIG_NETFILTER_XT_TARGET_TRACE_MODULE) | 544 | 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) | |||
550 | #endif | 551 | #endif |
551 | #endif | 552 | #endif |
552 | new->vlan_tci = old->vlan_tci; | 553 | new->vlan_tci = old->vlan_tci; |
554 | #if defined(CONFIG_MAC80211) || defined(CONFIG_MAC80211_MODULE) | ||
555 | new->do_not_encrypt = old->do_not_encrypt; | ||
556 | new->requeue = old->requeue; | ||
557 | #endif | ||
553 | 558 | ||
554 | skb_copy_secmark(new, old); | 559 | skb_copy_secmark(new, old); |
555 | } | 560 | } |
556 | 561 | ||
562 | /* | ||
563 | * You should not add any new code to this function. Add it to | ||
564 | * __copy_skb_header above instead. | ||
565 | */ | ||
557 | static struct sk_buff *__skb_clone(struct sk_buff *n, struct sk_buff *skb) | 566 | static struct sk_buff *__skb_clone(struct sk_buff *n, struct sk_buff *skb) |
558 | { | 567 | { |
559 | #define C(x) n->x = skb->x | 568 | #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) | |||
569 | n->cloned = 1; | 578 | n->cloned = 1; |
570 | n->nohdr = 0; | 579 | n->nohdr = 0; |
571 | n->destructor = NULL; | 580 | n->destructor = NULL; |
572 | C(iif); | ||
573 | C(tail); | 581 | C(tail); |
574 | C(end); | 582 | C(end); |
575 | C(head); | 583 | C(head); |
576 | C(data); | 584 | C(data); |
577 | C(truesize); | 585 | C(truesize); |
578 | #if defined(CONFIG_MAC80211) || defined(CONFIG_MAC80211_MODULE) | ||
579 | C(do_not_encrypt); | ||
580 | C(requeue); | ||
581 | #endif | ||
582 | atomic_set(&n->users, 1); | 586 | atomic_set(&n->users, 1); |
583 | 587 | ||
584 | atomic_inc(&(skb_shinfo(skb)->dataref)); | 588 | atomic_inc(&(skb_shinfo(skb)->dataref)); |