: Netfilter patches
Subsystems (2)
cover : Netfilter patches
Hi Dave,
following are a few netfilter patches, containing some cleanup of nf_conntrack, nf_nat and ip_tables, additionally there are two fixes to clear the private helper area when reassigning helpers and compat support for xt_conntrack.
Please apply, thanks.
include/linux/netfilter/x_tables.h | 8 + include/linux/netfilter_arp/arp_tables.h | 41 +++++++ include/linux/netfilter_ipv4/ip_tables.h | 22 ++++ include/linux/netfilter_ipv6/ip6_tables.h | 22 ++++ include/net/netfilter/nf_conntrack.h | 7 - include/net/netfilter/nf_conntrack_l3proto.h | 3 include/net/netfilter/nf_nat_rule.h | 11 -- net/ipv4/netfilter/arptable_filter.c | 140 ++++----------------------- net/ipv4/netfilter/iptable_filter.c | 73 ++++---------- net/ipv4/netfilter/iptable_mangle.c | 99 +++++-------------- net/ipv4/netfilter/iptable_raw.c | 78 +++++---------- net/ipv4/netfilter/nf_nat_rule.c | 86 ++-------------- net/ipv4/netfilter/nf_nat_standalone.c | 11 -- net/ipv6/netfilter/ip6table_filter.c | 70 ++++--------- net/ipv6/netfilter/ip6table_mangle.c | 96 +++++------------- net/ipv6/netfilter/ip6table_raw.c | 52 ---------- net/netfilter/nf_conntrack_core.c | 14 +- net/netfilter/nf_conntrack_netlink.c | 40 ++++--- net/netfilter/xt_conntrack.c | 54 ++++++++++ 19 files changed, 354 insertions(+), 573 deletions(-)
Patrick McHardy (4):
[NETFILTER]: Clean up table initialization
[NETFILTER]: iptable_{filter,mangle}: more descriptive "happy cracking" message [NETFILTER]: iptable_raw: ignore short packets sent by SOCK_RAW sockets [NETFILTER]: xt_conntrack: add compat support
Yasuyuki Kozakai (5):
[NETFILTER]: nf_nat: remove unused argument of function allocating binding [NETFILTER]: nf_conntrack: Removes duplicated declarations [NETFILTER]: nf_conntrack: Removes unused destroy operation of l3proto [NETFILTER]: ctnetlink: clear helper area and handle unchanged helper [NETFILTER]: nf_nat: Clears helper private area when NATing
PATCH 1/9 : Clean up table initialization
[NETFILTER]: Clean up table initialization
- move arp_tables initial table structure definitions to arp_tables.h similar to ip_tables and ip6_tables
- use C99 initializers
- use initializer macros where possible
---
commit acf2e14c5f3ff9b9ad1500c135a8d9be98d66436
tree c3d814e7e64652f2ec2541e174b9a210ac1f2459
parent a989705c4cf6e6c1a339c95f9daf658b4ba88ca8
author Patrick McHardy <[email protected]> Tue, 08 May 2007 11:06:17 +0200 committer Patrick McHardy <[email protected]> Tue, 08 May 2007 11:06:17 +0200
include/linux/netfilter/x_tables.h | 8 ++ include/linux/netfilter_arp/arp_tables.h | 41 ++++++++ include/linux/netfilter_ipv4/ip_tables.h | 22 +++++ include/linux/netfilter_ipv6/ip6_tables.h | 22 +++++ net/ipv4/netfilter/arptable_filter.c | 140 +++++------------------------ net/ipv4/netfilter/iptable_filter.c | 70 +++++---------- net/ipv4/netfilter/iptable_mangle.c | 96 ++++++-------------- net/ipv4/netfilter/iptable_raw.c | 58 +----------- net/ipv4/netfilter/nf_nat_rule.c | 73 ++------------- net/ipv6/netfilter/ip6table_filter.c | 70 +++++---------- net/ipv6/netfilter/ip6table_mangle.c | 96 ++++++-------------- net/ipv6/netfilter/ip6table_raw.c | 52 +---------- 12 files changed, 238 insertions(+), 510 deletions(-)
include/linux/netfilter/x_tables.h +8 -0
@@ -54,6 +54,14 @@ struct xt_entry_targetunsigned char data[0 ]; }; +#define XT_TARGET_INIT (__name, __size) \ +{ \ + .target.u.user = { \ + .target_size = XT_ALIGN(__size), \ + .name = __name, \ + }, \ +} +struct xt_standard_target {struct xt_entry_target target;
include/linux/netfilter_arp/arp_tables.h +41 -0
47 lines not on this page · raw message
include/linux/netfilter_ipv4/ip_tables.h +22 -0
@@ -295,6 +295,28 @@ struct ipt_errorstruct ipt_error_target target; }; +#define IPT_ENTRY_INIT (__size) \ +{ \ + .target_offset = sizeof(struct ipt_entry), \ + .next_offset = (__size), \ +} + +#define IPT_STANDARD_INIT (__verdict) \ +{ \ + .entry = IPT_ENTRY_INIT(sizeof(struct ipt_standard)), \ + .target = XT_TARGET_INIT(IPT_STANDARD_TARGET, \ + sizeof(struct xt_standard_target)), \ + .target.verdict = -(__verdict) - 1, \ +} + +#define IPT_ERROR_INIT \ +{ \ + .entry = IPT_ENTRY_INIT(sizeof(struct ipt_error)), \ + .target = XT_TARGET_INIT(IPT_ERROR_TARGET, \ + sizeof(struct ipt_error_target)), \ + .target.errorname = "ERROR", \ +} + extern unsigned int ipt_do_table(struct sk_buff **pskb, unsigned int hook, const struct net_device *in,
include/linux/netfilter_ipv6/ip6_tables.h +22 -0
@@ -123,6 +123,28 @@ struct ip6t_errorstruct ip6t_error_target target; }; +#define IP6T_ENTRY_INIT (__size) \ +{ \ + .target_offset = sizeof(struct ip6t_entry), \ + .next_offset = (__size), \ +} + +#define IP6T_STANDARD_INIT (__verdict) \ +{ \ + .entry = IP6T_ENTRY_INIT(sizeof(struct ip6t_standard)), \ + .target = XT_TARGET_INIT(IP6T_STANDARD_TARGET, \ + sizeof(struct ip6t_standard_target)), \ + .target.verdict = -(__verdict) - 1, \ +} + +#define IP6T_ERROR_INIT \ +{ \ + .entry = IP6T_ENTRY_INIT(sizeof(struct ip6t_error)), \ + .target = XT_TARGET_INIT(IP6T_ERROR_TARGET, \ + sizeof(struct ip6t_error_target)), \ + .target.errorname = "ERROR", \ +} +/* * New IP firewall options for [gs]etsockopt at the RAW IP level. * Unlike BSD Linux inherits IP options so you don't have to use
net/ipv4/netfilter/arptable_filter.c +23 -117
151 lines not on this page · raw message
net/ipv4/netfilter/iptable_filter.c +23 -47
76 lines not on this page · raw message
net/ipv4/netfilter/iptable_mangle.c +29 -67
102 lines not on this page · raw message
net/ipv4/netfilter/iptable_raw.c +7 -51
69 lines not on this page · raw message
net/ipv4/netfilter/nf_nat_rule.c +8 -65
85 lines not on this page · raw message
net/ipv6/netfilter/ip6table_filter.c +23 -47
76 lines not on this page · raw message
net/ipv6/netfilter/ip6table_mangle.c +29 -67
102 lines not on this page · raw message
net/ipv6/netfilter/ip6table_raw.c +3 -49
59 lines not on this page · raw message
Re: [NETFILTER 01/09]: Clean up table initialization
From: Patrick McHardy <[email protected]>
Date: Thu, 10 May 2007 15:41:11 +0200 (MEST)
Quoted 10 lines
[NETFILTER]: Clean up table initialization
- move
arp_tablesinitial table structure definitions toarp_tables.hsimilar toip_tablesandip6_tables- use C99 initializers
- use initializer macros where possible
Signed-off-by Patrick McHardy <[email protected]>
Applied.
PATCH 2/9 : nf_nat: remove unused argument of function allocating binding
In reply to Patrick McHardy[NETFILTER]: nf_nat: remove unused argument of function allocating binding
nf_nat_rule_find, alloc_null_binding and alloc_null_binding_confirmed do not use the argument 'info', which is actually ct->nat.info. If they are necessary to access it again, we can use the argument 'ct' instead.
---
commit f1103257fddbe3a55b4ae964741cefb5026c20ec
tree 32d30851ebdb14a2dfc5b7b10267b9700cf010d5
parent acf2e14c5f3ff9b9ad1500c135a8d9be98d66436
author Yasuyuki Kozakai <[email protected]> Tue, 08 May 2007 11:06:17 +0200 committer Patrick McHardy <[email protected]> Tue, 08 May 2007 11:06:17 +0200
include/net/netfilter/nf_nat_rule.h | 11 +++-------- net/ipv4/netfilter/nf_nat_rule.c | 13 ++++--------- net/ipv4/netfilter/nf_nat_standalone.c | 11 +++-------- 3 files changed, 10 insertions(+), 25 deletions(-)
include/net/netfilter/nf_nat_rule.h +3 -8
@@ -10,16 +10,11 @@ extern int nf_nat_rule_find(struct sk_buff **pskb,unsigned int hooknum, const struct net_device *in, const struct net_device *out, - struct nf_conn *ct, - struct nf_nat_info *info); + struct nf_conn *ct);extern unsigned int -alloc_null_binding (struct nf_conn *ct, -struct nf_nat_info *info, -unsigned int hooknum); +alloc_null_binding (struct nf_conn *ct,unsigned int hooknum);extern unsigned int -alloc_null_binding_confirmed (struct nf_conn *ct, -struct nf_nat_info *info, -unsigned int hooknum); +alloc_null_binding_confirmed (struct nf_conn *ct,unsigned int hooknum);#endif /* _NF_NAT_RULE_H */
net/ipv4/netfilter/nf_nat_rule.c +4 -9
@@ -173,9 +173,7 @@ static int ipt_dnat_checkentry(const char *tablename, }inline unsigned int -alloc_null_binding (struct nf_conn *ct, -struct nf_nat_info *info, -unsigned int hooknum) +alloc_null_binding (struct nf_conn *ct,unsigned int hooknum) {/* Force range to this IP; let proto decide mapping for per-proto parts (hence not IP_NAT_RANGE_PROTO_SPECIFIED).
@@ -194,9 +192,7 @@ alloc_null_binding(struct nf_conn *ct, }unsigned int -alloc_null_binding_confirmed (struct nf_conn *ct, -struct nf_nat_info *info, -unsigned int hooknum) +alloc_null_binding_confirmed (struct nf_conn *ct,unsigned int hooknum) {__be32 ip = (HOOK2MANIP(hooknum) == IP_NAT_MANIP_SRC
@@ -218,8 +214,7 @@ int nf_nat_rule_find(struct sk_buff **pskb,unsigned int hooknum, const struct net_device *in, const struct net_device *out, - struct nf_conn *ct, - struct nf_nat_info *info) + struct nf_conn *ct) { int ret;
@@ -228,7 +223,7 @@ int nf_nat_rule_find(struct sk_buff **pskb,if (ret ==NF_ACCEPT ) {if (!nf_nat_initialized (ct,HOOK2MANIP (hooknum)))/* NUL mapping */ - ret =alloc_null_binding (ct, info, hooknum); + ret =alloc_null_binding (ct, hooknum); }return ret; }
net/ipv4/netfilter/nf_nat_standalone.c +3 -8
@@ -80,7 +80,6 @@ nf_nat_fn(unsigned int hooknum,struct nf_conn *ct;enum ip_conntrack_info ctinfo;struct nf_conn_nat *nat; -struct nf_nat_info *info;/* maniptype == SRC for postrouting. */ enum nf_nat_manip_type maniptype =HOOK2MANIP (hooknum);
@@ -129,7 +128,6 @@ nf_nat_fn(unsigned int hooknum, }/* Fall thru... (Only ICMPs can be IP_CT_IS_REPLY) */ case IP_CT_NEW : - info = &nat->info;/* Seen it before? This can happen for loopback, retrans, or local packets.. */
@@ -138,14 +136,13 @@ nf_nat_fn(unsigned int hooknum,if (unlikely (nf_ct_is_confirmed (ct)))/* NAT module was loaded late */ - ret =alloc_null_binding_confirmed (ct, info, - hooknum); + ret =alloc_null_binding_confirmed (ct, hooknum);else if (hooknum ==NF_IP_LOCAL_IN )/* LOCAL_IN hook doesn't have a chain! */ - ret =alloc_null_binding (ct, info, hooknum); + ret =alloc_null_binding (ct, hooknum);else ret =nf_nat_rule_find (pskb, hooknum, in, out, - ct, info); + ct);if (ret !=NF_ACCEPT ) {return ret;
@@ -160,10 +157,8 @@ nf_nat_fn(unsigned int hooknum,/* ESTABLISHED */ NF_CT_ASSERT (ctinfo ==IP_CT_ESTABLISHED || ctinfo == (IP_CT_ESTABLISHED +IP_CT_IS_REPLY )); - info = &nat->info; } -NF_CT_ASSERT (info);return nf_nat_packet (ct, ctinfo, hooknum, pskb); }
Re: [NETFILTER 02/09]: nf_nat: remove unused argument of function allocating binding
From: Patrick McHardy <[email protected]>
Date: Thu, 10 May 2007 15:41:12 +0200 (MEST)
Quoted 9 lines
[NETFILTER]:
nf_nat: remove unused argument of function allocating binding
nf_nat_rule_find,alloc_null_bindingandalloc_null_binding_confirmeddo not use the argument 'info', which is actuallyct->nat.info. If they are necessary to access it again, we can use the argument 'ct' instead.Signed-off-by Yasuyuki Kozakai <[email protected]>Signed-off-by Patrick McHardy <[email protected]>
Applied.
PATCH 3/9 : nf_conntrack: Removes duplicated declarations
In reply to Patrick McHardy[NETFILTER]: nf_conntrack: Removes duplicated declarations
These are also in include/net/netfilter/nf_conntrack_helper.h
---
commit aeca1c226efa93ec47d21303d907d7ab18c30f0e
tree f35fccc4722bc6fe48e574e2c2596723bb01b673
parent f1103257fddbe3a55b4ae964741cefb5026c20ec
author Yasuyuki Kozakai <[email protected]> Tue, 08 May 2007 11:06:18 +0200 committer Patrick McHardy <[email protected]> Tue, 08 May 2007 11:06:18 +0200
include/net/netfilter/nf_conntrack.h | 7 ------- 1 files changed, 0 insertions(+), 7 deletions(-)
include/net/netfilter/nf_conntrack.h +0 -7
@@ -183,13 +183,6 @@ extern void nf_conntrack_hash_insert(struct nf_conn *ct);extern void nf_conntrack_flush (void ); -extern struct nf_conntrack_helper * -nf_ct_helper_find_get (const struct nf_conntrack_tuple *tuple); -extern void nf_ct_helper_put (struct nf_conntrack_helper *helper); - -extern struct nf_conntrack_helper * -__nf_conntrack_helper_find_byname (const char *name); -extern int nf_ct_invert_tuplepr (struct nf_conntrack_tuple *inverse,const struct nf_conntrack_tuple *orig);
Re: [NETFILTER 03/09]: nf_conntrack: Removes duplicated declarations
From: Patrick McHardy <[email protected]>
Date: Thu, 10 May 2007 15:41:14 +0200 (MEST)
Quoted 6 lines
[NETFILTER]:
nf_conntrack: Removes duplicated declarationsThese are also in
include/net/netfilter/nf_conntrack_helper.hSigned-off-by Yasuyuki Kozakai <[email protected]>Signed-off-by Patrick McHardy <[email protected]>
Applied.
PATCH 4/9 : nf_conntrack: Removes unused destroy operation of l3proto
In reply to Patrick McHardy[NETFILTER]: nf_conntrack: Removes unused destroy operation of l3proto
---
commit f1ab39bebc088ba296db8e047b21700b4a77d51c
tree d3276fe947a35054a48f9ba00ec7a31e2d375432
parent aeca1c226efa93ec47d21303d907d7ab18c30f0e
author Yasuyuki Kozakai <[email protected]> Tue, 08 May 2007 11:06:18 +0200 committer Patrick McHardy <[email protected]> Tue, 08 May 2007 11:06:18 +0200
include/net/netfilter/nf_conntrack_l3proto.h | 3 --- net/netfilter/nf_conntrack_core.c | 5 ----- 2 files changed, 0 insertions(+), 8 deletions(-)
include/net/netfilter/nf_conntrack_l3proto.h +0 -3
@@ -56,9 +56,6 @@ struct nf_conntrack_l3proto*/ int (*new)(struct nf_conn *conntrack,const struct sk_buff *skb); -/* Called when a conntrack entry is destroyed */ -void (*destroy)(struct nf_conn *conntrack); -/* * Called before tracking. * *dataoff: offset of protocol header (TCP, UDP,...) in *pskb
net/netfilter/nf_conntrack_core.c +0 -5
@@ -299,7 +299,6 @@ destroy_conntrack(struct nf_conntrack *nfct) {struct nf_conn *ct = (struct nf_conn *)nfct;struct nf_conn_help *help =nfct_help (ct); -struct nf_conntrack_l3proto *l3proto;struct nf_conntrack_l4proto *l4proto;typeof (nf_conntrack_destroyed) destroyed;
@@ -317,10 +316,6 @@ destroy_conntrack(struct nf_conntrack *nfct)* destroy_conntrack() MUST NOT be called with a write lock * to nf_conntrack_lock!!! -HW */ rcu_read_lock (); - l3proto =__nf_ct_l3proto_find (ct->tuplehash[IP_CT_DIR_REPLY ].tuple.src.l3num); -if (l3proto && l3proto->destroy) - l3proto->destroy (ct); - l4proto =__nf_ct_l4proto_find (ct->tuplehash[IP_CT_DIR_REPLY ].tuple.src.l3num, ct->tuplehash[IP_CT_DIR_REPLY ].tuple.dst.protonum);if (l4proto && l4proto->destroy)
Re: [NETFILTER 04/09]: nf_conntrack: Removes unused destroy operation of l3proto
From: Patrick McHardy <[email protected]>
Date: Thu, 10 May 2007 15:41:15 +0200 (MEST)
Quoted 4 lines
[NETFILTER]:
nf_conntrack: Removes unused destroy operation of l3protoSigned-off-by Yasuyuki Kozakai <[email protected]>Signed-off-by Patrick McHardy <[email protected]>
Applied.
PATCH 5/9 : ctnetlink: clear helper area and handle unchanged helper
In reply to Patrick McHardy[NETFILTER]: ctnetlink: clear helper area and handle unchanged helper
This patch
- Clears private area for helper even if no helper is assigned to conntrack. It might be used by old helper.
- Unchanges if the same helper as the used one is specified.
- Does not find helper if no helper is specified. And it does not require private area for helper in that case.
---
commit 9655305aa47e326950ad24fc072ff19aaf5691f9
tree f8c4bc7c4772b99427327af7bf93007f82e8c69f
parent f1ab39bebc088ba296db8e047b21700b4a77d51c
author Yasuyuki Kozakai <[email protected]> Tue, 08 May 2007 11:06:18 +0200 committer Patrick McHardy <[email protected]> Tue, 08 May 2007 11:06:18 +0200
net/netfilter/nf_conntrack_netlink.c | 40 +++++++++++++++++++--------------- 1 files changed, 22 insertions(+), 18 deletions(-)
net/netfilter/nf_conntrack_netlink.c +22 -18
@@ -830,11 +830,6 @@ ctnetlink_change_helper(struct nf_conn *ct, struct nfattr *cda[])char *helpname;int err; -if (!help) { -/* FIXME: we need to reallocate and rehash */ -return -EBUSY ; - } -/* don't change helper of sibling connections */ if (ct->master)return -EINVAL ;
@@ -843,25 +838,34 @@ ctnetlink_change_helper(struct nf_conn *ct, struct nfattr *cda[])if (err <0 )return err; - helper =__nf_conntrack_helper_find_byname (helpname); -if (!helper) { -if (!strcmp (helpname,"" )) - helper =NULL ; -else -return -EINVAL ; - } - -if (help->helper) { -if (!helper) { +if (!strcmp (helpname,"" )) { +if (help && help->helper) {/* we had a helper before ... */ nf_ct_remove_expectations (ct); help->helper =NULL ; - }else { -/* need to zero data of old helper */ -memset (&help->help,0 ,sizeof (help->help)); } + +return 0 ; } +if (!help) { +/* FIXME: we need to reallocate and rehash */ +return -EBUSY ; + } + + helper =__nf_conntrack_helper_find_byname (helpname); +if (helper ==NULL ) +return -EINVAL ; + +if (help->helper == helper) +return 0 ; + +if (help->helper) +/* we had a helper before ... */ +nf_ct_remove_expectations (ct); + +/* need to zero data of old helper */ +memset (&help->help,0 ,sizeof (help->help)); help->helper = helper;return 0 ;
Re: [NETFILTER 05/09]: ctnetlink: clear helper area and handle unchanged helper
From: Patrick McHardy <[email protected]>
Date: Thu, 10 May 2007 15:41:16 +0200 (MEST)
Quoted 11 lines
[NETFILTER]: ctnetlink: clear helper area and handle unchanged helper
This patch
- Clears private area for helper even if no helper is assigned to conntrack. It might be used by old helper.
- Unchanges if the same helper as the used one is specified.
- Does not find helper if no helper is specified. And it does not require private area for helper in that case.Signed-off-by Yasuyuki Kozakai <[email protected]>Signed-off-by Patrick McHardy <[email protected]>
Applied.
PATCH 6/9 : nf_nat: Clears helper private area when NATing
In reply to Patrick McHardy[NETFILTER]: nf_nat: Clears helper private area when NATing
Some helpers (eg. ftp) assume that private area in conntrack is filled with zero. It should be cleared when helper is changed.
---
commit 204674154410105c5b614101779698b439c2d864
tree c1d5f9835776353a1c53b7313f880ae4a6d8b2f1
parent 9655305aa47e326950ad24fc072ff19aaf5691f9
author Yasuyuki Kozakai <[email protected]> Tue, 08 May 2007 11:06:19 +0200 committer Patrick McHardy <[email protected]> Tue, 08 May 2007 11:06:19 +0200
net/netfilter/nf_conntrack_core.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-)
net/netfilter/nf_conntrack_core.c +7 -2
@@ -888,8 +888,13 @@ void nf_conntrack_alter_reply(struct nf_conn *ct,NF_CT_DUMP_TUPLE (newreply); ct->tuplehash[IP_CT_DIR_REPLY ].tuple = *newreply; -if (!ct->master && help && help->expecting ==0 ) - help->helper =__nf_ct_helper_find (newreply); +if (!ct->master && help && help->expecting ==0 ) { +struct nf_conntrack_helper *helper; + helper =__nf_ct_helper_find (newreply); +if (helper) +memset (&help->help,0 ,sizeof (help->help)); + help->helper = helper; + }write_unlock_bh (&nf_conntrack_lock); }EXPORT_SYMBOL_GPL (nf_conntrack_alter_reply);
Re: [NETFILTER 06/09]: nf_nat: Clears helper private area when NATing
From: Patrick McHardy <[email protected]>
Date: Thu, 10 May 2007 15:41:18 +0200 (MEST)
Quoted 7 lines
[NETFILTER]:
nf_nat: Clears helper private area when NATingSome helpers (eg. ftp) assume that private area in conntrack is filled with zero. It should be cleared when helper is changed.
Signed-off-by Yasuyuki Kozakai <[email protected]>Signed-off-by Patrick McHardy <[email protected]>
Applied.
PATCH 7/9 : iptable_{filter, mangle}: more descriptive "happy cracking" message
In reply to Patrick McHardy[NETFILTER]: iptable_{filter,mangle}: more descriptive "happy cracking" message
---
commit 2a5f3d9533016d5f7914b75ea5f7a5fe98872f24
tree e20bd2440ccf6814b349fb00cee0941d63b31d61
parent 204674154410105c5b614101779698b439c2d864
author Patrick McHardy <[email protected]> Thu, 10 May 2007 15:30:22 +0200 committer Patrick McHardy <[email protected]> Thu, 10 May 2007 15:30:22 +0200
net/ipv4/netfilter/iptable_filter.c | 3 ++- net/ipv4/netfilter/iptable_mangle.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
net/ipv4/netfilter/iptable_filter.c +2 -1
@@ -81,7 +81,8 @@ ipt_local_out_hook(unsigned int hook,if ((*pskb)->len <sizeof (struct iphdr ) ||ip_hdrlen (*pskb) <sizeof (struct iphdr )) {if (net_ratelimit ()) -printk ("ipt_hook: happy cracking.\n" ); +printk ("iptable_filter: ignoring short SOCK_RAW " +"packet.\n" );return NF_ACCEPT ; }
net/ipv4/netfilter/iptable_mangle.c +2 -1
@@ -100,7 +100,8 @@ ipt_local_hook(unsigned int hook,if ((*pskb)->len <sizeof (struct iphdr ) ||ip_hdrlen (*pskb) <sizeof (struct iphdr )) {if (net_ratelimit ()) -printk ("ipt_hook: happy cracking.\n" ); +printk ("iptable_mangle: ignoring short SOCK_RAW " +"packet.\n" );return NF_ACCEPT ; }
David Miller
maintainerRe: [NETFILTER 07/09]: iptable_{filter,mangle}: more descriptive "happy cracking" message
From: Patrick McHardy <[email protected]>
Date: Thu, 10 May 2007 15:41:19 +0200 (MEST)
Quoted 3 lines
[NETFILTER]: iptable_{filter,mangle}: more descriptive "happy cracking" message
Signed-off-by Patrick McHardy <[email protected]>
In a way I'm very sad to see this message go away, but such is "progress", so applied ;-)
Re: [NETFILTER 07/09]: iptable_{filter,mangle}: more descriptive "happy cracking" message
Quoted 11 lines · David Miller
From: Patrick McHardy <[email protected]>
Date: Thu, 10 May 2007 15:41:19 +0200 (MEST)Quoted 3 lines
[NETFILTER]: iptable_{filter,mangle}: more descriptive "happy cracking" message
Signed-off-by Patrick McHardy <[email protected]>In a way I'm very sad to see this message go away, but such is "progress", so applied ;-)
Me too, but I'd rather change it than explain it again. We still have a few of Rusty's funny messages and commentaries left :)
PATCH 8/9 : iptable_raw: ignore short packets sent by SOCK_RAW sockets
In reply to Patrick McHardy[NETFILTER]: iptable_raw: ignore short packets sent by SOCK_RAW sockets
iptables matches and targets expect packets to have at least a full IP header and a valid header length. Ignore packets sent through raw sockets for which this isn't true as in the other tables.
---
commit e319b2005352790a24e1a91dc1af4b2f8643a876
tree 20b707b1bb83996c701f78745f18c75d3e06a3d0
parent 2a5f3d9533016d5f7914b75ea5f7a5fe98872f24
author Patrick McHardy <[email protected]> Thu, 10 May 2007 15:38:16 +0200 committer Patrick McHardy <[email protected]> Thu, 10 May 2007 15:38:16 +0200
net/ipv4/netfilter/iptable_raw.c | 21 ++++++++++++++++++++- 1 files changed, 20 insertions(+), 1 deletions(-)
net/ipv4/netfilter/iptable_raw.c +20 -1
@@ -5,6 +5,7 @@*/ #include <linux/module.h> #include <linux/netfilter_ipv4/ip_tables.h> +#include <net/ip.h> #define RAW_VALID_HOOKS ((1 << NF_IP_PRE_ROUTING) | (1 << NF_IP_LOCAL_OUT))
@@ -54,6 +55,24 @@ ipt_hook(unsigned int hook,return ipt_do_table (pskb, hook, in, out, &packet_raw); } +static unsigned int +ipt_local_hook (unsigned int hook, +struct sk_buff **pskb, +const struct net_device *in, +const struct net_device *out, +int (*okfn)(struct sk_buff *)) +{ +/* root is playing with raw sockets. */ +if ((*pskb)->len <sizeof (struct iphdr ) || +ip_hdrlen (*pskb) <sizeof (struct iphdr )) { +if (net_ratelimit ()) +printk ("iptable_raw: ignoring short SOCK_RAW" +"packet.\n" ); +return NF_ACCEPT ; + } +return ipt_do_table (pskb, hook, in, out, &packet_raw); +} +/* 'raw' is the very first table. */ static struct nf_hook_ops ipt_ops[] = { {
@@ -64,7 +83,7 @@ static struct nf_hook_ops ipt_ops[] = { .owner = THIS_MODULE, }, { - .hook = ipt_hook, + .hook = ipt_local_hook, .pf = PF_INET, .hooknum = NF_IP_LOCAL_OUT, .priority = NF_IP_PRI_RAW,
Re: [NETFILTER 08/09]: iptable_raw: ignore short packets sent by SOCK_RAW sockets
From: Patrick McHardy <[email protected]>
Date: Thu, 10 May 2007 15:41:20 +0200 (MEST)
Quoted 7 lines
[NETFILTER]:
iptable_raw: ignore short packets sent bySOCK_RAWsocketsiptables matches and targets expect packets to have at least a full IP header and a valid header length. Ignore packets sent through raw sockets for which this isn't true as in the other tables.
Signed-off-by Patrick McHardy <[email protected]>
Applied.
PATCH 9/9 : xt_conntrack: add compat support
In reply to Patrick McHardy[NETFILTER]: xt_conntrack: add compat support
---
commit 18a31ce74f45310a1133fadd17f36b879fd0221b
tree 2b0e1102cbb2625a350309348ac0b15a7b54db5d
parent e319b2005352790a24e1a91dc1af4b2f8643a876
author Patrick McHardy <[email protected]> Thu, 10 May 2007 15:39:08 +0200 committer Patrick McHardy <[email protected]> Thu, 10 May 2007 15:39:08 +0200
net/netfilter/xt_conntrack.c | 54 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 54 insertions(+), 0 deletions(-)
net/netfilter/xt_conntrack.c +54 -0
@@ -134,12 +134,66 @@ static void destroy(const struct xt_match *match, void *matchinfo)nf_ct_l3proto_module_put (match->family); } +#ifdef CONFIG_COMPAT +struct compat_xt_conntrack_info +{ +compat_uint_t statemask; +compat_uint_t statusmask; +struct ip_conntrack_old_tuple tuple[IP_CT_DIR_MAX ]; +struct in_addr sipmsk[IP_CT_DIR_MAX ]; +struct in_addr dipmsk[IP_CT_DIR_MAX ]; +compat_ulong_t expires_min; +compat_ulong_t expires_max; +u_int8_t flags; +u_int8_t invflags; +}; + +static void compat_from_user (void *dst,void *src) +{ +struct compat_xt_conntrack_info *cm = src; +struct xt_conntrack_info m = { + .statemask = cm->statemask, + .statusmask = cm->statusmask, + .expires_min = cm->expires_min, + .expires_max = cm->expires_max, + .flags = cm->flags, + .invflags = cm->invflags, + }; +memcpy (m.tuple, cm->tuple,sizeof (m.tuple)); +memcpy (m.sipmsk, cm->sipmsk,sizeof (m.sipmsk)); +memcpy (m.dipmsk, cm->dipmsk,sizeof (m.dipmsk)); +memcpy (dst, &m,sizeof (m)); +} + +static int compat_to_user (void __user *dst,void *src) +{ +struct xt_conntrack_info *m = src; +struct compat_xt_conntrack_info cm = { + .statemask = m->statemask, + .statusmask = m->statusmask, + .expires_min = m->expires_min, + .expires_max = m->expires_max, + .flags = m->flags, + .invflags = m->invflags, + }; +memcpy (cm.tuple, m->tuple,sizeof (cm.tuple)); +memcpy (cm.sipmsk, m->sipmsk,sizeof (cm.sipmsk)); +memcpy (cm.dipmsk, m->dipmsk,sizeof (cm.dipmsk)); +return copy_to_user (dst, &cm,sizeof (cm)) ? -EFAULT :0 ; +} +#endif +static struct xt_match conntrack_match = { .name ="conntrack" , .match = match, .checkentry = checkentry, .destroy = destroy, .matchsize =sizeof (struct xt_conntrack_info ), +#ifdef CONFIG_COMPAT + .compatsize =sizeof (struct compat_xt_conntrack_info ), + .compat_from_user = compat_from_user, + .compat_to_user = compat_to_user, +#endif .family =AF_INET , .me =THIS_MODULE , };
David Miller
maintainerRe: [NETFILTER 09/09]: xt_conntrack: add compat support
From: Patrick McHardy <[email protected]>
Date: Thu, 10 May 2007 15:41:22 +0200 (MEST)
Quoted 3 lines
[NETFILTER]:
xt_conntrack: add compat supportSigned-off-by Patrick McHardy <[email protected]>
Also applied, thanks a lot Patrick.