nf_conntrack: clean up to reduce size of 'struct nf_conn'
Subsystems (3)
PATCH 1/1 nf_conntrack: clean up to reduce size of 'struct nf_conn'
Hi Dave!
This is net-2.6.17 stuff, please apply.
Thanks!
[NETFILTER] nf_conntrack: clean up to reduce size of 'struct nf_conn'
This patch moves all helper related data fields of 'struct nf_conn' into a separate structure 'struct nf_conn_help'. This new structure is only present in conntrack entries for which we actually have a helper loaded.
Also, this patch cleans up the nf_conntrack 'features' mechanism to resemble what the original idea was: Just glue the feature-specific data structures at the end of 'struct nf_conn', and explicitly re-calculate the pointer to it when needed rather than keeping pointers around.
Saves 20 bytes per conntrack on my x86_64 box. A non-helped conntrack is 276 bytes. We still need to save another 20 bytes in order to fit into to target of 256bytes.
---
commit aba8cf3ac5b60e10eb1ce9f30b6bb4c007ab9868
tree 758aedbe80b8306c1991a05c47eab8905d33a13b
parent 94d3d40c84672b74e59ea5252f61602610e1513e
author Harald Welte <[email protected]> Sun, 29 Jan 2006 19:19:06 +0100 committer Harald Welte <[email protected]> Sun, 29 Jan 2006 19:19:06 +0100
include/net/netfilter/nf_conntrack.h | 56 +++++++---- net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | 22 ++--- net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c | 39 +++++--- net/netfilter/nf_conntrack_core.c | 117 ++++++++++-------------- net/netfilter/nf_conntrack_ftp.c | 2 net/netfilter/nf_conntrack_netlink.c | 39 +++++--- net/netfilter/nf_conntrack_standalone.c | 1 net/netfilter/xt_helper.c | 8 +- 8 files changed, 147 insertions(+), 137 deletions(-)
include/net/netfilter/nf_conntrack.h +34 -22
@@ -67,6 +67,18 @@ do { \struct nf_conntrack_helper ; +/* nf_conn feature for connections that have a helper */ +struct nf_conn_help { +/* Helper. if any */ +struct nf_conntrack_helper *helper; + +union nf_conntrack_help help; + +/* Current number of expected connections */ +unsigned int expecting; +}; + +#include <net/netfilter/ipv4/nf_conntrack_ipv4.h> struct nf_conn {
@@ -81,6 +93,9 @@ struct nf_conn/* Have we seen traffic both ways yet? (bitset) */ unsigned long status; +/* If we were expected by an expectation, this will be it */ +struct nf_conn *master; +/* Timer function; drops refcnt when it goes off. */ struct timer_list timeout;
@@ -88,38 +103,22 @@ struct nf_conn/* Accounting Information (same cache line as other written members) */ struct ip_conntrack_counter counters[IP_CT_DIR_MAX ];#endif -/* If we were expected by an expectation, this will be it */ -struct nf_conn *master; - -/* Current number of expected connections */ -unsigned int expecting;/* Unique ID that identifies this conntrack*/ unsigned int id; -/* Helper. if any */ -struct nf_conntrack_helper *helper; -/* features - nat, helper, ... used by allocating system */ u_int32_t features; -/* Storage reserved for other modules: */ - -union nf_conntrack_proto proto; -#if defined(CONFIG_NF_CONNTRACK_MARK )u_int32_t mark;#endif -/* These members are dynamically allocated. */ - -union nf_conntrack_help *help; +/* Storage reserved for other modules: */ +union nf_conntrack_proto proto; -/* Layer 3 dependent members. (ex: NAT) */ -union { -struct nf_conntrack_ipv4 *ipv4; - } l3proto; -void *data[0 ]; +/* features dynamically at the end: helper, nat (both optional) */ +char data[0 ]; };struct nf_conntrack_expect
@@ -373,10 +372,23 @@ nf_conntrack_expect_event(enum ip_conntr#define NF_CT_F_NUM 4extern int -nf_conntrack_register_cache (u_int32_t features,const char *name,size_t size, -int (*init_conntrack)(struct nf_conn *,u_int32_t )); +nf_conntrack_register_cache (u_int32_t features,const char *name,size_t size);extern void nf_conntrack_unregister_cache (u_int32_t features); +/* valid combinations: +* basic: nf_conn, nf_conn .. nf_conn_help +* nat: nf_conn .. nf_conn_nat, nf_conn .. nf_conn_nat, nf_conn help +*/ +static inline struct nf_conn_help *nfct_help (const struct nf_conn *ct) +{ +unsigned int offset =sizeof (struct nf_conn ); + +if (!(ct->features &NF_CT_F_HELP )) +return NULL ; + +return (struct nf_conn_help *) ((void *)ct + offset); +} +#endif /* __KERNEL__ */ #endif /* _NF_CONNTRACK_H */
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c +12 -10
@@ -141,19 +141,21 @@ static unsigned int ipv4_conntrack_help( {struct nf_conn *ct;enum ip_conntrack_info ctinfo; +struct nf_conn_help *help;/* This is where we call the helper: as the packet goes out. */ ct =nf_ct_get (*pskb, &ctinfo); -if (ct && ct->helper) { -unsigned int ret; - ret = ct->helper->help (pskb, - (*pskb)->nh.raw - (*pskb)->data - + (*pskb)->nh.iph->ihl*4 , - ct, ctinfo); -if (ret !=NF_ACCEPT ) -return ret; - } -return NF_ACCEPT ; +if (!ct) +return NF_ACCEPT ; + + help =nfct_help (ct); +if (!help || !help->helper) +return NF_ACCEPT ; + +return help->helper->help (pskb, + (*pskb)->nh.raw - (*pskb)->data + + (*pskb)->nh.iph->ihl*4 , + ct, ctinfo); } static unsigned int ipv4_conntrack_defrag(unsigned int hooknum,
net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c +22 -17
@@ -179,31 +179,36 @@ static unsigned int ipv6_confirm(unsigne int (*okfn)(struct sk_buff *)) {struct nf_conn *ct; +struct nf_conn_help *help;enum ip_conntrack_info ctinfo; +unsigned int ret, protoff; +unsigned int extoff = (u8 *)((*pskb)->nh.ipv6h +1 ) + - (*pskb)->data; +unsigned char pnum = (*pskb)->nh.ipv6h->nexthdr; +/* This is where we call the helper: as the packet goes out. */ ct =nf_ct_get (*pskb, &ctinfo); -if (ct && ct->helper) { -unsigned int ret, protoff; -unsigned int extoff = (u8 *)((*pskb)->nh.ipv6h +1 ) - - (*pskb)->data; -unsigned char pnum = (*pskb)->nh.ipv6h->nexthdr; - - protoff =nf_ct_ipv6_skip_exthdr (*pskb, extoff, &pnum, - (*pskb)->len - extoff); -if (protoff <0 || protoff > (*pskb)->len || - pnum ==NEXTHDR_FRAGMENT ) { -DEBUGP ("proto header not found\n" ); -return NF_ACCEPT ; - } +if (!ct) + goto out; - ret = ct->helper->help (pskb, protoff, ct, ctinfo); -if (ret !=NF_ACCEPT ) -return ret; + help =nfct_help (ct); +if (!help || !help->helper) + goto out; + + protoff =nf_ct_ipv6_skip_exthdr (*pskb, extoff, &pnum, + (*pskb)->len - extoff); +if (protoff <0 || protoff > (*pskb)->len || + pnum ==NEXTHDR_FRAGMENT ) { +DEBUGP ("proto header not found\n" ); +return NF_ACCEPT ; } + ret = help->helper->help (pskb, protoff, ct, ctinfo); +if (ret !=NF_ACCEPT ) +return ret; +out:/* We've seen it coming out the other side: confirm it */ -return nf_conntrack_confirm (pskb); }
net/netfilter/nf_conntrack_core.c +51 -66
288 lines not on this page · raw message
net/netfilter/nf_conntrack_ftp.c +1 -1
@@ -440,7 +440,7 @@ static int help(struct sk_buff **pskb,u32 seq;int dir =CTINFO2DIR (ctinfo);unsigned int matchlen, matchoff; -struct ip_ct_ftp_master *ct_ftp_info = &ct->help->ct_ftp_info; +struct ip_ct_ftp_master *ct_ftp_info = &nfct_help (ct)->help.ct_ftp_info;struct nf_conntrack_expect *exp;struct nf_conntrack_man cmd = {};
net/netfilter/nf_conntrack_netlink.c +22 -17
@@ -2,7 +2,7 @@* protocol helpers and general trouble making from userspace. * * (C) 2001 by Jay Schulist <[email protected]> -* (C) 2002-2005 by Harald Welte <[email protected]> +* (C) 2002-2006 by Harald Welte <[email protected]> * (C) 2003 by Patrick Mchardy <[email protected]> * (C) 2005 by Pablo Neira Ayuso <[email protected]> *
@@ -44,7 +44,7 @@MODULE_LICENSE ("GPL" ); -static char __initdata version[] ="0.92" ; +static char __initdata version[] ="0.93" ;#if 0 #define DEBUGP printk
@@ -165,15 +165,16 @@ static inline int ctnetlink_dump_helpinfo(struct sk_buff *skb, const struct nf_conn *ct) { struct nfattr *nest_helper; +const struct nf_conn_help *help =nfct_help (ct); -if (!ct->helper) +if (!help)return 0 ; nest_helper =NFA_NEST (skb,CTA_HELP ); -NFA_PUT (skb,CTA_HELP_NAME ,strlen (ct->helper->name), ct->helper->name); +NFA_PUT (skb,CTA_HELP_NAME ,strlen (help->helper->name), help->helper->name); -if (ct->helper->to_nfattr) - ct->helper->to_nfattr (skb, ct); +if (help->helper->to_nfattr) + help->helper->to_nfattr (skb, ct);NFA_NEST_END (skb, nest_helper);
@@ -903,11 +904,17 @@ static inline int ctnetlink_change_helper(struct nf_conn *ct, struct nfattr *cda[]) { struct nf_conntrack_helper *helper; +struct nf_conn_help *help =nfct_help (ct);char *helpname;int err;DEBUGP ("entered %s\n" , __FUNCTION__); +if (!help) { +/* FIXME: we need to reallocate and rehash */ +return -EBUSY ; + } +/* don't change helper of sibling connections */ if (ct->master)return -EINVAL ;
@@ -924,18 +931,18 @@ ctnetlink_change_helper(struct nf_conn *return -EINVAL ; } -if (ct->helper) { +if (help->helper) {if (!helper) {/* we had a helper before ... */ nf_ct_remove_expectations (ct); - ct->helper =NULL ; + help->helper =NULL ; }else {/* need to zero data of old helper */ -memset (&ct->help,0 ,sizeof (ct->help)); +memset (&help->help,0 ,sizeof (help->help)); } } - ct->helper = helper; + help->helper = helper;return 0 ; }
@@ -1050,14 +1057,9 @@ ctnetlink_create_conntrack(struct nfattr ct->mark =ntohl (*(u_int32_t *)NFA_DATA (cda[CTA_MARK -1 ]));#endif - ct->helper =nf_ct_helper_find_get (rtuple); -add_timer (&ct->timeout);nf_conntrack_hash_insert (ct); -if (ct->helper) -nf_ct_helper_put (ct->helper); -DEBUGP ("conntrack with id %u inserted\n" , ct->id);return 0 ;
@@ -1417,7 +1419,8 @@ ctnetlink_del_expect(struct sock *ctnl, }list_for_each_entry_safe (exp, tmp, &nf_conntrack_expect_list, list) { -if (exp->master->helper == h +struct nf_conn_help *m_help =nfct_help (exp->master); +if (m_help->helper == h &&del_timer (&exp->timeout)) {nf_ct_unlink_expect (exp);nf_conntrack_expect_put (exp);
@@ -1452,6 +1455,7 @@ ctnetlink_create_expect(struct nfattr *cstruct nf_conntrack_tuple_hash *h =NULL ;struct nf_conntrack_expect *exp;struct nf_conn *ct; +struct nf_conn_help *help;int err =0 ;DEBUGP ("entered %s\n" , __FUNCTION__);
@@ -1472,8 +1476,9 @@ ctnetlink_create_expect(struct nfattr *cif (!h)return -ENOENT ; ct =nf_ct_tuplehash_to_ctrack (h); + help =nfct_help (ct); -if (!ct->helper) { +if (!help || !help->helper) {/* such conntrack hasn't got any helper, abort */ err = -EINVAL ; goto out;
net/netfilter/nf_conntrack_standalone.c +0 -1
@@ -839,7 +839,6 @@ EXPORT_SYMBOL(nf_conntrack_l3proto_unregEXPORT_SYMBOL (nf_conntrack_protocol_register);EXPORT_SYMBOL (nf_conntrack_protocol_unregister);EXPORT_SYMBOL (nf_ct_invert_tuplepr); -EXPORT_SYMBOL (nf_conntrack_alter_reply);EXPORT_SYMBOL (nf_conntrack_destroyed);EXPORT_SYMBOL (need_conntrack);EXPORT_SYMBOL (nf_conntrack_helper_register);
net/netfilter/xt_helper.c +5 -3
@@ -96,6 +96,7 @@ match(const struct sk_buff *skb, {const struct xt_helper_info *info = matchinfo;struct nf_conn *ct; +struct nf_conn_help *master_help;enum ip_conntrack_info ctinfo;int ret = info->invert;
@@ -111,7 +112,8 @@ match(const struct sk_buff *skb, }read_lock_bh (&nf_conntrack_lock); -if (!ct->master->helper) { + master_help =nfct_help (ct->master); +if (!master_help || !master_help->helper) {DEBUGP ("xt_helper: master ct %p has no helper\n" , exp->expectant); goto out_unlock;
@@ -123,8 +125,8 @@ match(const struct sk_buff *skb,if (info->name[0 ] =='\0' ) ret ^=1 ;else - ret ^= !strncmp (ct->master->helper->name, info->name, -strlen (ct->master->helper->name)); + ret ^= !strncmp (master_help->helper->name, info->name, +strlen (master_help->helper->name)); out_unlock:read_unlock_bh (&nf_conntrack_lock);return ret;
Signature · 4 lines
- Harald Welte <[email protected]> http://gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6)
Hi, Harald,
From: Harald Welte <[email protected]>
Date: Sun, 12 Feb 2006 18:56:22 +0100
Quoted 11 lines
[NETFILTER]
nf_conntrack: clean up to reduce size of 'structnf_conn'This patch moves all helper related data fields of 'struct
nf_conn' into a separate structure 'structnf_conn_help'. This new structure is only present in conntrack entries for which we actually have a helper loaded.Also, this patch cleans up the
nf_conntrack'features' mechanism to resemble what the original idea was: Just glue the feature-specific data structures at the end of 'structnf_conn', and explicitly re-calculate the pointer to it when needed rather than keeping pointers around.
Quoted 5 lines
Saves 20 bytes per conntrack on my
x86_64box. A non-helped conntrack is 276 bytes. We still need to save another 20 bytes in order to fit into to target of 256bytes.Signed-off-by Harald Welte <[email protected]>
This patch seems not to include fixes I pointed out and you said "fixed". Please confirm if you really sent the intended one.
Regards,
-- Yasuyuki Kozakai
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 17 lines · Yasuyuki KOZAKAI
Hi, Harald,
From: Harald Welte <[email protected]>
Date: Sun, 12 Feb 2006 18:56:22 +0100Quoted 11 lines
[NETFILTER]
nf_conntrack: clean up to reduce size of 'structnf_conn'This patch moves all helper related data fields of 'struct
nf_conn' into a separate structure 'structnf_conn_help'. This new structure is only present in conntrack entries for which we actually have a helper loaded.Also, this patch cleans up the
nf_conntrack'features' mechanism to resemble what the original idea was: Just glue the feature-specific data structures at the end of 'structnf_conn', and explicitly re-calculate the pointer to it when needed rather than keeping pointers around.
Quoted 8 lines
Quoted 5 lines
Saves 20 bytes per conntrack on my
x86_64box. A non-helped conntrack is 276 bytes. We still need to save another 20 bytes in order to fit into to target of 256bytes.Signed-off-by Harald Welte <[email protected]>This patch seems not to include fixes I pointed out and you said "fixed". Please confirm if you really sent the intended one.
oops, thanks for checking. Dave: Please hold, I sent an old version. You'll get a new one ASAP.
Signature · 5 lines
- Harald Welte <[email protected]> http://netfilter.org/ ============================================================================ "Fragmentation is like classful addressing -- an interesting early architectural error that shows how much experimentation was going on while IP was being designed." -- Paul Vixie
David S. Miller
maintainerFrom: Harald Welte <[email protected]>
Date: Mon, 13 Feb 2006 09:17:58 +0100
Quoted 2 lines
Dave: Please hold, I sent an old version.
You'll get a new one ASAP.
OK.
Hi Dave!
This is the correct (latest) version of this patch. Sorry for the confusion. Please apply to net-2.6.17, thanks!
[NETFILTER] nf_conntrack: clean up to reduce size of 'struct nf_conn'
This patch moves all helper related data fields of 'struct nf_conn' into a separate structure 'struct nf_conn_help'. This new structure is only present in conntrack entries for which we actually have a helper loaded.
Also, this patch cleans up the nf_conntrack 'features' mechanism to resemble what the original idea was: Just glue the feature-specific data structures at the end of 'struct nf_conn', and explicitly re-calculate the pointer to it when needed rather than keeping pointers around.
Saves 20 bytes per conntrack on my x86_64 box. A non-helped conntrack is 276 bytes. We still need to save another 20 bytes in order to fit into to target of 256bytes.
---
commit aba8cf3ac5b60e10eb1ce9f30b6bb4c007ab9868
tree 758aedbe80b8306c1991a05c47eab8905d33a13b
parent 94d3d40c84672b74e59ea5252f61602610e1513e
author Harald Welte <[email protected]> Sun, 29 Jan 2006 19:19:06 +0100 committer Harald Welte <[email protected]> Sun, 29 Jan 2006 19:19:06 +0100
include/net/netfilter/nf_conntrack.h | 56 +++++++---- net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | 22 ++--- net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c | 39 +++++--- net/netfilter/nf_conntrack_core.c | 117 ++++++++++-------------- net/netfilter/nf_conntrack_ftp.c | 2 net/netfilter/nf_conntrack_netlink.c | 39 +++++--- net/netfilter/nf_conntrack_standalone.c | 1 net/netfilter/xt_helper.c | 8 +- 8 files changed, 147 insertions(+), 137 deletions(-)
include/net/netfilter/nf_conntrack.h +34 -22
@@ -67,6 +67,18 @@ do { \struct nf_conntrack_helper ; +/* nf_conn feature for connections that have a helper */ +struct nf_conn_help { +/* Helper. if any */ +struct nf_conntrack_helper *helper; + +union nf_conntrack_help help; + +/* Current number of expected connections */ +unsigned int expecting; +}; + +#include <net/netfilter/ipv4/nf_conntrack_ipv4.h> struct nf_conn {
@@ -81,6 +93,9 @@ struct nf_conn/* Have we seen traffic both ways yet? (bitset) */ unsigned long status; +/* If we were expected by an expectation, this will be it */ +struct nf_conn *master; +/* Timer function; drops refcnt when it goes off. */ struct timer_list timeout;
@@ -88,38 +103,22 @@ struct nf_conn/* Accounting Information (same cache line as other written members) */ struct ip_conntrack_counter counters[IP_CT_DIR_MAX ];#endif -/* If we were expected by an expectation, this will be it */ -struct nf_conn *master; - -/* Current number of expected connections */ -unsigned int expecting;/* Unique ID that identifies this conntrack*/ unsigned int id; -/* Helper. if any */ -struct nf_conntrack_helper *helper; -/* features - nat, helper, ... used by allocating system */ u_int32_t features; -/* Storage reserved for other modules: */ - -union nf_conntrack_proto proto; -#if defined(CONFIG_NF_CONNTRACK_MARK )u_int32_t mark;#endif -/* These members are dynamically allocated. */ - -union nf_conntrack_help *help; +/* Storage reserved for other modules: */ +union nf_conntrack_proto proto; -/* Layer 3 dependent members. (ex: NAT) */ -union { -struct nf_conntrack_ipv4 *ipv4; - } l3proto; -void *data[0 ]; +/* features dynamically at the end: helper, nat (both optional) */ +char data[0 ]; };struct nf_conntrack_expect
@@ -373,10 +372,23 @@ nf_conntrack_expect_event(enum ip_conntr#define NF_CT_F_NUM 4extern int -nf_conntrack_register_cache (u_int32_t features,const char *name,size_t size, -int (*init_conntrack)(struct nf_conn *,u_int32_t )); +nf_conntrack_register_cache (u_int32_t features,const char *name,size_t size);extern void nf_conntrack_unregister_cache (u_int32_t features); +/* valid combinations: +* basic: nf_conn, nf_conn .. nf_conn_help +* nat: nf_conn .. nf_conn_nat, nf_conn .. nf_conn_nat, nf_conn help +*/ +static inline struct nf_conn_help *nfct_help (const struct nf_conn *ct) +{ +unsigned int offset =sizeof (struct nf_conn ); + +if (!(ct->features &NF_CT_F_HELP )) +return NULL ; + +return (struct nf_conn_help *) ((void *)ct + offset); +} +#endif /* __KERNEL__ */ #endif /* _NF_CONNTRACK_H */
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c +12 -10
@@ -141,19 +141,21 @@ static unsigned int ipv4_conntrack_help( {struct nf_conn *ct;enum ip_conntrack_info ctinfo; +struct nf_conn_help *help;/* This is where we call the helper: as the packet goes out. */ ct =nf_ct_get (*pskb, &ctinfo); -if (ct && ct->helper) { -unsigned int ret; - ret = ct->helper->help (pskb, - (*pskb)->nh.raw - (*pskb)->data - + (*pskb)->nh.iph->ihl*4 , - ct, ctinfo); -if (ret !=NF_ACCEPT ) -return ret; - } -return NF_ACCEPT ; +if (!ct) +return NF_ACCEPT ; + + help =nfct_help (ct); +if (!help || !help->helper) +return NF_ACCEPT ; + +return help->helper->help (pskb, + (*pskb)->nh.raw - (*pskb)->data + + (*pskb)->nh.iph->ihl*4 , + ct, ctinfo); } static unsigned int ipv4_conntrack_defrag(unsigned int hooknum,
net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c +22 -17
@@ -179,31 +179,36 @@ static unsigned int ipv6_confirm(unsigne int (*okfn)(struct sk_buff *)) {struct nf_conn *ct; +struct nf_conn_help *help;enum ip_conntrack_info ctinfo; +unsigned int ret, protoff; +unsigned int extoff = (u8 *)((*pskb)->nh.ipv6h +1 ) + - (*pskb)->data; +unsigned char pnum = (*pskb)->nh.ipv6h->nexthdr; +/* This is where we call the helper: as the packet goes out. */ ct =nf_ct_get (*pskb, &ctinfo); -if (ct && ct->helper) { -unsigned int ret, protoff; -unsigned int extoff = (u8 *)((*pskb)->nh.ipv6h +1 ) - - (*pskb)->data; -unsigned char pnum = (*pskb)->nh.ipv6h->nexthdr; - - protoff =nf_ct_ipv6_skip_exthdr (*pskb, extoff, &pnum, - (*pskb)->len - extoff); -if (protoff <0 || protoff > (*pskb)->len || - pnum ==NEXTHDR_FRAGMENT ) { -DEBUGP ("proto header not found\n" ); -return NF_ACCEPT ; - } +if (!ct) + goto out; - ret = ct->helper->help (pskb, protoff, ct, ctinfo); -if (ret !=NF_ACCEPT ) -return ret; + help =nfct_help (ct); +if (!help || !help->helper) + goto out; + + protoff =nf_ct_ipv6_skip_exthdr (*pskb, extoff, &pnum, + (*pskb)->len - extoff); +if (protoff <0 || protoff > (*pskb)->len || + pnum ==NEXTHDR_FRAGMENT ) { +DEBUGP ("proto header not found\n" ); +return NF_ACCEPT ; } + ret = help->helper->help (pskb, protoff, ct, ctinfo); +if (ret !=NF_ACCEPT ) +return ret; +out:/* We've seen it coming out the other side: confirm it */ -return nf_conntrack_confirm (pskb); }
net/netfilter/nf_conntrack_core.c +52 -67
290 lines not on this page · raw message
net/netfilter/nf_conntrack_ftp.c +1 -1
@@ -440,7 +440,7 @@ static int help(struct sk_buff **pskb,u32 seq;int dir =CTINFO2DIR (ctinfo);unsigned int matchlen, matchoff; -struct ip_ct_ftp_master *ct_ftp_info = &ct->help->ct_ftp_info; +struct ip_ct_ftp_master *ct_ftp_info = &nfct_help (ct)->help.ct_ftp_info;struct nf_conntrack_expect *exp;struct nf_conntrack_man cmd = {};
net/netfilter/nf_conntrack_netlink.c +22 -17
@@ -2,7 +2,7 @@* protocol helpers and general trouble making from userspace. * * (C) 2001 by Jay Schulist <[email protected]> -* (C) 2002-2005 by Harald Welte <[email protected]> +* (C) 2002-2006 by Harald Welte <[email protected]> * (C) 2003 by Patrick Mchardy <[email protected]> * (C) 2005 by Pablo Neira Ayuso <[email protected]> *
@@ -44,7 +44,7 @@MODULE_LICENSE ("GPL" ); -static char __initdata version[] ="0.92" ; +static char __initdata version[] ="0.93" ;#if 0 #define DEBUGP printk
@@ -165,15 +165,16 @@ static inline int ctnetlink_dump_helpinfo(struct sk_buff *skb, const struct nf_conn *ct) { struct nfattr *nest_helper; +const struct nf_conn_help *help =nfct_help (ct); -if (!ct->helper) +if (!help || !help->helper)return 0 ; nest_helper =NFA_NEST (skb,CTA_HELP ); -NFA_PUT (skb,CTA_HELP_NAME ,strlen (ct->helper->name), ct->helper->name); +NFA_PUT (skb,CTA_HELP_NAME ,strlen (help->helper->name), help->helper->name); -if (ct->helper->to_nfattr) - ct->helper->to_nfattr (skb, ct); +if (help->helper->to_nfattr) + help->helper->to_nfattr (skb, ct);NFA_NEST_END (skb, nest_helper);
@@ -903,11 +904,17 @@ static inline int ctnetlink_change_helper(struct nf_conn *ct, struct nfattr *cda[]) { struct nf_conntrack_helper *helper; +struct nf_conn_help *help =nfct_help (ct);char *helpname;int err;DEBUGP ("entered %s\n" , __FUNCTION__); +if (!help) { +/* FIXME: we need to reallocate and rehash */ +return -EBUSY ; + } +/* don't change helper of sibling connections */ if (ct->master)return -EINVAL ;
@@ -924,18 +931,18 @@ ctnetlink_change_helper(struct nf_conn *return -EINVAL ; } -if (ct->helper) { +if (help->helper) {if (!helper) {/* we had a helper before ... */ nf_ct_remove_expectations (ct); - ct->helper =NULL ; + help->helper =NULL ; }else {/* need to zero data of old helper */ -memset (&ct->help,0 ,sizeof (ct->help)); +memset (&help->help,0 ,sizeof (help->help)); } } - ct->helper = helper; + help->helper = helper;return 0 ; }
@@ -1050,14 +1057,9 @@ ctnetlink_create_conntrack(struct nfattr ct->mark =ntohl (*(u_int32_t *)NFA_DATA (cda[CTA_MARK -1 ]));#endif - ct->helper =nf_ct_helper_find_get (rtuple); -add_timer (&ct->timeout);nf_conntrack_hash_insert (ct); -if (ct->helper) -nf_ct_helper_put (ct->helper); -DEBUGP ("conntrack with id %u inserted\n" , ct->id);return 0 ;
@@ -1417,7 +1419,8 @@ ctnetlink_del_expect(struct sock *ctnl, }list_for_each_entry_safe (exp, tmp, &nf_conntrack_expect_list, list) { -if (exp->master->helper == h +struct nf_conn_help *m_help =nfct_help (exp->master); +if (m_help->helper == h &&del_timer (&exp->timeout)) {nf_ct_unlink_expect (exp);nf_conntrack_expect_put (exp);
@@ -1452,6 +1455,7 @@ ctnetlink_create_expect(struct nfattr *cstruct nf_conntrack_tuple_hash *h =NULL ;struct nf_conntrack_expect *exp;struct nf_conn *ct; +struct nf_conn_help *help;int err =0 ;DEBUGP ("entered %s\n" , __FUNCTION__);
@@ -1472,8 +1476,9 @@ ctnetlink_create_expect(struct nfattr *cif (!h)return -ENOENT ; ct =nf_ct_tuplehash_to_ctrack (h); + help =nfct_help (ct); -if (!ct->helper) { +if (!help || !help->helper) {/* such conntrack hasn't got any helper, abort */ err = -EINVAL ; goto out;
net/netfilter/nf_conntrack_standalone.c +0 -1
@@ -839,7 +839,6 @@ EXPORT_SYMBOL(nf_conntrack_l3proto_unregEXPORT_SYMBOL (nf_conntrack_protocol_register);EXPORT_SYMBOL (nf_conntrack_protocol_unregister);EXPORT_SYMBOL (nf_ct_invert_tuplepr); -EXPORT_SYMBOL (nf_conntrack_alter_reply);EXPORT_SYMBOL (nf_conntrack_destroyed);EXPORT_SYMBOL (need_conntrack);EXPORT_SYMBOL (nf_conntrack_helper_register);
net/netfilter/xt_helper.c +5 -3
@@ -96,6 +96,7 @@ match(const struct sk_buff *skb, {const struct xt_helper_info *info = matchinfo;struct nf_conn *ct; +struct nf_conn_help *master_help;enum ip_conntrack_info ctinfo;int ret = info->invert;
@@ -111,7 +112,8 @@ match(const struct sk_buff *skb, }read_lock_bh (&nf_conntrack_lock); -if (!ct->master->helper) { + master_help =nfct_help (ct->master); +if (!master_help || !master_help->helper) {DEBUGP ("xt_helper: master ct %p has no helper\n" , exp->expectant); goto out_unlock;
@@ -123,8 +125,8 @@ match(const struct sk_buff *skb,if (info->name[0 ] =='\0' ) ret ^=1 ;else - ret ^= !strncmp (ct->master->helper->name, info->name, -strlen (ct->master->helper->name)); + ret ^= !strncmp (master_help->helper->name, info->name, +strlen (master_help->helper->name)); out_unlock:read_unlock_bh (&nf_conntrack_lock);return ret;
Signature · 5 lines
- Harald Welte <[email protected]> http://netfilter.org/ ============================================================================ "Fragmentation is like classful addressing -- an interesting early architectural error that shows how much experimentation was going on while IP was being designed." -- Paul Vixie
From: Harald Welte <[email protected]>
Date: Mon, 13 Feb 2006 11:04:36 +0100
Quoted 2 lines
This is the correct (latest) version of this patch. Sorry for the confusion. Please apply to net-2.6.17, thanks!
Applied, thanks.