: Netfilter update for 2.6.22
Subsystems (3)
cover : Netfilter update for 2.6.22
Hi Dave,
following is a first batch of netfilter patches for 2.6.22, containing the scheduled removal of ip_conntrack/ip_nat, some further nf_conntrack locking cleanup, nfnetlink cleanup and a few minor enhancements in various places. The patches should apply cleanly to the current net-2.6.22 tree.
Please apply, thanks.
Documentation/feature-removal-schedule.txt | 9 include/linux/jhash.h | 2 include/linux/netfilter/nf_conntrack_tcp.h | 5 include/linux/netfilter/nfnetlink.h | 13 include/linux/netfilter/nfnetlink_conntrack.h | 4 include/linux/netfilter_ipv4/Kbuild | 14 include/linux/netfilter_ipv4/ip_conntrack.h | 402 --- include/linux/netfilter_ipv4/ip_conntrack_amanda.h | 11 include/linux/netfilter_ipv4/ip_conntrack_core.h | 61 include/linux/netfilter_ipv4/ip_conntrack_ftp.h | 44 include/linux/netfilter_ipv4/ip_conntrack_h323.h | 89 include/linux/netfilter_ipv4/ip_conntrack_helper.h | 46 include/linux/netfilter_ipv4/ip_conntrack_icmp.h | 6 include/linux/netfilter_ipv4/ip_conntrack_irc.h | 32 include/linux/netfilter_ipv4/ip_conntrack_pptp.h | 326 --- include/linux/netfilter_ipv4/ip_conntrack_proto_gre.h | 114 - include/linux/netfilter_ipv4/ip_conntrack_protocol.h | 98 include/linux/netfilter_ipv4/ip_conntrack_sctp.h | 6 include/linux/netfilter_ipv4/ip_conntrack_sip.h | 40 include/linux/netfilter_ipv4/ip_conntrack_tcp.h | 6 include/linux/netfilter_ipv4/ip_conntrack_tftp.h | 20 include/linux/netfilter_ipv4/ip_conntrack_tuple.h | 146 - include/linux/netfilter_ipv4/ip_nat.h | 79 include/linux/netfilter_ipv4/ip_nat_core.h | 18 include/linux/netfilter_ipv4/ip_nat_helper.h | 33 include/linux/netfilter_ipv4/ip_nat_pptp.h | 11 include/linux/netfilter_ipv4/ip_nat_protocol.h | 74 include/linux/netfilter_ipv4/ip_nat_rule.h | 28 include/linux/netfilter_ipv4/ipt_SAME.h | 2 include/linux/skbuff.h | 30 include/net/netfilter/nf_conntrack.h | 5 include/net/netfilter/nf_conntrack_compat.h | 145 - include/net/netfilter/nf_conntrack_core.h | 3 include/net/netfilter/nf_conntrack_ecache.h | 30 include/net/netfilter/nf_conntrack_l3proto.h | 5 include/net/netfilter/nf_nat_rule.h | 10 net/core/skbuff.c | 28 net/ipv4/ip_output.c | 13 net/ipv4/netfilter/Kconfig | 267 -- net/ipv4/netfilter/Makefile | 45 net/ipv4/netfilter/ip_conntrack_amanda.c | 229 -- net/ipv4/netfilter/ip_conntrack_core.c | 1549 --------------- net/ipv4/netfilter/ip_conntrack_ftp.c | 520 ----- net/ipv4/netfilter/ip_conntrack_helper_h323.c | 1840 ------------------ net/ipv4/netfilter/ip_conntrack_helper_pptp.c | 684 ------ net/ipv4/netfilter/ip_conntrack_irc.c | 314 --- net/ipv4/netfilter/ip_conntrack_netbios_ns.c | 143 - net/ipv4/netfilter/ip_conntrack_netlink.c | 1577 --------------- net/ipv4/netfilter/ip_conntrack_proto_generic.c | 74 net/ipv4/netfilter/ip_conntrack_proto_gre.c | 328 --- net/ipv4/netfilter/ip_conntrack_proto_icmp.c | 315 --- net/ipv4/netfilter/ip_conntrack_proto_sctp.c | 659 ------ net/ipv4/netfilter/ip_conntrack_proto_tcp.c | 1163 ----------- net/ipv4/netfilter/ip_conntrack_proto_udp.c | 148 - net/ipv4/netfilter/ip_conntrack_sip.c | 520 ----- net/ipv4/netfilter/ip_conntrack_standalone.c | 962 --------- net/ipv4/netfilter/ip_conntrack_tftp.c | 161 - net/ipv4/netfilter/ip_nat_amanda.c | 85 net/ipv4/netfilter/ip_nat_core.c | 633 ------ net/ipv4/netfilter/ip_nat_ftp.c | 180 - net/ipv4/netfilter/ip_nat_helper.c | 436 ---- net/ipv4/netfilter/ip_nat_helper_h323.c | 611 ----- net/ipv4/netfilter/ip_nat_helper_pptp.c | 350 --- net/ipv4/netfilter/ip_nat_irc.c | 122 - net/ipv4/netfilter/ip_nat_proto_gre.c | 174 - net/ipv4/netfilter/ip_nat_proto_icmp.c | 87 net/ipv4/netfilter/ip_nat_proto_tcp.c | 154 - net/ipv4/netfilter/ip_nat_proto_udp.c | 144 - net/ipv4/netfilter/ip_nat_proto_unknown.c | 55 net/ipv4/netfilter/ip_nat_rule.c | 314 --- net/ipv4/netfilter/ip_nat_sip.c | 282 -- net/ipv4/netfilter/ip_nat_snmp_basic.c | 1333 ------------- net/ipv4/netfilter/ip_nat_standalone.c | 384 --- net/ipv4/netfilter/ip_nat_tftp.c | 70 net/ipv4/netfilter/ipt_CLUSTERIP.c | 18 net/ipv4/netfilter/ipt_MASQUERADE.c | 57 net/ipv4/netfilter/ipt_NETMAP.c | 22 net/ipv4/netfilter/ipt_REDIRECT.c | 24 net/ipv4/netfilter/ipt_SAME.c | 25 net/ipv4/netfilter/nf_nat_h323.c | 4 net/ipv4/netfilter/nf_nat_pptp.c | 2 net/ipv6/ip6_output.c | 18 net/netfilter/Kconfig | 63 net/netfilter/nf_conntrack_core.c | 27 net/netfilter/nf_conntrack_ecache.c | 23 net/netfilter/nf_conntrack_proto.c | 168 - net/netfilter/nf_conntrack_proto_tcp.c | 63 net/netfilter/nfnetlink.c | 171 - net/netfilter/x_tables.c | 26 net/netfilter/xt_CONNMARK.c | 32 net/netfilter/xt_CONNSECMARK.c | 18 net/netfilter/xt_NOTRACK.c | 4 net/netfilter/xt_connbytes.c | 10 net/netfilter/xt_connmark.c | 17 net/netfilter/xt_conntrack.c | 110 - net/netfilter/xt_helper.c | 57 net/netfilter/xt_state.c | 4 97 files changed, 384 insertions(+), 19499 deletions(-)
Pablo Neira Ayuso:
[NETFILTER]: nfnetlink: remove early debugging messages from nfnetlink [NETFILTER]: nfnetlink: remove duplicate checks in nfnetlink_check_attributes [NETFILTER]: nfnetlink: remove unrequired check in nfnetlink_get_subsys [NETFILTER]: nfnetlink: remove unused includes in nfnetlink.c [NETFILTER]: nfnetlink: move EXPORT_SYMBOL declarations next to the exported symbol [NETFILTER]: ctnetlink: add support for internal tcp connection tracking flags handling [NETFILTER]: nfnetlink: parse attributes with nfattr_parse in nfnetlink_check_attribute
Patrick McHardy:
[NETFILTER]: Remove IPv4 only connection tracking/NAT [NETFILTER]: nf_conntrack: switch protocol registration/unregistration to mutex [NETFILTER]: nf_conntrack: remove ugly hack in l4proto registration [NETFILTER]: nf_conntrack: simplify protocol locking
[NETFILTER]: nf_conntrack: simplify l4 protocol array allocation [NETFILTER]: nfnetlink: use mutex instead of semaphore [NETFILTER]: nfnetlink: use netlink_run_queue()
[NETFILTER]: nf_conntrack: uninline notifier registration functions [JHASH]: Use const in jhash2
Sami Farin:
[NETFILTER]: nf_conntrack: use jhash2 in __hash_conntrack
Tobias Klauser:
[NETFILTER]: x_tables: remove duplicate of xt_prefix
Willy Tarreau:
[NETFILTER]: TCP conntrack: accept RST|PSH as valid [NETFILTER]: TCP conntrack: factorize out the PUSH flag
Yasuyuki Kozakai:
[NETFILTER]: nf_conntrack: add __nf_copy() to copy members in skb [NETFILTER]: nf_conntrack: add nf_copy() to safely copy members in skb
PATCH 1/22 : x_tables: remove duplicate of xt_prefix
[NETFILTER]: x_tables: remove duplicate of xt_prefix
Remove xt_proto_prefix array which duplicates xt_prefix and change all users of xt_proto_prefix to xt_prefix.
---
commit c9e0a6db3a45a0b71c5e81d4915c9734719ad998
tree d9d9db95b2b6cb407802db9d55dba496854741d4
parent 384510bca7c96113e5dca3bcc7f84a2934d707f1
author Tobias Klauser <[email protected]> Thu, 08 Mar 2007 18:22:29 +0100 committer Patrick McHardy <[email protected]> Tue, 13 Mar 2007 17:01:59 +0100
net/netfilter/x_tables.c | 26 ++++++++++---------------- 1 files changed, 10 insertions(+), 16 deletions(-)
net/netfilter/x_tables.c +10 -16
@@ -56,8 +56,8 @@ enum { };static const char *xt_prefix[NPROTO ] = { - [AF_INET ] ="ip" , - [AF_INET6 ] ="ip6" , + [AF_INET ] ="ip" , + [AF_INET6 ] ="ip6" , [NF_ARP ] ="arp" , };
@@ -651,12 +651,6 @@ void *xt_unregister_table(struct xt_tablEXPORT_SYMBOL_GPL (xt_unregister_table);#ifdef CONFIG_PROC_FS -static char *xt_proto_prefix[NPROTO ] = { - [AF_INET ] ="ip" , - [AF_INET6 ] ="ip6" , - [NF_ARP ] ="arp" , -}; -static struct list_head *xt_get_idx (struct list_head *list,struct seq_file *seq,loff_t pos) {struct list_head *head = list->next;
@@ -798,7 +792,7 @@ #endif#ifdef CONFIG_PROC_FS -strlcpy (buf, xt_proto_prefix[af],sizeof (buf)); +strlcpy (buf, xt_prefix[af],sizeof (buf));strlcat (buf,FORMAT_TABLES ,sizeof (buf)); proc =proc_net_fops_create (buf,0440 , &xt_file_ops);if (!proc)
@@ -806,14 +800,14 @@ #ifdef CONFIG_PROC_FS proc->data = (void *) ((unsigned long ) af | (TABLE <<16 )); -strlcpy (buf, xt_proto_prefix[af],sizeof (buf)); +strlcpy (buf, xt_prefix[af],sizeof (buf));strlcat (buf,FORMAT_MATCHES ,sizeof (buf)); proc =proc_net_fops_create (buf,0440 , &xt_file_ops);if (!proc) goto out_remove_tables; proc->data = (void *) ((unsigned long ) af | (MATCH <<16 )); -strlcpy (buf, xt_proto_prefix[af],sizeof (buf)); +strlcpy (buf, xt_prefix[af],sizeof (buf));strlcat (buf,FORMAT_TARGETS ,sizeof (buf)); proc =proc_net_fops_create (buf,0440 , &xt_file_ops);if (!proc)
@@ -825,12 +819,12 @@ #endif#ifdef CONFIG_PROC_FS out_remove_matches: -strlcpy (buf, xt_proto_prefix[af],sizeof (buf)); +strlcpy (buf, xt_prefix[af],sizeof (buf));strlcat (buf,FORMAT_MATCHES ,sizeof (buf));proc_net_remove (buf); out_remove_tables: -strlcpy (buf, xt_proto_prefix[af],sizeof (buf)); +strlcpy (buf, xt_prefix[af],sizeof (buf));strlcat (buf,FORMAT_TABLES ,sizeof (buf));proc_net_remove (buf); out:
@@ -844,15 +838,15 @@ void xt_proto_fini(int af)#ifdef CONFIG_PROC_FS char buf[XT_FUNCTION_MAXNAMELEN ]; -strlcpy (buf, xt_proto_prefix[af],sizeof (buf)); +strlcpy (buf, xt_prefix[af],sizeof (buf));strlcat (buf,FORMAT_TABLES ,sizeof (buf));proc_net_remove (buf); -strlcpy (buf, xt_proto_prefix[af],sizeof (buf)); +strlcpy (buf, xt_prefix[af],sizeof (buf));strlcat (buf,FORMAT_TARGETS ,sizeof (buf));proc_net_remove (buf); -strlcpy (buf, xt_proto_prefix[af],sizeof (buf)); +strlcpy (buf, xt_prefix[af],sizeof (buf));strlcat (buf,FORMAT_MATCHES ,sizeof (buf));proc_net_remove (buf);#endif /*CONFIG_PROC_FS*/
PATCH 3/22 : nf_conntrack: switch protocol registration/unregistration to mutex
In reply to Patrick McHardy[NETFILTER]: nf_conntrack: switch protocol registration/unregistration to mutex
The protocol lookups done by nf_conntrack are already protected by RCU, there is no need to keep taking nf_conntrack_lock for registration and unregistration. Switch to a mutex.
---
commit 69b5f8d51819903743c648e829d247f0d156b889
tree 561177b4d270b5e1f30ed316c8b1535a68e10be1
parent 659738c122a278d4c15cb1b2dbd641b7acf80460
author Patrick McHardy <[email protected]> Thu, 08 Mar 2007 18:23:57 +0100 committer Patrick McHardy <[email protected]> Wed, 14 Mar 2007 09:26:28 +0100
net/netfilter/nf_conntrack_proto.c | 52 ++++++++++++++++-------------------- 1 files changed, 23 insertions(+), 29 deletions(-)
net/netfilter/nf_conntrack_proto.c +23 -29
@@ -32,9 +32,9 @@ struct nf_conntrack_l4proto **nf_ct_protstruct nf_conntrack_l3proto *nf_ct_l3protos[AF_MAX ]__read_mostly ;EXPORT_SYMBOL_GPL (nf_ct_l3protos); -#ifdef CONFIG_SYSCTL -static DEFINE_MUTEX (nf_ct_proto_sysctl_mutex); +static DEFINE_MUTEX (nf_ct_proto_mutex); +#ifdef CONFIG_SYSCTL static int nf_ct_register_sysctl (struct ctl_table_header **header,struct ctl_table *path,struct ctl_table *table,unsigned int *users)
@@ -164,13 +164,13 @@ static int nf_ct_l3proto_register_sysctlint err =0 ;#ifdef CONFIG_SYSCTL -mutex_lock (&nf_ct_proto_sysctl_mutex); +mutex_lock (&nf_ct_proto_mutex);if (l3proto->ctl_table !=NULL ) { err =nf_ct_register_sysctl (&l3proto->ctl_table_header, l3proto->ctl_table_path, l3proto->ctl_table,NULL ); } -mutex_unlock (&nf_ct_proto_sysctl_mutex); +mutex_unlock (&nf_ct_proto_mutex);#endif return err; }
@@ -178,11 +178,11 @@ #endifstatic void nf_ct_l3proto_unregister_sysctl (struct nf_conntrack_l3proto *l3proto) {#ifdef CONFIG_SYSCTL -mutex_lock (&nf_ct_proto_sysctl_mutex); +mutex_lock (&nf_ct_proto_mutex);if (l3proto->ctl_table_header !=NULL )nf_ct_unregister_sysctl (&l3proto->ctl_table_header, l3proto->ctl_table,NULL ); -mutex_unlock (&nf_ct_proto_sysctl_mutex); +mutex_unlock (&nf_ct_proto_mutex);#endif }
@@ -195,13 +195,13 @@ int nf_conntrack_l3proto_register(struct goto out; } -write_lock_bh (&nf_conntrack_lock); +mutex_lock (&nf_ct_proto_mutex);if (nf_ct_l3protos[proto->l3proto] != &nf_conntrack_l3proto_generic) { ret = -EBUSY ; goto out_unlock; }rcu_assign_pointer (nf_ct_l3protos[proto->l3proto], proto); -write_unlock_bh (&nf_conntrack_lock); +mutex_unlock (&nf_ct_proto_mutex); ret =nf_ct_l3proto_register_sysctl (proto);if (ret <0 )
@@ -209,7 +209,7 @@ int nf_conntrack_l3proto_register(structreturn ret; out_unlock: -write_unlock_bh (&nf_conntrack_lock); +mutex_unlock (&nf_ct_proto_mutex); out:return ret; }
@@ -219,11 +219,11 @@ void nf_conntrack_l3proto_unregister(str {BUG_ON (proto->l3proto >=AF_MAX ); -write_lock_bh (&nf_conntrack_lock); +mutex_lock (&nf_ct_proto_mutex);BUG_ON (nf_ct_l3protos[proto->l3proto] != proto);rcu_assign_pointer (nf_ct_l3protos[proto->l3proto], &nf_conntrack_l3proto_generic); -write_unlock_bh (&nf_conntrack_lock); +mutex_unlock (&nf_ct_proto_mutex);synchronize_rcu ();nf_ct_l3proto_unregister_sysctl (proto);
@@ -238,7 +238,7 @@ static int nf_ct_l4proto_register_sysctlint err =0 ;#ifdef CONFIG_SYSCTL -mutex_lock (&nf_ct_proto_sysctl_mutex); +mutex_lock (&nf_ct_proto_mutex);if (l4proto->ctl_table !=NULL ) { err = nf_ct_register_sysctl(l4proto->ctl_table_header, nf_net_netfilter_sysctl_path,
@@ -260,7 +260,7 @@ #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT }#endif /* CONFIG_NF_CONNTRACK_PROC_COMPAT */ out: -mutex_unlock (&nf_ct_proto_sysctl_mutex); +mutex_unlock (&nf_ct_proto_mutex);#endif /* CONFIG_SYSCTL */ return err; }
@@ -268,7 +268,7 @@ #endif /* CONFIG_SYSCTL */static void nf_ct_l4proto_unregister_sysctl (struct nf_conntrack_l4proto *l4proto) {#ifdef CONFIG_SYSCTL -mutex_lock (&nf_ct_proto_sysctl_mutex); +mutex_lock (&nf_ct_proto_mutex);if (l4proto->ctl_table_header !=NULL && *l4proto->ctl_table_header !=NULL ) nf_ct_unregister_sysctl(l4proto->ctl_table_header,
@@ -279,7 +279,7 @@ #ifdef CONFIG_NF_CONNTRACK_PROC_COMPATnf_ct_unregister_sysctl (&l4proto->ctl_compat_table_header, l4proto->ctl_compat_table,NULL );#endif /* CONFIG_NF_CONNTRACK_PROC_COMPAT */ -mutex_unlock (&nf_ct_proto_sysctl_mutex); +mutex_unlock (&nf_ct_proto_mutex);#endif /* CONFIG_SYSCTL */ }
@@ -297,8 +297,8 @@ int nf_conntrack_l4proto_register(structif (l4proto == &nf_conntrack_l4proto_generic)return nf_ct_l4proto_register_sysctl (l4proto); +mutex_lock (&nf_ct_proto_mutex); retry: -write_lock_bh (&nf_conntrack_lock);if (nf_ct_protos[l4proto->l3proto]) {if (nf_ct_protos[l4proto->l3proto][l4proto->l4proto] != &nf_conntrack_l4proto_generic) {
@@ -310,28 +310,22 @@ retry:struct nf_conntrack_l4proto **proto_array;int i; -write_unlock_bh (&nf_conntrack_lock); - proto_array = (struct nf_conntrack_l4proto **)kmalloc (MAX_NF_CT_PROTO *sizeof (struct nf_conntrack_l4proto *),GFP_KERNEL );if (proto_array ==NULL ) { ret = -ENOMEM ; - goto out; + goto out_unlock; }for (i =0 ; i <MAX_NF_CT_PROTO ; i++) proto_array[i] = &nf_conntrack_l4proto_generic; -write_lock_bh (&nf_conntrack_lock); -if (nf_ct_protos[l4proto->l3proto]) { +if (nf_ct_protos[l4proto->l3proto])/* bad timing, but no problem */ -write_unlock_bh (&nf_conntrack_lock);kfree (proto_array); - }else { +else nf_ct_protos[l4proto->l3proto] = proto_array; -write_unlock_bh (&nf_conntrack_lock); - }/* * Just once because array is never freed until unloading
@@ -341,7 +335,7 @@ retry: }rcu_assign_pointer (nf_ct_protos[l4proto->l3proto][l4proto->l4proto], l4proto); -write_unlock_bh (&nf_conntrack_lock); +mutex_unlock (&nf_ct_proto_mutex); ret =nf_ct_l4proto_register_sysctl (l4proto);if (ret <0 )
@@ -349,7 +343,7 @@ retry:return ret; out_unlock: -write_unlock_bh (&nf_conntrack_lock); +mutex_unlock (&nf_ct_proto_mutex); out:return ret; }
@@ -364,11 +358,11 @@ void nf_conntrack_l4proto_unregister(strreturn ; } -write_lock_bh (&nf_conntrack_lock); +mutex_lock (&nf_ct_proto_mutex);BUG_ON (nf_ct_protos[l4proto->l3proto][l4proto->l4proto] != l4proto);rcu_assign_pointer (nf_ct_protos[l4proto->l3proto][l4proto->l4proto], &nf_conntrack_l4proto_generic); -write_unlock_bh (&nf_conntrack_lock); +mutex_unlock (&nf_ct_proto_mutex);synchronize_rcu ();nf_ct_l4proto_unregister_sysctl (l4proto);
PATCH 4/22 : nf_conntrack: remove ugly hack in l4proto registration
In reply to Patrick McHardy[NETFILTER]: nf_conntrack: remove ugly hack in l4proto registration
Remove ugly special-casing of nf_conntrack_l4proto_generic, all it wants is its sysctl tables registered, so do that explicitly in an init function and move the remaining protocol initialization and cleanup code to nf_conntrack_proto.c as well.
---
commit 54043273620aa19f6b4334a56e04d90385b96d85
tree b1d212025330251bf39a38414de7488a2bf9bf30
parent 69b5f8d51819903743c648e829d247f0d156b889
author Patrick McHardy <[email protected]> Thu, 08 Mar 2007 18:24:09 +0100 committer Patrick McHardy <[email protected]> Wed, 14 Mar 2007 09:27:11 +0100
include/net/netfilter/nf_conntrack_core.h | 3 +++ net/netfilter/nf_conntrack_core.c | 18 ++------------- net/netfilter/nf_conntrack_proto.c | 34 ++++++++++++++++++++++------- 3 files changed, 31 insertions(+), 24 deletions(-)
include/net/netfilter/nf_conntrack_core.h +3 -0
@@ -27,6 +27,9 @@ extern unsigned int nf_conntrack_in(intextern int nf_conntrack_init (void );extern void nf_conntrack_cleanup (void ); +extern int nf_conntrack_proto_init (void ); +extern void nf_conntrack_proto_fini (void ); +struct nf_conntrack_l3proto ;extern struct nf_conntrack_l3proto *nf_ct_find_l3proto (u_int16_t pf);/* Like above, but you already have conntrack read lock. */
net/netfilter/nf_conntrack_core.c +2 -16
@@ -1152,14 +1152,7 @@ void nf_conntrack_cleanup(void)free_conntrack_hash (nf_conntrack_hash, nf_conntrack_vmalloc, nf_conntrack_htable_size); -nf_conntrack_l4proto_unregister (&nf_conntrack_l4proto_generic); - -/* free l3proto protocol tables */ -for (i =0 ; i <PF_MAX ; i++) -if (nf_ct_protos[i]) { -kfree (nf_ct_protos[i]); - nf_ct_protos[i] =NULL ; - } +nf_conntrack_proto_fini (); }static struct list_head *alloc_hashtable (int size,int *vmalloced)
@@ -1237,7 +1230,6 @@ module_param_call(hashsize, set_hashsizeint __init nf_conntrack_init (void ) { -unsigned int i;int ret;/* Idea from tcp.c: use 1/16384 of memory. On i386: 32MB
@@ -1279,16 +1271,10 @@ int __init nf_conntrack_init(void) goto err_free_conntrack_slab; } - ret =nf_conntrack_l4proto_register (&nf_conntrack_l4proto_generic); + ret =nf_conntrack_proto_init ();if (ret <0 ) goto out_free_expect_slab; -/* Don't NEED lock here, but good form anyway. */ -write_lock_bh (&nf_conntrack_lock); -for (i =0 ; i <AF_MAX ; i++) - nf_ct_l3protos[i] = &nf_conntrack_l3proto_generic; -write_unlock_bh (&nf_conntrack_lock); -/* For use by REJECT target */ rcu_assign_pointer (ip_ct_attach, __nf_conntrack_attach);
net/netfilter/nf_conntrack_proto.c +26 -8
@@ -294,9 +294,6 @@ int nf_conntrack_l4proto_register(struct goto out; } -if (l4proto == &nf_conntrack_l4proto_generic) -return nf_ct_l4proto_register_sysctl (l4proto); -mutex_lock (&nf_ct_proto_mutex); retry:if (nf_ct_protos[l4proto->l3proto]) {
@@ -353,11 +350,6 @@ void nf_conntrack_l4proto_unregister(str {BUG_ON (l4proto->l3proto >=PF_MAX ); -if (l4proto == &nf_conntrack_l4proto_generic) { -nf_ct_l4proto_unregister_sysctl (l4proto); -return ; - } -mutex_lock (&nf_ct_proto_mutex);BUG_ON (nf_ct_protos[l4proto->l3proto][l4proto->l4proto] != l4proto); rcu_assign_pointer(nf_ct_protos[l4proto->l3proto][l4proto->l4proto],
@@ -371,3 +363,29 @@ void nf_conntrack_l4proto_unregister(strnf_ct_iterate_cleanup (kill_l4proto, l4proto); }EXPORT_SYMBOL_GPL (nf_conntrack_l4proto_unregister); + +int nf_conntrack_proto_init (void ) +{ +unsigned int i; +int err; + + err =nf_ct_l4proto_register_sysctl (&nf_conntrack_l4proto_generic); +if (err <0 ) +return err; + +for (i =0 ; i <AF_MAX ; i++) +rcu_assign_pointer (nf_ct_l3protos[i], + &nf_conntrack_l3proto_generic); +return 0 ; +} + +void nf_conntrack_proto_fini (void ) +{ +unsigned int i; + +nf_ct_l4proto_unregister_sysctl (&nf_conntrack_l4proto_generic); + +/* free l3proto protocol tables */ +for (i =0 ; i <PF_MAX ; i++) +kfree (nf_ct_protos[i]); +}
PATCH 5/22 : nf_conntrack: simplify protocol locking
In reply to Patrick McHardy[NETFILTER]: nf_conntrack: simplify protocol locking
Now that we don't use nf_conntrack_lock anymore but a single mutex for all protocol handling, no need to release and grab it again for sysctl registration.
---
commit ea67c267464258ebf4752a9f23a30b965b6985a0
tree ba2a559594f6035e5b827a9a2d6651559dfbde08
parent 54043273620aa19f6b4334a56e04d90385b96d85
author Patrick McHardy <[email protected]> Thu, 08 Mar 2007 18:24:21 +0100 committer Patrick McHardy <[email protected]> Wed, 14 Mar 2007 09:28:46 +0100
net/netfilter/nf_conntrack_proto.c | 45 +++++++++++------------------------- 1 files changed, 14 insertions(+), 31 deletions(-)
net/netfilter/nf_conntrack_proto.c +14 -31
@@ -164,13 +164,11 @@ static int nf_ct_l3proto_register_sysctlint err =0 ;#ifdef CONFIG_SYSCTL -mutex_lock (&nf_ct_proto_mutex);if (l3proto->ctl_table !=NULL ) { err =nf_ct_register_sysctl (&l3proto->ctl_table_header, l3proto->ctl_table_path, l3proto->ctl_table,NULL ); } -mutex_unlock (&nf_ct_proto_mutex);#endif return err; }
@@ -178,11 +176,9 @@ #endifstatic void nf_ct_l3proto_unregister_sysctl (struct nf_conntrack_l3proto *l3proto) {#ifdef CONFIG_SYSCTL -mutex_lock (&nf_ct_proto_mutex);if (l3proto->ctl_table_header !=NULL )nf_ct_unregister_sysctl (&l3proto->ctl_table_header, l3proto->ctl_table,NULL ); -mutex_unlock (&nf_ct_proto_mutex);#endif }
@@ -190,27 +186,23 @@ int nf_conntrack_l3proto_register(struct {int ret =0 ; -if (proto->l3proto >=AF_MAX ) { - ret = -EBUSY ; - goto out; - } +if (proto->l3proto >=AF_MAX ) +return -EBUSY ;mutex_lock (&nf_ct_proto_mutex);if (nf_ct_l3protos[proto->l3proto] != &nf_conntrack_l3proto_generic) { ret = -EBUSY ; goto out_unlock; } -rcu_assign_pointer (nf_ct_l3protos[proto->l3proto], proto); -mutex_unlock (&nf_ct_proto_mutex); ret =nf_ct_l3proto_register_sysctl (proto);if (ret <0 ) -nf_conntrack_l3proto_unregister (proto); -return ret; + goto out_unlock; + +rcu_assign_pointer (nf_ct_l3protos[proto->l3proto], proto); out_unlock:mutex_unlock (&nf_ct_proto_mutex); -out:return ret; }EXPORT_SYMBOL_GPL (nf_conntrack_l3proto_register);
@@ -223,10 +215,10 @@ void nf_conntrack_l3proto_unregister(strBUG_ON (nf_ct_l3protos[proto->l3proto] != proto);rcu_assign_pointer (nf_ct_l3protos[proto->l3proto], &nf_conntrack_l3proto_generic); +nf_ct_l3proto_unregister_sysctl (proto);mutex_unlock (&nf_ct_proto_mutex); -synchronize_rcu (); -nf_ct_l3proto_unregister_sysctl (proto); +synchronize_rcu ();/* Remove all contrack entries for this protocol */ nf_ct_iterate_cleanup (kill_l3proto, proto);
@@ -238,7 +230,6 @@ static int nf_ct_l4proto_register_sysctlint err =0 ;#ifdef CONFIG_SYSCTL -mutex_lock (&nf_ct_proto_mutex);if (l4proto->ctl_table !=NULL ) { err = nf_ct_register_sysctl(l4proto->ctl_table_header, nf_net_netfilter_sysctl_path,
@@ -260,7 +251,6 @@ #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT }#endif /* CONFIG_NF_CONNTRACK_PROC_COMPAT */ out: -mutex_unlock (&nf_ct_proto_mutex);#endif /* CONFIG_SYSCTL */ return err; }
@@ -268,7 +258,6 @@ #endif /* CONFIG_SYSCTL */static void nf_ct_l4proto_unregister_sysctl (struct nf_conntrack_l4proto *l4proto) {#ifdef CONFIG_SYSCTL -mutex_lock (&nf_ct_proto_mutex);if (l4proto->ctl_table_header !=NULL && *l4proto->ctl_table_header !=NULL ) nf_ct_unregister_sysctl(l4proto->ctl_table_header,
@@ -279,7 +268,6 @@ #ifdef CONFIG_NF_CONNTRACK_PROC_COMPATnf_ct_unregister_sysctl (&l4proto->ctl_compat_table_header, l4proto->ctl_compat_table,NULL );#endif /* CONFIG_NF_CONNTRACK_PROC_COMPAT */ -mutex_unlock (&nf_ct_proto_mutex);#endif /* CONFIG_SYSCTL */ }
@@ -289,10 +277,8 @@ int nf_conntrack_l4proto_register(struct {int ret =0 ; -if (l4proto->l3proto >=PF_MAX ) { - ret = -EBUSY ; - goto out; - } +if (l4proto->l3proto >=PF_MAX ) +return -EBUSY ;mutex_lock (&nf_ct_proto_mutex); retry:
@@ -331,17 +317,14 @@ retry: goto retry; } -rcu_assign_pointer (nf_ct_protos[l4proto->l3proto][l4proto->l4proto], l4proto); -mutex_unlock (&nf_ct_proto_mutex); - ret =nf_ct_l4proto_register_sysctl (l4proto);if (ret <0 ) -nf_conntrack_l4proto_unregister (l4proto); -return ret; + goto out_unlock; + +rcu_assign_pointer (nf_ct_protos[l4proto->l3proto][l4proto->l4proto], l4proto); out_unlock:mutex_unlock (&nf_ct_proto_mutex); -out:return ret; }EXPORT_SYMBOL_GPL (nf_conntrack_l4proto_register);
@@ -354,10 +337,10 @@ void nf_conntrack_l4proto_unregister(strBUG_ON (nf_ct_protos[l4proto->l3proto][l4proto->l4proto] != l4proto);rcu_assign_pointer (nf_ct_protos[l4proto->l3proto][l4proto->l4proto], &nf_conntrack_l4proto_generic); +nf_ct_l4proto_unregister_sysctl (l4proto);mutex_unlock (&nf_ct_proto_mutex); -synchronize_rcu (); -nf_ct_l4proto_unregister_sysctl (l4proto); +synchronize_rcu ();/* Remove all contrack entries for this protocol */ nf_ct_iterate_cleanup (kill_l4proto, l4proto);
PATCH 6/22 : nf_conntrack: simplify l4 protocol array allocation
In reply to Patrick McHardy[NETFILTER]: nf_conntrack: simplify l4 protocol array allocation
The retrying after an allocation failure is not necessary anymore since we're holding the mutex the entire time, for the same reason the double allocation race can't happen anymore.
---
commit e4cfced6765b323aaf85882448deef3008a2e204
tree 39afbf17c060a2de7cd21bfbbc807a14a2d66dad
parent ea67c267464258ebf4752a9f23a30b965b6985a0
author Patrick McHardy <[email protected]> Thu, 08 Mar 2007 18:24:32 +0100 committer Patrick McHardy <[email protected]> Wed, 14 Mar 2007 09:29:11 +0100
net/netfilter/nf_conntrack_proto.c | 37 ++++++++++++------------------------ 1 files changed, 12 insertions(+), 25 deletions(-)
net/netfilter/nf_conntrack_proto.c +12 -25
@@ -281,47 +281,34 @@ int nf_conntrack_l4proto_register(structreturn -EBUSY ;mutex_lock (&nf_ct_proto_mutex); -retry: -if (nf_ct_protos[l4proto->l3proto]) { -if (nf_ct_protos[l4proto->l3proto][l4proto->l4proto] - != &nf_conntrack_l4proto_generic) { - ret = -EBUSY ; - goto out_unlock; - } - }else { +if (!nf_ct_protos[l4proto->l3proto]) {/* l3proto may be loaded latter. */ struct nf_conntrack_l4proto **proto_array;int i; - proto_array = (struct nf_conntrack_l4proto **) -kmalloc (MAX_NF_CT_PROTO * -sizeof (struct nf_conntrack_l4proto *), -GFP_KERNEL ); + proto_array =kmalloc (MAX_NF_CT_PROTO * +sizeof (struct nf_conntrack_l4proto *), +GFP_KERNEL );if (proto_array ==NULL ) { ret = -ENOMEM ; goto out_unlock; } +for (i =0 ; i <MAX_NF_CT_PROTO ; i++) proto_array[i] = &nf_conntrack_l4proto_generic; - -if (nf_ct_protos[l4proto->l3proto]) -/* bad timing, but no problem */ -kfree (proto_array); -else - nf_ct_protos[l4proto->l3proto] = proto_array; - -/* -* Just once because array is never freed until unloading -* nf_conntrack.ko -*/ - goto retry; + nf_ct_protos[l4proto->l3proto] = proto_array; + }else if (nf_ct_protos[l4proto->l3proto][l4proto->l4proto] != + &nf_conntrack_l4proto_generic) { + ret = -EBUSY ; + goto out_unlock; } ret =nf_ct_l4proto_register_sysctl (l4proto);if (ret <0 ) goto out_unlock; -rcu_assign_pointer (nf_ct_protos[l4proto->l3proto][l4proto->l4proto], l4proto); +rcu_assign_pointer (nf_ct_protos[l4proto->l3proto][l4proto->l4proto], + l4proto); out_unlock:mutex_unlock (&nf_ct_proto_mutex);
PATCH 7/22 : nfnetlink: use mutex instead of semaphore
In reply to Patrick McHardy[NETFILTER]: nfnetlink: use mutex instead of semaphore
---
commit d61dcfb467bf886f404643585b36317fc2be7254
tree 366fde24982c43ff86f8f6fb3c78bcebf55931ef
parent e4cfced6765b323aaf85882448deef3008a2e204
author Patrick McHardy <[email protected]> Thu, 08 Mar 2007 18:24:47 +0100 committer Patrick McHardy <[email protected]> Wed, 14 Mar 2007 09:29:39 +0100
include/linux/netfilter/nfnetlink.h | 13 ---------- include/net/netfilter/nf_conntrack_l3proto.h | 5 +--- net/netfilter/nfnetlink.c | 35 ++++++++++++++++++-------- 3 files changed, 25 insertions(+), 28 deletions(-)
include/linux/netfilter/nfnetlink.h +0 -13
@@ -129,19 +129,6 @@ #define NFA_PUT(skb, attrtype, attrlen, ({if (skb_tailroom (skb) < (int )NFA_SPACE (attrlen)) goto nfattr_failure; \ __nfa_fill(skb, attrtype, attrlen, data); }) -extern struct semaphore nfnl_sem; - -#define nfnl_shlock () down(&nfnl_sem) -#define nfnl_shlock_nowait () down_trylock(&nfnl_sem) - -#define nfnl_shunlock () do { up(&nfnl_sem); \ - if(nfnl && nfnl->sk_receive_queue.qlen) \ - nfnl->sk_data_ready(nfnl, 0); \ - } while(0) - -extern void nfnl_lock (void ); -extern void nfnl_unlock (void ); -extern int nfnetlink_subsys_register (struct nfnetlink_subsystem *n);extern int nfnetlink_subsys_unregister (struct nfnetlink_subsystem *n);
include/net/netfilter/nf_conntrack_l3proto.h +1 -4
@@ -90,10 +90,7 @@ extern struct nf_conntrack_l3proto *nf_c/* Protocol registration. */ extern int nf_conntrack_l3proto_register (struct nf_conntrack_l3proto *proto);extern void nf_conntrack_l3proto_unregister (struct nf_conntrack_l3proto *proto); - -extern struct nf_conntrack_l3proto * -nf_ct_l3proto_find_get (u_int16_t l3proto); - +extern struct nf_conntrack_l3proto *nf_ct_l3proto_find_get (u_int16_t l3proto);extern void nf_ct_l3proto_put (struct nf_conntrack_l3proto *p);/* Existing built-in protocols */
net/netfilter/nfnetlink.c +24 -11
@@ -28,6 +28,7 @@ #include <linux/skbuff.h>#include <asm/uaccess.h> #include <asm/system.h> #include <net/sock.h> +#include <net/netlink.h> #include <linux/init.h> #include <linux/spinlock.h>
@@ -51,16 +52,28 @@ #endifstatic struct sock *nfnl =NULL ;static struct nfnetlink_subsystem *subsys_table[NFNL_SUBSYS_COUNT ]; -DECLARE_MUTEX (nfnl_sem); +static DEFINE_MUTEX (nfnl_mutex); -void nfnl_lock (void ) +static void nfnl_lock (void ) { -nfnl_shlock (); +mutex_lock (&nfnl_mutex); } -void nfnl_unlock (void ) +static int nfnl_trylock (void ) { -nfnl_shunlock (); +return !mutex_trylock (&nfnl_mutex); +} + +static void __nfnl_unlock (void ) +{ +mutex_unlock (&nfnl_mutex); +} + +static void nfnl_unlock (void ) +{ +mutex_unlock (&nfnl_mutex); +if (nfnl->sk_receive_queue.qlen) + nfnl->sk_data_ready (nfnl,0 ); }int nfnetlink_subsys_register (struct nfnetlink_subsystem *n)
@@ -248,11 +261,11 @@ static int nfnetlink_rcv_msg(struct sk_b ss =nfnetlink_get_subsys (type);if (!ss) {#ifdef CONFIG_KMOD -/* don't call nfnl_shunlock, since it would reenter +/* don't call nfnl_unlock, since it would reenter * with further packet processing */ -up (&nfnl_sem); +__nfnl_unlock ();request_module ("nfnetlink-subsys-%d" ,NFNL_SUBSYS_ID (type)); -nfnl_shlock (); +nfnl_lock (); ss =nfnetlink_get_subsys (type); if (!ss)#endif
@@ -322,7 +335,7 @@ static void nfnetlink_rcv(struct sock *s do { struct sk_buff *skb; - if (nfnl_shlock_nowait()) + if (nfnl_trylock()) return; while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) {
@@ -337,9 +350,9 @@ static void nfnetlink_rcv(struct sock *skfree_skb (skb); } -/* don't call nfnl_shunlock, since it would reenter +/* don't call nfnl_unlock, since it would reenter * with further packet processing */ -up (&nfnl_sem); +__nfnl_unlock (); }while (nfnl && nfnl->sk_receive_queue.qlen); }
PATCH 8/22 : nfnetlink: use netlink_run_queue()
In reply to Patrick McHardy[NETFILTER]: nfnetlink: use netlink_run_queue()
---
commit 9a256881f5e3027a9833ad87b1fe36c0be0c20fb
tree 756d0b3c3f1905fc3f441c650551e334e670f4ff
parent d61dcfb467bf886f404643585b36317fc2be7254
author Patrick McHardy <[email protected]> Thu, 08 Mar 2007 18:24:55 +0100 committer Patrick McHardy <[email protected]> Wed, 14 Mar 2007 09:30:30 +0100
net/netfilter/nfnetlink.c | 51 ++++----------------------------------------- 1 files changed, 4 insertions(+), 47 deletions(-)
net/netfilter/nfnetlink.c +4 -47
@@ -301,59 +301,16 @@ err_inval:return -1 ; } -/* Process one packet of messages. */ -static inline int nfnetlink_rcv_skb (struct sk_buff *skb) -{ -int err; -struct nlmsghdr *nlh; - -while (skb->len >=NLMSG_SPACE (0 )) { -u32 rlen; - - nlh = (struct nlmsghdr *)skb->data; -if (nlh->nlmsg_len <sizeof (struct nlmsghdr ) - || skb->len < nlh->nlmsg_len) -return 0 ; - rlen =NLMSG_ALIGN (nlh->nlmsg_len); -if (rlen > skb->len) - rlen = skb->len; -if (nfnetlink_rcv_msg (skb, nlh, &err)) { -if (!err) -return -1 ; -netlink_ack (skb, nlh, err); - }else -if (nlh->nlmsg_flags &NLM_F_ACK ) -netlink_ack (skb, nlh,0 ); -skb_pull (skb, rlen); - } - -return 0 ; -} -static void nfnetlink_rcv (struct sock *sk,int len) { -do { -struct sk_buff *skb; +unsigned int qlen =0 ; +do {if (nfnl_trylock ())return ; - -while ((skb =skb_dequeue (&sk->sk_receive_queue)) !=NULL ) { -if (nfnetlink_rcv_skb (skb)) { -if (skb->len) -skb_queue_head (&sk->sk_receive_queue, - skb); -else -kfree_skb (skb); -break ; - } -kfree_skb (skb); - } - -/* don't call nfnl_unlock, since it would reenter -* with further packet processing */ +netlink_run_queue (sk, &qlen, nfnetlink_rcv_msg);__nfnl_unlock (); - }while (nfnl && nfnl->sk_receive_queue.qlen); + }while (qlen); } static void __exit nfnetlink_exit(void)
PATCH 9/22 : nf_conntrack: uninline notifier registration functions
In reply to Patrick McHardy[NETFILTER]: nf_conntrack: uninline notifier registration functions
---
commit f8184abb940940e7503c5b089e89d2d88b4eb34c
tree 5a953b2f7dc58cb1b2b4ff96b5e0094a1d33e9dd
parent 9a256881f5e3027a9833ad87b1fe36c0be0c20fb
author Patrick McHardy <[email protected]> Thu, 08 Mar 2007 18:25:12 +0100 committer Patrick McHardy <[email protected]> Wed, 14 Mar 2007 09:30:39 +0100
include/net/netfilter/nf_conntrack_ecache.h | 30 +++++---------------------- net/netfilter/nf_conntrack_ecache.c | 23 +++++++++++++++++++++ 2 files changed, 29 insertions(+), 24 deletions(-)
include/net/netfilter/nf_conntrack_ecache.h +6 -24
@@ -20,30 +20,8 @@ DECLARE_PER_CPU(struct nf_conntrack_ecac#define CONNTRACK_ECACHE (x) (__get_cpu_var(nf_conntrack_ecache).x)extern struct atomic_notifier_head nf_conntrack_chain; -extern struct atomic_notifier_head nf_conntrack_expect_chain; - -static inline int nf_conntrack_register_notifier (struct notifier_block *nb) -{ -return atomic_notifier_chain_register (&nf_conntrack_chain, nb); -} - -static inline int nf_conntrack_unregister_notifier (struct notifier_block *nb) -{ -return atomic_notifier_chain_unregister (&nf_conntrack_chain, nb); -} - -static inline int -nf_conntrack_expect_register_notifier (struct notifier_block *nb) -{ -return atomic_notifier_chain_register (&nf_conntrack_expect_chain, nb); -} - -static inline int -nf_conntrack_expect_unregister_notifier (struct notifier_block *nb) -{ -return atomic_notifier_chain_unregister (&nf_conntrack_expect_chain, - nb); -} +extern int nf_conntrack_register_notifier (struct notifier_block *nb); +extern int nf_conntrack_unregister_notifier (struct notifier_block *nb);extern void nf_ct_deliver_cached_events (const struct nf_conn *ct);extern void __nf_ct_event_cache_init (struct nf_conn *ct);
@@ -71,6 +49,10 @@ static inline void nf_conntrack_event(enatomic_notifier_call_chain (&nf_conntrack_chain, event, ct); } +extern struct atomic_notifier_head nf_conntrack_expect_chain; +extern int nf_conntrack_expect_register_notifier (struct notifier_block *nb); +extern int nf_conntrack_expect_unregister_notifier (struct notifier_block *nb); +static inline void nf_conntrack_expect_event (enum ip_conntrack_expect_events event,struct nf_conntrack_expect *exp)
net/netfilter/nf_conntrack_ecache.c +23 -0
@@ -91,3 +91,26 @@ void nf_ct_event_cache_flush(void) } } +int nf_conntrack_register_notifier (struct notifier_block *nb) +{ +return atomic_notifier_chain_register (&nf_conntrack_chain, nb); +} +EXPORT_SYMBOL_GPL (nf_conntrack_register_notifier); + +int nf_conntrack_unregister_notifier (struct notifier_block *nb) +{ +return atomic_notifier_chain_unregister (&nf_conntrack_chain, nb); +} +EXPORT_SYMBOL_GPL (nf_conntrack_unregister_notifier); + +int nf_conntrack_expect_register_notifier (struct notifier_block *nb) +{ +return atomic_notifier_chain_register (&nf_conntrack_expect_chain, nb); +} +EXPORT_SYMBOL_GPL (nf_conntrack_expect_register_notifier); + +int nf_conntrack_expect_unregister_notifier (struct notifier_block *nb) +{ +return atomic_notifier_chain_unregister (&nf_conntrack_expect_chain, nb); +} +EXPORT_SYMBOL_GPL (nf_conntrack_expect_unregister_notifier);
PATCH 10/22 : nfnetlink: remove early debugging messages from nfnetlink
In reply to Patrick McHardy[NETFILTER]: nfnetlink: remove early debugging messages from nfnetlink
---
commit 750623a576cf1a6cd62d138be4da5b95a8419c35
tree 1ae7982c1e123a23f56e890c0d8110cfd23bf13a
parent f8184abb940940e7503c5b089e89d2d88b4eb34c
author Pablo Neira Ayuso <[email protected]> Thu, 08 Mar 2007 18:25:20 +0100 committer Patrick McHardy <[email protected]> Wed, 14 Mar 2007 09:30:46 +0100
net/netfilter/nfnetlink.c | 42 ++++++------------------------------------ 1 files changed, 6 insertions(+), 36 deletions(-)
net/netfilter/nfnetlink.c +6 -36
@@ -3,7 +3,7 @@* * (C) 2001 by Jay Schulist <[email protected]>, * (C) 2002-2005 by Harald Welte <[email protected]> -* (C) 2005 by Pablo Neira Ayuso <[email protected]> +* (C) 2005,2007 by Pablo Neira Ayuso <[email protected]> * * Initial netfilter messages via netlink development funded and * generally made possible by Network Robots, Inc. (www.networkrobots.com)
@@ -42,14 +42,6 @@ MODULE_ALIAS_NET_PF_PROTO(PF_NETLINK, NEstatic char __initdata nfversion[] ="0.30" ; -#if 0 -#define DEBUGP(format, args...) \ - printk(KERN_DEBUG "%s(%d):%s(): " format, __FILE__, \ - __LINE__, __FUNCTION__, ## args) -#else -#define DEBUGP(format, args...) -#endif -static struct sock *nfnl =NULL ;static struct nfnetlink_subsystem *subsys_table[NFNL_SUBSYS_COUNT ];static DEFINE_MUTEX (nfnl_mutex);
@@ -78,8 +70,6 @@ static void nfnl_unlock(void)int nfnetlink_subsys_register (struct nfnetlink_subsystem *n) { -DEBUGP ("registering subsystem ID %u\n" , n->subsys_id); -nfnl_lock ();if (subsys_table[n->subsys_id]) {nfnl_unlock ();
@@ -93,8 +83,6 @@ int nfnetlink_subsys_register(struct nfnint nfnetlink_subsys_unregister (struct nfnetlink_subsystem *n) { -DEBUGP ("unregistering subsystem ID %u\n" , n->subsys_id); -nfnl_lock (); subsys_table[n->subsys_id] =NULL ;nfnl_unlock ();
@@ -118,10 +106,8 @@ nfnetlink_find_client(u_int16_t type, st {u_int8_t cb_id =NFNL_MSG_TYPE (type); -if (cb_id >= ss->cb_count) { -DEBUGP ("msgtype %u >= %u, returning\n" , type, ss->cb_count); +if (cb_id >= ss->cb_count)return NULL ; - }return &ss->cb[cb_id]; }
@@ -167,11 +153,8 @@ nfnetlink_check_attributes(struct nfnetlu_int16_t attr_count;u_int8_t cb_id =NFNL_MSG_TYPE (nlh->nlmsg_type); -if (unlikely (cb_id >= subsys->cb_count)) { -DEBUGP ("msgtype %u >= %u, returning\n" , - cb_id, subsys->cb_count); +if (unlikely (cb_id >= subsys->cb_count))return -EINVAL ; - } min_len =NLMSG_SPACE (sizeof (struct nfgenmsg ));if (unlikely (nlh->nlmsg_len < min_len))
@@ -235,27 +218,18 @@ static int nfnetlink_rcv_msg(struct sk_bstruct nfnetlink_subsystem *ss;int type, err =0 ; -DEBUGP ("entered; subsys=%u, msgtype=%u\n" , -NFNL_SUBSYS_ID (nlh->nlmsg_type), -NFNL_MSG_TYPE (nlh->nlmsg_type)); -if (security_netlink_recv (skb,CAP_NET_ADMIN )) { -DEBUGP ("missing CAP_NET_ADMIN\n" ); *errp = -EPERM ;return -1 ; }/* Only requests are handled by kernel now. */ -if (!(nlh->nlmsg_flags &NLM_F_REQUEST )) { -DEBUGP ("received non-request message\n" ); +if (!(nlh->nlmsg_flags &NLM_F_REQUEST ))return 0 ; - }/* All the messages must at least contain nfgenmsg */ -if (nlh->nlmsg_len <NLMSG_SPACE (sizeof (struct nfgenmsg ))) { -DEBUGP ("received message was too short\n" ); +if (nlh->nlmsg_len <NLMSG_SPACE (sizeof (struct nfgenmsg )))return 0 ; - } type = nlh->nlmsg_type; ss =nfnetlink_get_subsys (type);
@@ -273,10 +247,8 @@ #endif } nc =nfnetlink_find_client (type, ss); -if (!nc) { -DEBUGP ("unable to find client for type %d\n" , type); +if (!nc) goto err_inval; - } { u_int16_t attr_count =
@@ -289,14 +261,12 @@ #endifif (err <0 ) goto err_inval; -DEBUGP ("calling handler\n" ); err = nc->call (nfnl, skb, nlh, cda, errp); *errp = err;return err; } err_inval: -DEBUGP ("returning -EINVAL\n" ); *errp = -EINVAL ;return -1 ; }
PATCH 11/22 : nfnetlink: remove duplicate checks in nfnetlink_check_attributes
In reply to Patrick McHardy[NETFILTER]: nfnetlink: remove duplicate checks in nfnetlink_check_attributes
Remove nfnetlink_check_attributes duplicates message size and callback id checks. nfnetlink_find_client and nfnetlink_rcv_msg already do such checks.
---
commit 6399e6156d65ce163cc77aeb6d53eacf9d9a1fb2
tree a5a5206f0e21e755c7d076be09ba1459412b21a6
parent 750623a576cf1a6cd62d138be4da5b95a8419c35
author Pablo Neira Ayuso <[email protected]> Thu, 08 Mar 2007 18:25:28 +0100 committer Patrick McHardy <[email protected]> Wed, 14 Mar 2007 09:30:57 +0100
net/netfilter/nfnetlink.c | 9 +-------- 1 files changed, 1 insertions(+), 8 deletions(-)
net/netfilter/nfnetlink.c +1 -8
@@ -149,17 +149,10 @@ static int nfnetlink_check_attributes(struct nfnetlink_subsystem *subsys, struct nlmsghdr *nlh, struct nfattr *cda[]) { - int min_len; + int min_len = NLMSG_SPACE(sizeof(struct nfgenmsg));u_int16_t attr_count;u_int8_t cb_id =NFNL_MSG_TYPE (nlh->nlmsg_type); -if (unlikely (cb_id >= subsys->cb_count)) -return -EINVAL ; - - min_len =NLMSG_SPACE (sizeof (struct nfgenmsg )); -if (unlikely (nlh->nlmsg_len < min_len)) -return -EINVAL ; - attr_count = subsys->cb[cb_id].attr_count;memset (cda,0 ,sizeof (struct nfattr *) * attr_count);
PATCH 12/22 : nfnetlink: remove unrequired check in nfnetlink_get_subsys
In reply to Patrick McHardy[NETFILTER]: nfnetlink: remove unrequired check in nfnetlink_get_subsys
subsys_table is initialized to NULL, therefore just returns NULL in case that it is not set.
---
commit bc5959a6bd9a56d1ea0e31344bde2b4f119d8b4c
tree 7c56a7256ee573e38f4a480dd7b8f6412e7e29bc
parent 6399e6156d65ce163cc77aeb6d53eacf9d9a1fb2
author Pablo Neira Ayuso <[email protected]> Thu, 08 Mar 2007 18:25:37 +0100 committer Patrick McHardy <[email protected]> Wed, 14 Mar 2007 09:31:09 +0100
net/netfilter/nfnetlink.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
net/netfilter/nfnetlink.c +1 -2
@@ -94,8 +94,7 @@ static inline struct nfnetlink_subsystem {u_int8_t subsys_id =NFNL_SUBSYS_ID (type); -if (subsys_id >=NFNL_SUBSYS_COUNT - || subsys_table[subsys_id] ==NULL ) +if (subsys_id >=NFNL_SUBSYS_COUNT )return NULL ;return subsys_table[subsys_id];
PATCH 13/22 : nfnetlink: remove unused includes in nfnetlink.c
In reply to Patrick McHardy[NETFILTER]: nfnetlink: remove unused includes in nfnetlink.c
---
commit b826bdd775fb219458b886e3fc41491019af0d67
tree e355d5cc9d828eb93b11211e047b56e849c01229
parent bc5959a6bd9a56d1ea0e31344bde2b4f119d8b4c
author Pablo Neira Ayuso <[email protected]> Thu, 08 Mar 2007 18:25:49 +0100 committer Patrick McHardy <[email protected]> Wed, 14 Mar 2007 09:31:19 +0100
net/netfilter/nfnetlink.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-)
net/netfilter/nfnetlink.c +0 -2
@@ -30,9 +30,7 @@ #include <asm/system.h>#include <net/sock.h> #include <net/netlink.h> #include <linux/init.h> -#include <linux/spinlock.h> -#include <linux/netfilter.h> #include <linux/netlink.h> #include <linux/netfilter/nfnetlink.h>
PATCH 14/22 : nfnetlink: move EXPORT_SYMBOL declarations next to the exported symbol
In reply to Patrick McHardy[NETFILTER]: nfnetlink: move EXPORT_SYMBOL declarations next to the exported symbol
---
commit f7ec69deeb727422f3e7b2aec0e89a411c165d81
tree ea9661307f8d0e661338d3df4765692bf3e3d608
parent b826bdd775fb219458b886e3fc41491019af0d67
author Pablo Neira Ayuso <[email protected]> Thu, 08 Mar 2007 18:25:59 +0100 committer Patrick McHardy <[email protected]> Wed, 14 Mar 2007 09:31:29 +0100
net/netfilter/nfnetlink.c | 13 ++++++------- 1 files changed, 6 insertions(+), 7 deletions(-)
net/netfilter/nfnetlink.c +6 -7
@@ -78,6 +78,7 @@ int nfnetlink_subsys_register(struct nfnreturn 0 ; } +EXPORT_SYMBOL_GPL (nfnetlink_subsys_register);int nfnetlink_subsys_unregister (struct nfnetlink_subsystem *n) {
@@ -87,6 +88,7 @@ int nfnetlink_subsys_unregister(struct nreturn 0 ; } +EXPORT_SYMBOL_GPL (nfnetlink_subsys_unregister);static inline struct nfnetlink_subsystem *nfnetlink_get_subsys (u_int16_t type) {
@@ -121,6 +123,7 @@ void __nfa_fill(struct sk_buff *skb, intmemcpy (NFA_DATA (nfa), data, attrlen);memset (NFA_DATA (nfa) + attrlen,0 ,NFA_ALIGN (size) - size); } +EXPORT_SYMBOL_GPL (__nfa_fill);void nfattr_parse (struct nfattr *tb[],int maxattr,struct nfattr *nfa,int len) {
@@ -133,6 +136,7 @@ void nfattr_parse(struct nfattr *tb[], i nfa =NFA_NEXT (nfa, len); } } +EXPORT_SYMBOL_GPL (nfattr_parse);/** * nfnetlink_check_attributes - check and parse nfnetlink attributes
@@ -194,11 +198,13 @@ int nfnetlink_send(struct sk_buff *skb,return err; } +EXPORT_SYMBOL_GPL (nfnetlink_send);int nfnetlink_unicast (struct sk_buff *skb,u_int32_t pid,int flags) {return netlink_unicast (nfnl, skb, pid, flags); } +EXPORT_SYMBOL_GPL (nfnetlink_unicast);/* Process one complete nfnetlink message. */ static int nfnetlink_rcv_msg(struct sk_buff *skb,
@@ -296,10 +302,3 @@ static int __init nfnetlink_init(void)module_init (nfnetlink_init);module_exit (nfnetlink_exit); - -EXPORT_SYMBOL_GPL (nfnetlink_subsys_register); -EXPORT_SYMBOL_GPL (nfnetlink_subsys_unregister); -EXPORT_SYMBOL_GPL (nfnetlink_send); -EXPORT_SYMBOL_GPL (nfnetlink_unicast); -EXPORT_SYMBOL_GPL (nfattr_parse); -EXPORT_SYMBOL_GPL (__nfa_fill);
PATCH 15/22 : Use const in jhash2
In reply to Patrick McHardy[JHASH]: Use const in jhash2
Use const to avoid forcing users to cast const data.
---
commit 2fdc283757d6f33fda2d4d86a51abce3d155bb22
tree b032ab64f7219db843f68b291ff28993e9dc441b
parent f7ec69deeb727422f3e7b2aec0e89a411c165d81
author Patrick McHardy <[email protected]> Thu, 08 Mar 2007 18:26:09 +0100 committer Patrick McHardy <[email protected]> Wed, 14 Mar 2007 09:31:39 +0100
include/linux/jhash.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
include/linux/jhash.h +1 -1
@@ -84,7 +84,7 @@ static inline u32 jhash(const void *key,/* A special optimized version that handles 1 or more of u32s. * The length parameter here is the number of u32s in the key. */ -static inline u32 jhash2 (u32 *k,u32 length,u32 initval) +static inline u32 jhash2 (const u32 *k,u32 length,u32 initval) {u32 a, b, c, len;
PATCH 16/22 : nf_conntrack: use jhash2 in __hash_conntrack
In reply to Patrick McHardy[NETFILTER]: nf_conntrack: use jhash2 in __hash_conntrack
Now it uses jhash, but using jhash2 would be around 3-4 times faster (on P4).
---
commit a36f33350b8220397ac33ee98c26e808289a302b
tree d505586b3eb93b7cfb9990a892ca9538325fb57d
parent 2fdc283757d6f33fda2d4d86a51abce3d155bb22
author Sami Farin <[email protected]> Thu, 08 Mar 2007 18:26:17 +0100 committer Patrick McHardy <[email protected]> Wed, 14 Mar 2007 09:31:52 +0100
net/netfilter/nf_conntrack_core.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-)
net/netfilter/nf_conntrack_core.c +5 -4
@@ -128,10 +128,11 @@ static u_int32_t __hash_conntrack(const unsigned int size, unsigned int rnd) {unsigned int a, b; - a =jhash ((void *)tuple->src.u3.all,sizeof (tuple->src.u3.all), - ((tuple->src.l3num) <<16 ) | tuple->dst.protonum); - b =jhash ((void *)tuple->dst.u3.all,sizeof (tuple->dst.u3.all), - (tuple->src.u.all <<16 ) | tuple->dst.u.all); + + a =jhash2 (tuple->src.u3.all,ARRAY_SIZE (tuple->src.u3.all), + (tuple->src.l3num <<16 ) | tuple->dst.protonum); + b =jhash2 (tuple->dst.u3.all,ARRAY_SIZE (tuple->dst.u3.all), + (tuple->src.u.all <<16 ) | tuple->dst.u.all);return jhash_2words (a, b, rnd) % size; }
PATCH 17/22 : conntrack: add __nf_copy() to copy members in skb
In reply to Patrick McHardy[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.
---
commit c3f281b640e4bec1e09a5ec338d3e605c23a3e9e
tree 9084a7a022b9222cc4d7230f9b885a8693f08296
parent a36f33350b8220397ac33ee98c26e808289a302b
author Yasuyuki Kozakai <[email protected]> Wed, 14 Mar 2007 09:32:00 +0100 committer Patrick McHardy <[email protected]> Wed, 14 Mar 2007 09:32:00 +0100
include/linux/skbuff.h | 17 +++++++++++++++++ net/core/skbuff.c | 28 ++-------------------------- 2 files changed, 19 insertions(+), 26 deletions(-)
include/linux/skbuff.h +17 -0
@@ -1481,8 +1481,25 @@ #ifdef CONFIG_BRIDGE_NETFILTER #endif } +/* Note: This doesn't put any conntrack and bridge info in dst. */ +static inline void __nf_copy (struct sk_buff *dst,const struct sk_buff *src) +{ + dst->nfct = src->nfct; +nf_conntrack_get (src->nfct); + dst->nfctinfo = src->nfctinfo; +#if defined(CONFIG_NF_CONNTRACK ) || defined(CONFIG_NF_CONNTRACK_MODULE ) + dst->nfct_reasm = src->nfct_reasm; +nf_conntrack_get_reasm (src->nfct_reasm); +#endif +#ifdef CONFIG_BRIDGE_NETFILTER + dst->nf_bridge = src->nf_bridge; +nf_bridge_get (src->nf_bridge); +#endif +} +#else /* CONFIG_NETFILTER */ static inline void nf_reset (struct sk_buff *skb) {} +static inline void __nf_copy (struct sk_buff *dst,const struct sk_buff *src) {}#endif /* CONFIG_NETFILTER */ #ifdef CONFIG_NETWORK_SECMARK
net/core/skbuff.c +2 -26
@@ -476,19 +476,7 @@ #endifC (protocol); n->destructor =NULL ;C (mark); -#ifdef CONFIG_NETFILTER -C (nfct); -nf_conntrack_get (skb->nfct); -C (nfctinfo); -#if defined(CONFIG_NF_CONNTRACK ) || defined(CONFIG_NF_CONNTRACK_MODULE ) -C (nfct_reasm); -nf_conntrack_get_reasm (skb->nfct_reasm); -#endif -#ifdef CONFIG_BRIDGE_NETFILTER -C (nf_bridge); -nf_bridge_get (skb->nf_bridge); -#endif -#endif /*CONFIG_NETFILTER*/ +__nf_copy (n, skb);#ifdef CONFIG_NET_SCHED C (tc_index);#ifdef CONFIG_NET_CLS_ACT
@@ -537,22 +525,10 @@ #endif new->tstamp = old->tstamp; new->destructor =NULL ; new->mark = old->mark; -#ifdef CONFIG_NETFILTER - new->nfct = old->nfct; -nf_conntrack_get (old->nfct); - new->nfctinfo = old->nfctinfo; -#if defined(CONFIG_NF_CONNTRACK ) || defined(CONFIG_NF_CONNTRACK_MODULE ) - new->nfct_reasm = old->nfct_reasm; -nf_conntrack_get_reasm (old->nfct_reasm); -#endif +__nf_copy (new, old);#if defined(CONFIG_IP_VS ) || defined(CONFIG_IP_VS_MODULE ) new->ipvs_property = old->ipvs_property;#endif -#ifdef CONFIG_BRIDGE_NETFILTER - new->nf_bridge = old->nf_bridge; -nf_bridge_get (old->nf_bridge); -#endif -#endif #ifdef CONFIG_NET_SCHED #ifdef CONFIG_NET_CLS_ACT new->tc_verd = old->tc_verd;
PATCH 18/22 : conntrack: add nf_copy() to safely copy members in skb
In reply to Patrick McHardy[NETFILTER]: nf_conntrack: add nf_copy() to safely copy members in skb
This unifies the codes to copy netfilter related datas. Before copying, nf_copy() puts original members in destination skb.
---
commit 625c028a6c0ccfd684f4334699f9ec7672fd179c
tree 2a28f1dbd73d0dab5458df7203534f9ad7bf942e
parent c3f281b640e4bec1e09a5ec338d3e605c23a3e9e
author Yasuyuki Kozakai <[email protected]> Wed, 14 Mar 2007 09:32:30 +0100 committer Patrick McHardy <[email protected]> Wed, 14 Mar 2007 09:32:30 +0100
include/linux/skbuff.h | 13 +++++++++++++ net/ipv4/ip_output.c | 13 +------------ net/ipv6/ip6_output.c | 18 +----------------- 3 files changed, 15 insertions(+), 29 deletions(-)
include/linux/skbuff.h +13 -0
@@ -1497,9 +1497,22 @@ #ifdef CONFIG_BRIDGE_NETFILTER #endif } +static inline void nf_copy (struct sk_buff *dst,const struct sk_buff *src) +{ +nf_conntrack_put (dst->nfct); +#if defined(CONFIG_NF_CONNTRACK ) || defined(CONFIG_NF_CONNTRACK_MODULE ) +nf_conntrack_put_reasm (dst->nfct_reasm); +#endif +#ifdef CONFIG_BRIDGE_NETFILTER +nf_bridge_put (dst->nf_bridge); +#endif +__nf_copy (dst, src); +} +#else /* CONFIG_NETFILTER */ static inline void nf_reset (struct sk_buff *skb) {}static inline void __nf_copy (struct sk_buff *dst,const struct sk_buff *src) {} +static inline void nf_copy (struct sk_buff *dst,const struct sk_buff *src) {}#endif /* CONFIG_NETFILTER */ #ifdef CONFIG_NETWORK_SECMARK
net/ipv4/ip_output.c +1 -12
@@ -384,21 +384,10 @@ static void ip_copy_metadata(struct sk_b#ifdef CONFIG_NET_SCHED to->tc_index = from->tc_index;#endif -#ifdef CONFIG_NETFILTER -/* Connection association is same as pre-frag packet */ -nf_conntrack_put (to->nfct); - to->nfct = from->nfct; -nf_conntrack_get (to->nfct); - to->nfctinfo = from->nfctinfo; +nf_copy (to, from);#if defined(CONFIG_IP_VS ) || defined(CONFIG_IP_VS_MODULE ) to->ipvs_property = from->ipvs_property;#endif -#ifdef CONFIG_BRIDGE_NETFILTER -nf_bridge_put (to->nf_bridge); - to->nf_bridge = from->nf_bridge; -nf_bridge_get (to->nf_bridge); -#endif -#endif skb_copy_secmark (to, from); }
net/ipv6/ip6_output.c +1 -17
@@ -504,23 +504,7 @@ static void ip6_copy_metadata(struct sk_#ifdef CONFIG_NET_SCHED to->tc_index = from->tc_index;#endif -#ifdef CONFIG_NETFILTER -/* Connection association is same as pre-frag packet */ -nf_conntrack_put (to->nfct); - to->nfct = from->nfct; -nf_conntrack_get (to->nfct); - to->nfctinfo = from->nfctinfo; -#if defined(CONFIG_NF_CONNTRACK ) || defined(CONFIG_NF_CONNTRACK_MODULE ) -nf_conntrack_put_reasm (to->nfct_reasm); - to->nfct_reasm = from->nfct_reasm; -nf_conntrack_get_reasm (to->nfct_reasm); -#endif -#ifdef CONFIG_BRIDGE_NETFILTER -nf_bridge_put (to->nf_bridge); - to->nf_bridge = from->nf_bridge; -nf_bridge_get (to->nf_bridge); -#endif -#endif +nf_copy (to, from);skb_copy_secmark (to, from); }
PATCH 19/22 : tcp_conntrack: accept RST|PSH as valid
In reply to Patrick McHardy[NETFILTER]: TCP conntrack: accept RST|PSH as valid
This combination has been encountered on an IBM AS/400 in response to packets sent to a closed session. There is no particular reason to mark it invalid.
---
commit 922ad96654a159769dc890c4ef1896e10985f5bb
tree fe6736631229cdb0d961de37b738268e8dfca032
parent 625c028a6c0ccfd684f4334699f9ec7672fd179c
author Willy Tarreau <[email protected]> Wed, 14 Mar 2007 09:32:43 +0100 committer Patrick McHardy <[email protected]> Wed, 14 Mar 2007 09:32:43 +0100
net/netfilter/nf_conntrack_proto_tcp.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
net/netfilter/nf_conntrack_proto_tcp.c +1 -0
@@ -774,6 +774,7 @@ static u8 tcp_valid_flags[(TH_FIN|TH_SYN [TH_SYN|TH_ACK] = 1, [TH_SYN|TH_ACK|TH_PUSH] = 1, [TH_RST] = 1, + [TH_RST|TH_PUSH] = 1, [TH_RST|TH_ACK] = 1, [TH_RST|TH_ACK|TH_PUSH] = 1, [TH_FIN|TH_ACK] = 1,
PATCH 20/22 : tcp_conntrack: factorize out the PUSH flag
In reply to Patrick McHardy[NETFILTER]: TCP conntrack: factorize out the PUSH flag
The PUSH flag is accepted with every other valid combination. Let's get it out of the tcp_valid_flags table and reduce the number of combinations we have to handle. This does not significantly reduce the table size however (8 bytes).
---
commit 3607514396585a2be00d6d0aa3081a96532e5db7
tree 7aeb2263123d7bba9d8265c2dc55c1e5d3b3ad50
parent 922ad96654a159769dc890c4ef1896e10985f5bb
author Willy Tarreau <[email protected]> Wed, 14 Mar 2007 09:34:29 +0100 committer Patrick McHardy <[email protected]> Wed, 14 Mar 2007 09:34:29 +0100
net/netfilter/nf_conntrack_proto_tcp.c | 17 ++++------------- 1 files changed, 4 insertions(+), 13 deletions(-)
net/netfilter/nf_conntrack_proto_tcp.c +4 -13
@@ -764,27 +764,18 @@ #define TH_URG 0x20#define TH_ECE 0x40#define TH_CWR 0x80 -/* table of valid flag combinations - ECE and CWR are always valid */ -static u8 tcp_valid_flags[(TH_FIN |TH_SYN |TH_RST |TH_PUSH |TH_ACK |TH_URG ) +1 ] = +/* table of valid flag combinations - PUSH, ECE and CWR are always valid */ +static u8 tcp_valid_flags[(TH_FIN |TH_SYN |TH_RST |TH_ACK |TH_URG ) +1 ] = { [TH_SYN ] =1 , - [TH_SYN |TH_PUSH ] =1 , [TH_SYN |TH_URG ] =1 , - [TH_SYN |TH_PUSH |TH_URG ] =1 , [TH_SYN |TH_ACK ] =1 , - [TH_SYN |TH_ACK |TH_PUSH ] =1 , [TH_RST ] =1 , - [TH_RST |TH_PUSH ] =1 , [TH_RST |TH_ACK ] =1 , - [TH_RST |TH_ACK |TH_PUSH ] =1 , [TH_FIN |TH_ACK ] =1 , + [TH_FIN |TH_ACK |TH_URG ] =1 , [TH_ACK ] =1 , - [TH_ACK |TH_PUSH ] =1 , [TH_ACK |TH_URG ] =1 , - [TH_ACK |TH_URG |TH_PUSH ] =1 , - [TH_FIN |TH_ACK |TH_PUSH ] =1 , - [TH_FIN |TH_ACK |TH_URG ] =1 , - [TH_FIN |TH_ACK |TH_URG |TH_PUSH ] =1 , };/* Protect conntrack agaist broken packets. Code taken from ipt_unclean.c. */
@@ -831,7 +822,7 @@ static int tcp_error(struct sk_buff *skb }/* Check TCP flags. */ - tcpflags = (((u_int8_t *)th)[13 ] & ~(TH_ECE |TH_CWR )); + tcpflags = (((u_int8_t *)th)[13 ] & ~(TH_ECE |TH_CWR |TH_PUSH ));if (!tcp_valid_flags[tcpflags]) {if (LOG_INVALID (IPPROTO_TCP )) nf_log_packet(pf, 0, skb, NULL, NULL, NULL,
PATCH 21/22 : ctnetlink: add support for internal tcp connection tracking flags handling
In reply to Patrick McHardy[NETFILTER]: ctnetlink: add support for internal tcp connection tracking flags handling
This patch let userspace programs set the IP_CT_TCP_BE_LIBERAL flag to force the pickup of established connections.
---
commit 95cddede9ae6fddfb993ab5d989f6d96cdf4e8e8
tree 760bf19f0f49fb668b24552e9243b5568b0a615e
parent 3607514396585a2be00d6d0aa3081a96532e5db7
author Pablo Neira Ayuso <[email protected]> Wed, 14 Mar 2007 09:34:50 +0100 committer Patrick McHardy <[email protected]> Wed, 14 Mar 2007 09:34:50 +0100
include/linux/netfilter/nf_conntrack_tcp.h | 5 +++ include/linux/netfilter/nfnetlink_conntrack.h | 4 ++ net/netfilter/nf_conntrack_proto_tcp.c | 45 ++++++++++++++++++++++++- 3 files changed, 53 insertions(+), 1 deletions(-)
include/linux/netfilter/nf_conntrack_tcp.h +5 -0
@@ -30,6 +30,11 @@ #define IP_CT_TCP_FLAG_CLOSE_INIT 0x04/* Be liberal in window checking */ #define IP_CT_TCP_FLAG_BE_LIBERAL 0x08 +struct nf_ct_tcp_flags { +u_int8_t flags; +u_int8_t mask; +}; +#ifdef __KERNEL__ struct ip_ct_tcp_state {
include/linux/netfilter/nfnetlink_conntrack.h +4 -0
@@ -83,6 +83,10 @@ #define CTA_PROTOINFO_MAX (__CTA_PROTOINenum ctattr_protoinfo_tcp {CTA_PROTOINFO_TCP_UNSPEC ,CTA_PROTOINFO_TCP_STATE , +CTA_PROTOINFO_TCP_WSCALE_ORIGINAL , +CTA_PROTOINFO_TCP_WSCALE_REPLY , +CTA_PROTOINFO_TCP_FLAGS_ORIGINAL , +CTA_PROTOINFO_TCP_FLAGS_REPLY , __CTA_PROTOINFO_TCP_MAX };#define CTA_PROTOINFO_TCP_MAX (__CTA_PROTOINFO_TCP_MAX - 1)
net/netfilter/nf_conntrack_proto_tcp.c +44 -1
68 lines not on this page · raw message
PATCH 22/22 : nfnetlink: parse attributes with nfattr_parse in nfnetlink_check_attribute
In reply to Patrick McHardy[NETFILTER]: nfnetlink: parse attributes with nfattr_parse in nfnetlink_check_attribute
Use nfattr_parse to parse attributes, this patch also modifies the default behaviour since unknown attributes will be ignored instead of returning EINVAL. This ensure backward compatibility: new libraries with new attributes and old kernels can work.
---
commit 53d0099da1eea04b818399e4548daeb7399c7bc2
tree 20ef7dfae6763dabbc5b0a84a169e1c69db2f0c6
parent 95cddede9ae6fddfb993ab5d989f6d96cdf4e8e8
author Pablo Neira Ayuso <[email protected]> Wed, 14 Mar 2007 09:35:23 +0100 committer Patrick McHardy <[email protected]> Wed, 14 Mar 2007 09:35:23 +0100
net/netfilter/nfnetlink.c | 16 ++-------------- 1 files changed, 2 insertions(+), 14 deletions(-)
net/netfilter/nfnetlink.c +2 -14
@@ -151,26 +151,14 @@ nfnetlink_check_attributes(struct nfnetl struct nlmsghdr *nlh, struct nfattr *cda[]) { int min_len = NLMSG_SPACE(sizeof(struct nfgenmsg)); -u_int16_t attr_count;u_int8_t cb_id =NFNL_MSG_TYPE (nlh->nlmsg_type); - - attr_count = subsys->cb[cb_id].attr_count; -memset (cda,0 ,sizeof (struct nfattr *) * attr_count); +u_int16_t attr_count = subsys->cb[cb_id].attr_count;/* check attribute lengths. */ if (likely (nlh->nlmsg_len > min_len)) {struct nfattr *attr =NFM_NFA (NLMSG_DATA (nlh));int attrlen = nlh->nlmsg_len -NLMSG_ALIGN (min_len); - -while (NFA_OK (attr, attrlen)) { -unsigned flavor =NFA_TYPE (attr); -if (flavor) { -if (flavor > attr_count) -return -EINVAL ; - cda[flavor -1 ] = attr; - } - attr =NFA_NEXT (attr, attrlen); - } +nfattr_parse (cda, attr_count, attr, attrlen); }/* implicit: if nlmsg_len == min_len, we return 0, and an empty
David Miller
maintainerFrom: Patrick McHardy <[email protected]>
Date: Wed, 14 Mar 2007 09:50:02 +0100 (MET)
Quoted 6 lines
following is a first batch of netfilter patches for 2.6.22, containing the scheduled removal of ip_conntrack/ip_nat, some further
nf_conntracklocking cleanup, nfnetlink cleanup and a few minor enhancements in various places. The patches should apply cleanly to the current net-2.6.22 tree.Please apply, thanks.
Thanks Patrick.
I have two major merges to do today, one large set from Arnaldo with more skb data access refinements, and this netfilter set.
What I'm going to do is merge Arnaldo's first, then your's.
The logic is that it's easier for me to fix conflicts in your patch set (since it largely just removes code) than the other way around.
Quoted 8 lines · David Miller
I have two major merges to do today, one large set from Arnaldo with more skb data access refinements, and this netfilter set.
What I'm going to do is merge Arnaldo's first, then your's.
The logic is that it's easier for me to fix conflicts in your patch set (since it largely just removes code) than the other way around.
Thanks. I had a quick look at Arnaldo's patches and think there shouldn't be any conflicts, but if there are, just let me know and I'll go over it afterwards.
David Miller
maintainerFrom: Patrick McHardy <[email protected]>
Date: Thu, 15 Mar 2007 00:14:25 +0100
Quoted 6 lines
Quoted 5 lines · David Miller
I have two major merges to do today, one large set from Arnaldo with more skb data access refinements, and this netfilter set.
What I'm going to do is merge Arnaldo's first, then your's.
Quoted 7 lines
Quoted 3 lines
The logic is that it's easier for me to fix conflicts in your patch set (since it largely just removes code) than the other way around.
Thanks. I had a quick look at Arnaldo's patches and think there shouldn't be any conflicts, but if there are, just let me know and I'll go over it afterwards.
Happily, it all went in cleanly. I push it all back out to kernel.org, let me know if I screw up anything :-)
Thanks!