diff options
author | Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp> | 2007-03-14 19:43:37 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-04-26 01:25:54 -0400 |
commit | edda553c324bdc5bb5c2d553b524cab37058a855 (patch) | |
tree | 04b041d20e685e2d7dab1dad41419af0360aa312 | |
parent | 9b88790972498d235a2a4d2b66640c3c5b70bb7c (diff) |
[NETFILTER]: nf_conntrack: add __nf_copy() to copy members in skb
This unifies the codes to copy netfilter related datas. Note that
__nf_copy() assumes destination skb doesn't have any netfilter
related members.
Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp>
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/linux/skbuff.h | 17 | ||||
-rw-r--r-- | net/core/skbuff.c | 28 |
2 files changed, 19 insertions, 26 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 39a6da243b24..62ab1ab07028 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h | |||
@@ -1498,8 +1498,25 @@ static inline void nf_reset(struct sk_buff *skb) | |||
1498 | #endif | 1498 | #endif |
1499 | } | 1499 | } |
1500 | 1500 | ||
1501 | /* Note: This doesn't put any conntrack and bridge info in dst. */ | ||
1502 | static inline void __nf_copy(struct sk_buff *dst, const struct sk_buff *src) | ||
1503 | { | ||
1504 | dst->nfct = src->nfct; | ||
1505 | nf_conntrack_get(src->nfct); | ||
1506 | dst->nfctinfo = src->nfctinfo; | ||
1507 | #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) | ||
1508 | dst->nfct_reasm = src->nfct_reasm; | ||
1509 | nf_conntrack_get_reasm(src->nfct_reasm); | ||
1510 | #endif | ||
1511 | #ifdef CONFIG_BRIDGE_NETFILTER | ||
1512 | dst->nf_bridge = src->nf_bridge; | ||
1513 | nf_bridge_get(src->nf_bridge); | ||
1514 | #endif | ||
1515 | } | ||
1516 | |||
1501 | #else /* CONFIG_NETFILTER */ | 1517 | #else /* CONFIG_NETFILTER */ |
1502 | static inline void nf_reset(struct sk_buff *skb) {} | 1518 | static inline void nf_reset(struct sk_buff *skb) {} |
1519 | static inline void __nf_copy(struct sk_buff *dst, const struct sk_buff *src) {} | ||
1503 | #endif /* CONFIG_NETFILTER */ | 1520 | #endif /* CONFIG_NETFILTER */ |
1504 | 1521 | ||
1505 | #ifdef CONFIG_NETWORK_SECMARK | 1522 | #ifdef CONFIG_NETWORK_SECMARK |
diff --git a/net/core/skbuff.c b/net/core/skbuff.c index b242020c02f7..408cc99af6b3 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c | |||
@@ -422,19 +422,7 @@ struct sk_buff *skb_clone(struct sk_buff *skb, gfp_t gfp_mask) | |||
422 | C(protocol); | 422 | C(protocol); |
423 | n->destructor = NULL; | 423 | n->destructor = NULL; |
424 | C(mark); | 424 | C(mark); |
425 | #ifdef CONFIG_NETFILTER | 425 | __nf_copy(n, skb); |
426 | C(nfct); | ||
427 | nf_conntrack_get(skb->nfct); | ||
428 | C(nfctinfo); | ||
429 | #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) | ||
430 | C(nfct_reasm); | ||
431 | nf_conntrack_get_reasm(skb->nfct_reasm); | ||
432 | #endif | ||
433 | #ifdef CONFIG_BRIDGE_NETFILTER | ||
434 | C(nf_bridge); | ||
435 | nf_bridge_get(skb->nf_bridge); | ||
436 | #endif | ||
437 | #endif /*CONFIG_NETFILTER*/ | ||
438 | #ifdef CONFIG_NET_SCHED | 426 | #ifdef CONFIG_NET_SCHED |
439 | C(tc_index); | 427 | C(tc_index); |
440 | #ifdef CONFIG_NET_CLS_ACT | 428 | #ifdef CONFIG_NET_CLS_ACT |
@@ -483,22 +471,10 @@ static void copy_skb_header(struct sk_buff *new, const struct sk_buff *old) | |||
483 | new->tstamp = old->tstamp; | 471 | new->tstamp = old->tstamp; |
484 | new->destructor = NULL; | 472 | new->destructor = NULL; |
485 | new->mark = old->mark; | 473 | new->mark = old->mark; |
486 | #ifdef CONFIG_NETFILTER | 474 | __nf_copy(new, old); |
487 | new->nfct = old->nfct; | ||
488 | nf_conntrack_get(old->nfct); | ||
489 | new->nfctinfo = old->nfctinfo; | ||
490 | #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) | ||
491 | new->nfct_reasm = old->nfct_reasm; | ||
492 | nf_conntrack_get_reasm(old->nfct_reasm); | ||
493 | #endif | ||
494 | #if defined(CONFIG_IP_VS) || defined(CONFIG_IP_VS_MODULE) | 475 | #if defined(CONFIG_IP_VS) || defined(CONFIG_IP_VS_MODULE) |
495 | new->ipvs_property = old->ipvs_property; | 476 | new->ipvs_property = old->ipvs_property; |
496 | #endif | 477 | #endif |
497 | #ifdef CONFIG_BRIDGE_NETFILTER | ||
498 | new->nf_bridge = old->nf_bridge; | ||
499 | nf_bridge_get(old->nf_bridge); | ||
500 | #endif | ||
501 | #endif | ||
502 | #ifdef CONFIG_NET_SCHED | 478 | #ifdef CONFIG_NET_SCHED |
503 | #ifdef CONFIG_NET_CLS_ACT | 479 | #ifdef CONFIG_NET_CLS_ACT |
504 | new->tc_verd = old->tc_verd; | 480 | new->tc_verd = old->tc_verd; |