* [NETFILTER 00/09]: Netfilter patches
@ 2007-05-10 13:41 Patrick McHardy
2007-05-10 13:41 ` [NETFILTER 01/09]: Clean up table initialization Patrick McHardy
` (8 more replies)
0 siblings, 9 replies; 20+ messages in thread
From: Patrick McHardy @ 2007-05-10 13:41 UTC (permalink / raw)
To: davem; +Cc: netfilter-devel, Patrick McHardy
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
^ permalink raw reply [flat|nested] 20+ messages in thread* [NETFILTER 01/09]: Clean up table initialization 2007-05-10 13:41 [NETFILTER 00/09]: Netfilter patches Patrick McHardy @ 2007-05-10 13:41 ` Patrick McHardy 2007-05-10 21:14 ` David Miller 2007-05-10 13:41 ` [NETFILTER 02/09]: nf_nat: remove unused argument of function allocating binding Patrick McHardy ` (7 subsequent siblings) 8 siblings, 1 reply; 20+ messages in thread From: Patrick McHardy @ 2007-05-10 13:41 UTC (permalink / raw) To: davem; +Cc: netfilter-devel, Patrick McHardy [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 Signed-off-by: Patrick McHardy <kaber@trash.net> --- commit acf2e14c5f3ff9b9ad1500c135a8d9be98d66436 tree c3d814e7e64652f2ec2541e174b9a210ac1f2459 parent a989705c4cf6e6c1a339c95f9daf658b4ba88ca8 author Patrick McHardy <kaber@trash.net> Tue, 08 May 2007 11:06:17 +0200 committer Patrick McHardy <kaber@trash.net> 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(-) diff --git a/include/linux/netfilter/x_tables.h b/include/linux/netfilter/x_tables.h index 022edfa..7e733a6 100644 --- a/include/linux/netfilter/x_tables.h +++ b/include/linux/netfilter/x_tables.h @@ -54,6 +54,14 @@ struct xt_entry_target unsigned 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; diff --git a/include/linux/netfilter_arp/arp_tables.h b/include/linux/netfilter_arp/arp_tables.h index 24c8786..584cd1b 100644 --- a/include/linux/netfilter_arp/arp_tables.h +++ b/include/linux/netfilter_arp/arp_tables.h @@ -238,6 +238,47 @@ static __inline__ struct arpt_entry_target *arpt_get_target(struct arpt_entry *e */ #ifdef __KERNEL__ +/* Standard entry. */ +struct arpt_standard +{ + struct arpt_entry entry; + struct arpt_standard_target target; +}; + +struct arpt_error_target +{ + struct arpt_entry_target target; + char errorname[ARPT_FUNCTION_MAXNAMELEN]; +}; + +struct arpt_error +{ + struct arpt_entry entry; + struct arpt_error_target target; +}; + +#define ARPT_ENTRY_INIT(__size) \ +{ \ + .target_offset = sizeof(struct arpt_entry), \ + .next_offset = (__size), \ +} + +#define ARPT_STANDARD_INIT(__verdict) \ +{ \ + .entry = ARPT_ENTRY_INIT(sizeof(struct arpt_standard)), \ + .target = XT_TARGET_INIT(ARPT_STANDARD_TARGET, \ + sizeof(struct arpt_standard_target)), \ + .target.verdict = -(__verdict) - 1, \ +} + +#define ARPT_ERROR_INIT \ +{ \ + .entry = ARPT_ENTRY_INIT(sizeof(struct arpt_error)), \ + .target = XT_TARGET_INIT(ARPT_ERROR_TARGET, \ + sizeof(struct arpt_error_target)), \ + .target.errorname = "ERROR", \ +} + #define arpt_register_target(tgt) \ ({ (tgt)->family = NF_ARP; \ xt_register_target(tgt); }) diff --git a/include/linux/netfilter_ipv4/ip_tables.h b/include/linux/netfilter_ipv4/ip_tables.h index 9527296..2f46dd7 100644 --- a/include/linux/netfilter_ipv4/ip_tables.h +++ b/include/linux/netfilter_ipv4/ip_tables.h @@ -295,6 +295,28 @@ struct ipt_error struct 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, diff --git a/include/linux/netfilter_ipv6/ip6_tables.h b/include/linux/netfilter_ipv6/ip6_tables.h index 61aa104..4686f83 100644 --- a/include/linux/netfilter_ipv6/ip6_tables.h +++ b/include/linux/netfilter_ipv6/ip6_tables.h @@ -123,6 +123,28 @@ struct ip6t_error struct 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 diff --git a/net/ipv4/netfilter/arptable_filter.c b/net/ipv4/netfilter/arptable_filter.c index 7edea2a..75c0230 100644 --- a/net/ipv4/netfilter/arptable_filter.c +++ b/net/ipv4/netfilter/arptable_filter.c @@ -15,128 +15,34 @@ MODULE_DESCRIPTION("arptables filter table"); #define FILTER_VALID_HOOKS ((1 << NF_ARP_IN) | (1 << NF_ARP_OUT) | \ (1 << NF_ARP_FORWARD)) -/* Standard entry. */ -struct arpt_standard -{ - struct arpt_entry entry; - struct arpt_standard_target target; -}; - -struct arpt_error_target -{ - struct arpt_entry_target target; - char errorname[ARPT_FUNCTION_MAXNAMELEN]; -}; - -struct arpt_error -{ - struct arpt_entry entry; - struct arpt_error_target target; -}; - static struct { struct arpt_replace repl; struct arpt_standard entries[3]; struct arpt_error term; -} initial_table __initdata -= { { "filter", FILTER_VALID_HOOKS, 4, - sizeof(struct arpt_standard) * 3 + sizeof(struct arpt_error), - { [NF_ARP_IN] = 0, - [NF_ARP_OUT] = sizeof(struct arpt_standard), - [NF_ARP_FORWARD] = 2 * sizeof(struct arpt_standard), }, - { [NF_ARP_IN] = 0, - [NF_ARP_OUT] = sizeof(struct arpt_standard), - [NF_ARP_FORWARD] = 2 * sizeof(struct arpt_standard), }, - 0, NULL, { } }, - { - /* ARP_IN */ - { - { - { - { 0 }, { 0 }, { 0 }, { 0 }, - 0, 0, - { { 0, }, { 0, } }, - { { 0, }, { 0, } }, - 0, 0, - 0, 0, - 0, 0, - "", "", { 0 }, { 0 }, - 0, 0 - }, - sizeof(struct arpt_entry), - sizeof(struct arpt_standard), - 0, - { 0, 0 }, { } }, - { { { { ARPT_ALIGN(sizeof(struct arpt_standard_target)), "" } }, { } }, - -NF_ACCEPT - 1 } - }, - /* ARP_OUT */ - { - { - { - { 0 }, { 0 }, { 0 }, { 0 }, - 0, 0, - { { 0, }, { 0, } }, - { { 0, }, { 0, } }, - 0, 0, - 0, 0, - 0, 0, - "", "", { 0 }, { 0 }, - 0, 0 - }, - sizeof(struct arpt_entry), - sizeof(struct arpt_standard), - 0, - { 0, 0 }, { } }, - { { { { ARPT_ALIGN(sizeof(struct arpt_standard_target)), "" } }, { } }, - -NF_ACCEPT - 1 } - }, - /* ARP_FORWARD */ - { - { - { - { 0 }, { 0 }, { 0 }, { 0 }, - 0, 0, - { { 0, }, { 0, } }, - { { 0, }, { 0, } }, - 0, 0, - 0, 0, - 0, 0, - "", "", { 0 }, { 0 }, - 0, 0 - }, - sizeof(struct arpt_entry), - sizeof(struct arpt_standard), - 0, - { 0, 0 }, { } }, - { { { { ARPT_ALIGN(sizeof(struct arpt_standard_target)), "" } }, { } }, - -NF_ACCEPT - 1 } - } - }, - /* ERROR */ - { - { - { - { 0 }, { 0 }, { 0 }, { 0 }, - 0, 0, - { { 0, }, { 0, } }, - { { 0, }, { 0, } }, - 0, 0, - 0, 0, - 0, 0, - "", "", { 0 }, { 0 }, - 0, 0 - }, - sizeof(struct arpt_entry), - sizeof(struct arpt_error), - 0, - { 0, 0 }, { } }, - { { { { ARPT_ALIGN(sizeof(struct arpt_error_target)), ARPT_ERROR_TARGET } }, - { } }, - "ERROR" - } - } +} initial_table __initdata = { + .repl = { + .name = "filter", + .valid_hooks = FILTER_VALID_HOOKS, + .num_entries = 4, + .size = sizeof(struct arpt_standard) * 3 + sizeof(struct arpt_error), + .hook_entry = { + [NF_ARP_IN] = 0, + [NF_ARP_OUT] = sizeof(struct arpt_standard), + [NF_ARP_FORWARD] = 2 * sizeof(struct arpt_standard), + }, + .underflow = { + [NF_ARP_IN] = 0, + [NF_ARP_OUT] = sizeof(struct arpt_standard), + [NF_ARP_FORWARD] = 2 * sizeof(struct arpt_standard), + }, + }, + .entries = { + ARPT_STANDARD_INIT(NF_ACCEPT), /* ARP_IN */ + ARPT_STANDARD_INIT(NF_ACCEPT), /* ARP_OUT */ + ARPT_STANDARD_INIT(NF_ACCEPT), /* ARP_FORWARD */ + }, + .term = ARPT_ERROR_INIT, }; static struct arpt_table packet_filter = { diff --git a/net/ipv4/netfilter/iptable_filter.c b/net/ipv4/netfilter/iptable_filter.c index 4272890..ea14979 100644 --- a/net/ipv4/netfilter/iptable_filter.c +++ b/net/ipv4/netfilter/iptable_filter.c @@ -26,53 +26,29 @@ static struct struct ipt_replace repl; struct ipt_standard entries[3]; struct ipt_error term; -} initial_table __initdata -= { { "filter", FILTER_VALID_HOOKS, 4, - sizeof(struct ipt_standard) * 3 + sizeof(struct ipt_error), - { [NF_IP_LOCAL_IN] = 0, - [NF_IP_FORWARD] = sizeof(struct ipt_standard), - [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) * 2 }, - { [NF_IP_LOCAL_IN] = 0, - [NF_IP_FORWARD] = sizeof(struct ipt_standard), - [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) * 2 }, - 0, NULL, { } }, - { - /* LOCAL_IN */ - { { { { 0 }, { 0 }, { 0 }, { 0 }, "", "", { 0 }, { 0 }, 0, 0, 0 }, - 0, - sizeof(struct ipt_entry), - sizeof(struct ipt_standard), - 0, { 0, 0 }, { } }, - { { { { IPT_ALIGN(sizeof(struct ipt_standard_target)), "" } }, { } }, - -NF_ACCEPT - 1 } }, - /* FORWARD */ - { { { { 0 }, { 0 }, { 0 }, { 0 }, "", "", { 0 }, { 0 }, 0, 0, 0 }, - 0, - sizeof(struct ipt_entry), - sizeof(struct ipt_standard), - 0, { 0, 0 }, { } }, - { { { { IPT_ALIGN(sizeof(struct ipt_standard_target)), "" } }, { } }, - -NF_ACCEPT - 1 } }, - /* LOCAL_OUT */ - { { { { 0 }, { 0 }, { 0 }, { 0 }, "", "", { 0 }, { 0 }, 0, 0, 0 }, - 0, - sizeof(struct ipt_entry), - sizeof(struct ipt_standard), - 0, { 0, 0 }, { } }, - { { { { IPT_ALIGN(sizeof(struct ipt_standard_target)), "" } }, { } }, - -NF_ACCEPT - 1 } } - }, - /* ERROR */ - { { { { 0 }, { 0 }, { 0 }, { 0 }, "", "", { 0 }, { 0 }, 0, 0, 0 }, - 0, - sizeof(struct ipt_entry), - sizeof(struct ipt_error), - 0, { 0, 0 }, { } }, - { { { { IPT_ALIGN(sizeof(struct ipt_error_target)), IPT_ERROR_TARGET } }, - { } }, - "ERROR" - } - } +} initial_table __initdata = { + .repl = { + .name = "filter", + .valid_hooks = FILTER_VALID_HOOKS, + .num_entries = 4, + .size = sizeof(struct ipt_standard) * 3 + sizeof(struct ipt_error), + .hook_entry = { + [NF_IP_LOCAL_IN] = 0, + [NF_IP_FORWARD] = sizeof(struct ipt_standard), + [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) * 2, + }, + .underflow = { + [NF_IP_LOCAL_IN] = 0, + [NF_IP_FORWARD] = sizeof(struct ipt_standard), + [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) * 2, + }, + }, + .entries = { + IPT_STANDARD_INIT(NF_ACCEPT), /* LOCAL_IN */ + IPT_STANDARD_INIT(NF_ACCEPT), /* FORWARD */ + IPT_STANDARD_INIT(NF_ACCEPT), /* LOCAL_OUT */ + }, + .term = IPT_ERROR_INIT, /* ERROR */ }; static struct xt_table packet_filter = { diff --git a/net/ipv4/netfilter/iptable_mangle.c b/net/ipv4/netfilter/iptable_mangle.c index 9278802..c3827ba 100644 --- a/net/ipv4/netfilter/iptable_mangle.c +++ b/net/ipv4/netfilter/iptable_mangle.c @@ -33,73 +33,35 @@ static struct struct ipt_replace repl; struct ipt_standard entries[5]; struct ipt_error term; -} initial_table __initdata -= { { "mangle", MANGLE_VALID_HOOKS, 6, - sizeof(struct ipt_standard) * 5 + sizeof(struct ipt_error), - { [NF_IP_PRE_ROUTING] = 0, - [NF_IP_LOCAL_IN] = sizeof(struct ipt_standard), - [NF_IP_FORWARD] = sizeof(struct ipt_standard) * 2, - [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) * 3, - [NF_IP_POST_ROUTING] = sizeof(struct ipt_standard) * 4 }, - { [NF_IP_PRE_ROUTING] = 0, - [NF_IP_LOCAL_IN] = sizeof(struct ipt_standard), - [NF_IP_FORWARD] = sizeof(struct ipt_standard) * 2, - [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) * 3, - [NF_IP_POST_ROUTING] = sizeof(struct ipt_standard) * 4 }, - 0, NULL, { } }, - { - /* PRE_ROUTING */ - { { { { 0 }, { 0 }, { 0 }, { 0 }, "", "", { 0 }, { 0 }, 0, 0, 0 }, - 0, - sizeof(struct ipt_entry), - sizeof(struct ipt_standard), - 0, { 0, 0 }, { } }, - { { { { IPT_ALIGN(sizeof(struct ipt_standard_target)), "" } }, { } }, - -NF_ACCEPT - 1 } }, - /* LOCAL_IN */ - { { { { 0 }, { 0 }, { 0 }, { 0 }, "", "", { 0 }, { 0 }, 0, 0, 0 }, - 0, - sizeof(struct ipt_entry), - sizeof(struct ipt_standard), - 0, { 0, 0 }, { } }, - { { { { IPT_ALIGN(sizeof(struct ipt_standard_target)), "" } }, { } }, - -NF_ACCEPT - 1 } }, - /* FORWARD */ - { { { { 0 }, { 0 }, { 0 }, { 0 }, "", "", { 0 }, { 0 }, 0, 0, 0 }, - 0, - sizeof(struct ipt_entry), - sizeof(struct ipt_standard), - 0, { 0, 0 }, { } }, - { { { { IPT_ALIGN(sizeof(struct ipt_standard_target)), "" } }, { } }, - -NF_ACCEPT - 1 } }, - /* LOCAL_OUT */ - { { { { 0 }, { 0 }, { 0 }, { 0 }, "", "", { 0 }, { 0 }, 0, 0, 0 }, - 0, - sizeof(struct ipt_entry), - sizeof(struct ipt_standard), - 0, { 0, 0 }, { } }, - { { { { IPT_ALIGN(sizeof(struct ipt_standard_target)), "" } }, { } }, - -NF_ACCEPT - 1 } }, - /* POST_ROUTING */ - { { { { 0 }, { 0 }, { 0 }, { 0 }, "", "", { 0 }, { 0 }, 0, 0, 0 }, - 0, - sizeof(struct ipt_entry), - sizeof(struct ipt_standard), - 0, { 0, 0 }, { } }, - { { { { IPT_ALIGN(sizeof(struct ipt_standard_target)), "" } }, { } }, - -NF_ACCEPT - 1 } }, - }, - /* ERROR */ - { { { { 0 }, { 0 }, { 0 }, { 0 }, "", "", { 0 }, { 0 }, 0, 0, 0 }, - 0, - sizeof(struct ipt_entry), - sizeof(struct ipt_error), - 0, { 0, 0 }, { } }, - { { { { IPT_ALIGN(sizeof(struct ipt_error_target)), IPT_ERROR_TARGET } }, - { } }, - "ERROR" - } - } +} initial_table __initdata = { + .repl = { + .name = "mangle", + .valid_hooks = MANGLE_VALID_HOOKS, + .num_entries = 6, + .size = sizeof(struct ipt_standard) * 5 + sizeof(struct ipt_error), + .hook_entry = { + [NF_IP_PRE_ROUTING] = 0, + [NF_IP_LOCAL_IN] = sizeof(struct ipt_standard), + [NF_IP_FORWARD] = sizeof(struct ipt_standard) * 2, + [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) * 3, + [NF_IP_POST_ROUTING] = sizeof(struct ipt_standard) * 4, + }, + .underflow = { + [NF_IP_PRE_ROUTING] = 0, + [NF_IP_LOCAL_IN] = sizeof(struct ipt_standard), + [NF_IP_FORWARD] = sizeof(struct ipt_standard) * 2, + [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) * 3, + [NF_IP_POST_ROUTING] = sizeof(struct ipt_standard) * 4, + }, + }, + .entries = { + IPT_STANDARD_INIT(NF_ACCEPT), /* PRE_ROUTING */ + IPT_STANDARD_INIT(NF_ACCEPT), /* LOCAL_IN */ + IPT_STANDARD_INIT(NF_ACCEPT), /* FORWARD */ + IPT_STANDARD_INIT(NF_ACCEPT), /* LOCAL_OUT */ + IPT_STANDARD_INIT(NF_ACCEPT), /* POST_ROUTING */ + }, + .term = IPT_ERROR_INIT, /* ERROR */ }; static struct xt_table packet_mangler = { diff --git a/net/ipv4/netfilter/iptable_raw.c b/net/ipv4/netfilter/iptable_raw.c index 18c3d4c..f7d28fd 100644 --- a/net/ipv4/netfilter/iptable_raw.c +++ b/net/ipv4/netfilter/iptable_raw.c @@ -21,62 +21,18 @@ static struct .size = sizeof(struct ipt_standard) * 2 + sizeof(struct ipt_error), .hook_entry = { [NF_IP_PRE_ROUTING] = 0, - [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) }, + [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) + }, .underflow = { [NF_IP_PRE_ROUTING] = 0, - [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) }, + [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) + }, }, .entries = { - /* PRE_ROUTING */ - { - .entry = { - .target_offset = sizeof(struct ipt_entry), - .next_offset = sizeof(struct ipt_standard), - }, - .target = { - .target = { - .u = { - .target_size = IPT_ALIGN(sizeof(struct ipt_standard_target)), - }, - }, - .verdict = -NF_ACCEPT - 1, - }, - }, - - /* LOCAL_OUT */ - { - .entry = { - .target_offset = sizeof(struct ipt_entry), - .next_offset = sizeof(struct ipt_standard), - }, - .target = { - .target = { - .u = { - .target_size = IPT_ALIGN(sizeof(struct ipt_standard_target)), - }, - }, - .verdict = -NF_ACCEPT - 1, - }, - }, + IPT_STANDARD_INIT(NF_ACCEPT), /* PRE_ROUTING */ + IPT_STANDARD_INIT(NF_ACCEPT), /* LOCAL_OUT */ }, - /* ERROR */ - .term = { - .entry = { - .target_offset = sizeof(struct ipt_entry), - .next_offset = sizeof(struct ipt_error), - }, - .target = { - .target = { - .u = { - .user = { - .target_size = IPT_ALIGN(sizeof(struct ipt_error_target)), - .name = IPT_ERROR_TARGET, - }, - }, - }, - .errorname = "ERROR", - }, - } + .term = IPT_ERROR_INIT, /* ERROR */ }; static struct xt_table packet_raw = { diff --git a/net/ipv4/netfilter/nf_nat_rule.c b/net/ipv4/netfilter/nf_nat_rule.c index 2534f71..07e99e3 100644 --- a/net/ipv4/netfilter/nf_nat_rule.c +++ b/net/ipv4/netfilter/nf_nat_rule.c @@ -46,77 +46,20 @@ static struct .hook_entry = { [NF_IP_PRE_ROUTING] = 0, [NF_IP_POST_ROUTING] = sizeof(struct ipt_standard), - [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) * 2 }, + [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) * 2 + }, .underflow = { [NF_IP_PRE_ROUTING] = 0, [NF_IP_POST_ROUTING] = sizeof(struct ipt_standard), - [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) * 2 }, + [NF_IP_LOCAL_OUT] = sizeof(struct ipt_standard) * 2 + }, }, .entries = { - /* PRE_ROUTING */ - { - .entry = { - .target_offset = sizeof(struct ipt_entry), - .next_offset = sizeof(struct ipt_standard), - }, - .target = { - .target = { - .u = { - .target_size = IPT_ALIGN(sizeof(struct ipt_standard_target)), - }, - }, - .verdict = -NF_ACCEPT - 1, - }, - }, - /* POST_ROUTING */ - { - .entry = { - .target_offset = sizeof(struct ipt_entry), - .next_offset = sizeof(struct ipt_standard), - }, - .target = { - .target = { - .u = { - .target_size = IPT_ALIGN(sizeof(struct ipt_standard_target)), - }, - }, - .verdict = -NF_ACCEPT - 1, - }, - }, - /* LOCAL_OUT */ - { - .entry = { - .target_offset = sizeof(struct ipt_entry), - .next_offset = sizeof(struct ipt_standard), - }, - .target = { - .target = { - .u = { - .target_size = IPT_ALIGN(sizeof(struct ipt_standard_target)), - }, - }, - .verdict = -NF_ACCEPT - 1, - }, - }, + IPT_STANDARD_INIT(NF_ACCEPT), /* PRE_ROUTING */ + IPT_STANDARD_INIT(NF_ACCEPT), /* POST_ROUTING */ + IPT_STANDARD_INIT(NF_ACCEPT), /* LOCAL_OUT */ }, - /* ERROR */ - .term = { - .entry = { - .target_offset = sizeof(struct ipt_entry), - .next_offset = sizeof(struct ipt_error), - }, - .target = { - .target = { - .u = { - .user = { - .target_size = IPT_ALIGN(sizeof(struct ipt_error_target)), - .name = IPT_ERROR_TARGET, - }, - }, - }, - .errorname = "ERROR", - }, - } + .term = IPT_ERROR_INIT, /* ERROR */ }; static struct xt_table nat_table = { diff --git a/net/ipv6/netfilter/ip6table_filter.c b/net/ipv6/netfilter/ip6table_filter.c index 76f0cf6..7e32e2a 100644 --- a/net/ipv6/netfilter/ip6table_filter.c +++ b/net/ipv6/netfilter/ip6table_filter.c @@ -24,53 +24,29 @@ static struct struct ip6t_replace repl; struct ip6t_standard entries[3]; struct ip6t_error term; -} initial_table __initdata -= { { "filter", FILTER_VALID_HOOKS, 4, - sizeof(struct ip6t_standard) * 3 + sizeof(struct ip6t_error), - { [NF_IP6_LOCAL_IN] = 0, - [NF_IP6_FORWARD] = sizeof(struct ip6t_standard), - [NF_IP6_LOCAL_OUT] = sizeof(struct ip6t_standard) * 2 }, - { [NF_IP6_LOCAL_IN] = 0, - [NF_IP6_FORWARD] = sizeof(struct ip6t_standard), - [NF_IP6_LOCAL_OUT] = sizeof(struct ip6t_standard) * 2 }, - 0, NULL, { } }, - { - /* LOCAL_IN */ - { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 }, - 0, - sizeof(struct ip6t_entry), - sizeof(struct ip6t_standard), - 0, { 0, 0 }, { } }, - { { { { IP6T_ALIGN(sizeof(struct ip6t_standard_target)), "" } }, { } }, - -NF_ACCEPT - 1 } }, - /* FORWARD */ - { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 }, - 0, - sizeof(struct ip6t_entry), - sizeof(struct ip6t_standard), - 0, { 0, 0 }, { } }, - { { { { IP6T_ALIGN(sizeof(struct ip6t_standard_target)), "" } }, { } }, - -NF_ACCEPT - 1 } }, - /* LOCAL_OUT */ - { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 }, - 0, - sizeof(struct ip6t_entry), - sizeof(struct ip6t_standard), - 0, { 0, 0 }, { } }, - { { { { IP6T_ALIGN(sizeof(struct ip6t_standard_target)), "" } }, { } }, - -NF_ACCEPT - 1 } } - }, - /* ERROR */ - { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 }, - 0, - sizeof(struct ip6t_entry), - sizeof(struct ip6t_error), - 0, { 0, 0 }, { } }, - { { { { IP6T_ALIGN(sizeof(struct ip6t_error_target)), IP6T_ERROR_TARGET } }, - { } }, - "ERROR" - } - } +} initial_table __initdata = { + .repl = { + .name = "filter", + .valid_hooks = FILTER_VALID_HOOKS, + .num_entries = 4, + .size = sizeof(struct ip6t_standard) * 3 + sizeof(struct ip6t_error), + .hook_entry = { + [NF_IP6_LOCAL_IN] = 0, + [NF_IP6_FORWARD] = sizeof(struct ip6t_standard), + [NF_IP6_LOCAL_OUT] = sizeof(struct ip6t_standard) * 2 + }, + .underflow = { + [NF_IP6_LOCAL_IN] = 0, + [NF_IP6_FORWARD] = sizeof(struct ip6t_standard), + [NF_IP6_LOCAL_OUT] = sizeof(struct ip6t_standard) * 2 + }, + }, + .entries = { + IP6T_STANDARD_INIT(NF_ACCEPT), /* LOCAL_IN */ + IP6T_STANDARD_INIT(NF_ACCEPT), /* FORWARD */ + IP6T_STANDARD_INIT(NF_ACCEPT), /* LOCAL_OUT */ + }, + .term = IP6T_ERROR_INIT, /* ERROR */ }; static struct xt_table packet_filter = { diff --git a/net/ipv6/netfilter/ip6table_mangle.c b/net/ipv6/netfilter/ip6table_mangle.c index a9f10e3..f2d2649 100644 --- a/net/ipv6/netfilter/ip6table_mangle.c +++ b/net/ipv6/netfilter/ip6table_mangle.c @@ -32,73 +32,35 @@ static struct struct ip6t_replace repl; struct ip6t_standard entries[5]; struct ip6t_error term; -} initial_table __initdata -= { { "mangle", MANGLE_VALID_HOOKS, 6, - sizeof(struct ip6t_standard) * 5 + sizeof(struct ip6t_error), - { [NF_IP6_PRE_ROUTING] = 0, - [NF_IP6_LOCAL_IN] = sizeof(struct ip6t_standard), - [NF_IP6_FORWARD] = sizeof(struct ip6t_standard) * 2, - [NF_IP6_LOCAL_OUT] = sizeof(struct ip6t_standard) * 3, - [NF_IP6_POST_ROUTING] = sizeof(struct ip6t_standard) * 4}, - { [NF_IP6_PRE_ROUTING] = 0, - [NF_IP6_LOCAL_IN] = sizeof(struct ip6t_standard), - [NF_IP6_FORWARD] = sizeof(struct ip6t_standard) * 2, - [NF_IP6_LOCAL_OUT] = sizeof(struct ip6t_standard) * 3, - [NF_IP6_POST_ROUTING] = sizeof(struct ip6t_standard) * 4}, - 0, NULL, { } }, - { - /* PRE_ROUTING */ - { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 }, - 0, - sizeof(struct ip6t_entry), - sizeof(struct ip6t_standard), - 0, { 0, 0 }, { } }, - { { { { IP6T_ALIGN(sizeof(struct ip6t_standard_target)), "" } }, { } }, - -NF_ACCEPT - 1 } }, - /* LOCAL_IN */ - { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 }, - 0, - sizeof(struct ip6t_entry), - sizeof(struct ip6t_standard), - 0, { 0, 0 }, { } }, - { { { { IP6T_ALIGN(sizeof(struct ip6t_standard_target)), "" } }, { } }, - -NF_ACCEPT - 1 } }, - /* FORWARD */ - { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 }, - 0, - sizeof(struct ip6t_entry), - sizeof(struct ip6t_standard), - 0, { 0, 0 }, { } }, - { { { { IP6T_ALIGN(sizeof(struct ip6t_standard_target)), "" } }, { } }, - -NF_ACCEPT - 1 } }, - /* LOCAL_OUT */ - { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 }, - 0, - sizeof(struct ip6t_entry), - sizeof(struct ip6t_standard), - 0, { 0, 0 }, { } }, - { { { { IP6T_ALIGN(sizeof(struct ip6t_standard_target)), "" } }, { } }, - -NF_ACCEPT - 1 } }, - /* POST_ROUTING */ - { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 }, - 0, - sizeof(struct ip6t_entry), - sizeof(struct ip6t_standard), - 0, { 0, 0 }, { } }, - { { { { IP6T_ALIGN(sizeof(struct ip6t_standard_target)), "" } }, { } }, - -NF_ACCEPT - 1 } } - }, - /* ERROR */ - { { { { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, "", "", { 0 }, { 0 }, 0, 0, 0 }, - 0, - sizeof(struct ip6t_entry), - sizeof(struct ip6t_error), - 0, { 0, 0 }, { } }, - { { { { IP6T_ALIGN(sizeof(struct ip6t_error_target)), IP6T_ERROR_TARGET } }, - { } }, - "ERROR" - } - } +} initial_table __initdata = { + .repl = { + .name = "mangle", + .valid_hooks = MANGLE_VALID_HOOKS, + .num_entries = 6, + .size = sizeof(struct ip6t_standard) * 5 + sizeof(struct ip6t_error), + .hook_entry = { + [NF_IP6_PRE_ROUTING] = 0, + [NF_IP6_LOCAL_IN] = sizeof(struct ip6t_standard), + [NF_IP6_FORWARD] = sizeof(struct ip6t_standard) * 2, + [NF_IP6_LOCAL_OUT] = sizeof(struct ip6t_standard) * 3, + [NF_IP6_POST_ROUTING] = sizeof(struct ip6t_standard) * 4, + }, + .underflow = { + [NF_IP6_PRE_ROUTING] = 0, + [NF_IP6_LOCAL_IN] = sizeof(struct ip6t_standard), + [NF_IP6_FORWARD] = sizeof(struct ip6t_standard) * 2, + [NF_IP6_LOCAL_OUT] = sizeof(struct ip6t_standard) * 3, + [NF_IP6_POST_ROUTING] = sizeof(struct ip6t_standard) * 4, + }, + }, + .entries = { + IP6T_STANDARD_INIT(NF_ACCEPT), /* PRE_ROUTING */ + IP6T_STANDARD_INIT(NF_ACCEPT), /* LOCAL_IN */ + IP6T_STANDARD_INIT(NF_ACCEPT), /* FORWARD */ + IP6T_STANDARD_INIT(NF_ACCEPT), /* LOCAL_OUT */ + IP6T_STANDARD_INIT(NF_ACCEPT), /* POST_ROUTING */ + }, + .term = IP6T_ERROR_INIT, /* ERROR */ }; static struct xt_table packet_mangler = { diff --git a/net/ipv6/netfilter/ip6table_raw.c b/net/ipv6/netfilter/ip6table_raw.c index a3eb5b8..0acda45 100644 --- a/net/ipv6/netfilter/ip6table_raw.c +++ b/net/ipv6/netfilter/ip6table_raw.c @@ -35,56 +35,10 @@ static struct }, }, .entries = { - /* PRE_ROUTING */ - { - .entry = { - .target_offset = sizeof(struct ip6t_entry), - .next_offset = sizeof(struct ip6t_standard), - }, - .target = { - .target = { - .u = { - .target_size = IP6T_ALIGN(sizeof(struct ip6t_standard_target)), - }, - }, - .verdict = -NF_ACCEPT - 1, - }, - }, - - /* LOCAL_OUT */ - { - .entry = { - .target_offset = sizeof(struct ip6t_entry), - .next_offset = sizeof(struct ip6t_standard), - }, - .target = { - .target = { - .u = { - .target_size = IP6T_ALIGN(sizeof(struct ip6t_standard_target)), - }, - }, - .verdict = -NF_ACCEPT - 1, - }, - }, + IP6T_STANDARD_INIT(NF_ACCEPT), /* PRE_ROUTING */ + IP6T_STANDARD_INIT(NF_ACCEPT), /* LOCAL_OUT */ }, - /* ERROR */ - .term = { - .entry = { - .target_offset = sizeof(struct ip6t_entry), - .next_offset = sizeof(struct ip6t_error), - }, - .target = { - .target = { - .u = { - .user = { - .target_size = IP6T_ALIGN(sizeof(struct ip6t_error_target)), - .name = IP6T_ERROR_TARGET, - }, - }, - }, - .errorname = "ERROR", - }, - } + .term = IP6T_ERROR_INIT, /* ERROR */ }; static struct xt_table packet_raw = { ^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [NETFILTER 01/09]: Clean up table initialization 2007-05-10 13:41 ` [NETFILTER 01/09]: Clean up table initialization Patrick McHardy @ 2007-05-10 21:14 ` David Miller 0 siblings, 0 replies; 20+ messages in thread From: David Miller @ 2007-05-10 21:14 UTC (permalink / raw) To: kaber; +Cc: netfilter-devel From: Patrick McHardy <kaber@trash.net> Date: Thu, 10 May 2007 15:41:11 +0200 (MEST) > [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 > > Signed-off-by: Patrick McHardy <kaber@trash.net> Applied. ^ permalink raw reply [flat|nested] 20+ messages in thread
* [NETFILTER 02/09]: nf_nat: remove unused argument of function allocating binding 2007-05-10 13:41 [NETFILTER 00/09]: Netfilter patches Patrick McHardy 2007-05-10 13:41 ` [NETFILTER 01/09]: Clean up table initialization Patrick McHardy @ 2007-05-10 13:41 ` Patrick McHardy 2007-05-10 21:14 ` David Miller 2007-05-10 13:41 ` [NETFILTER 03/09]: nf_conntrack: Removes duplicated declarations Patrick McHardy ` (6 subsequent siblings) 8 siblings, 1 reply; 20+ messages in thread From: Patrick McHardy @ 2007-05-10 13:41 UTC (permalink / raw) To: davem; +Cc: netfilter-devel, 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. Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp> Signed-off-by: Patrick McHardy <kaber@trash.net> --- commit f1103257fddbe3a55b4ae964741cefb5026c20ec tree 32d30851ebdb14a2dfc5b7b10267b9700cf010d5 parent acf2e14c5f3ff9b9ad1500c135a8d9be98d66436 author Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp> Tue, 08 May 2007 11:06:17 +0200 committer Patrick McHardy <kaber@trash.net> 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(-) diff --git a/include/net/netfilter/nf_nat_rule.h b/include/net/netfilter/nf_nat_rule.h index e765654..f974318 100644 --- a/include/net/netfilter/nf_nat_rule.h +++ b/include/net/netfilter/nf_nat_rule.h @@ -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 */ diff --git a/net/ipv4/netfilter/nf_nat_rule.c b/net/ipv4/netfilter/nf_nat_rule.c index 07e99e3..6740736 100644 --- a/net/ipv4/netfilter/nf_nat_rule.c +++ b/net/ipv4/netfilter/nf_nat_rule.c @@ -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; } diff --git a/net/ipv4/netfilter/nf_nat_standalone.c b/net/ipv4/netfilter/nf_nat_standalone.c index 64bbed2..55dac36 100644 --- a/net/ipv4/netfilter/nf_nat_standalone.c +++ b/net/ipv4/netfilter/nf_nat_standalone.c @@ -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); } ^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [NETFILTER 02/09]: nf_nat: remove unused argument of function allocating binding 2007-05-10 13:41 ` [NETFILTER 02/09]: nf_nat: remove unused argument of function allocating binding Patrick McHardy @ 2007-05-10 21:14 ` David Miller 0 siblings, 0 replies; 20+ messages in thread From: David Miller @ 2007-05-10 21:14 UTC (permalink / raw) To: kaber; +Cc: netfilter-devel From: Patrick McHardy <kaber@trash.net> Date: Thu, 10 May 2007 15:41:12 +0200 (MEST) > [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. > > Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp> > Signed-off-by: Patrick McHardy <kaber@trash.net> Applied. ^ permalink raw reply [flat|nested] 20+ messages in thread
* [NETFILTER 03/09]: nf_conntrack: Removes duplicated declarations 2007-05-10 13:41 [NETFILTER 00/09]: Netfilter patches Patrick McHardy 2007-05-10 13:41 ` [NETFILTER 01/09]: Clean up table initialization Patrick McHardy 2007-05-10 13:41 ` [NETFILTER 02/09]: nf_nat: remove unused argument of function allocating binding Patrick McHardy @ 2007-05-10 13:41 ` Patrick McHardy 2007-05-10 21:15 ` David Miller 2007-05-10 13:41 ` [NETFILTER 04/09]: nf_conntrack: Removes unused destroy operation of l3proto Patrick McHardy ` (5 subsequent siblings) 8 siblings, 1 reply; 20+ messages in thread From: Patrick McHardy @ 2007-05-10 13:41 UTC (permalink / raw) To: davem; +Cc: netfilter-devel, Patrick McHardy [NETFILTER]: nf_conntrack: Removes duplicated declarations These are also in include/net/netfilter/nf_conntrack_helper.h Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp> Signed-off-by: Patrick McHardy <kaber@trash.net> --- commit aeca1c226efa93ec47d21303d907d7ab18c30f0e tree f35fccc4722bc6fe48e574e2c2596723bb01b673 parent f1103257fddbe3a55b4ae964741cefb5026c20ec author Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp> Tue, 08 May 2007 11:06:18 +0200 committer Patrick McHardy <kaber@trash.net> Tue, 08 May 2007 11:06:18 +0200 include/net/netfilter/nf_conntrack.h | 7 ------- 1 files changed, 0 insertions(+), 7 deletions(-) diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h index 1c6b8bd..4732432 100644 --- a/include/net/netfilter/nf_conntrack.h +++ b/include/net/netfilter/nf_conntrack.h @@ -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); ^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [NETFILTER 03/09]: nf_conntrack: Removes duplicated declarations 2007-05-10 13:41 ` [NETFILTER 03/09]: nf_conntrack: Removes duplicated declarations Patrick McHardy @ 2007-05-10 21:15 ` David Miller 0 siblings, 0 replies; 20+ messages in thread From: David Miller @ 2007-05-10 21:15 UTC (permalink / raw) To: kaber; +Cc: netfilter-devel From: Patrick McHardy <kaber@trash.net> Date: Thu, 10 May 2007 15:41:14 +0200 (MEST) > [NETFILTER]: nf_conntrack: Removes duplicated declarations > > These are also in include/net/netfilter/nf_conntrack_helper.h > > Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp> > Signed-off-by: Patrick McHardy <kaber@trash.net> Applied. ^ permalink raw reply [flat|nested] 20+ messages in thread
* [NETFILTER 04/09]: nf_conntrack: Removes unused destroy operation of l3proto 2007-05-10 13:41 [NETFILTER 00/09]: Netfilter patches Patrick McHardy ` (2 preceding siblings ...) 2007-05-10 13:41 ` [NETFILTER 03/09]: nf_conntrack: Removes duplicated declarations Patrick McHardy @ 2007-05-10 13:41 ` Patrick McHardy 2007-05-10 21:15 ` David Miller 2007-05-10 13:41 ` [NETFILTER 05/09]: ctnetlink: clear helper area and handle unchanged helper Patrick McHardy ` (4 subsequent siblings) 8 siblings, 1 reply; 20+ messages in thread From: Patrick McHardy @ 2007-05-10 13:41 UTC (permalink / raw) To: davem; +Cc: netfilter-devel, Patrick McHardy [NETFILTER]: nf_conntrack: Removes unused destroy operation of l3proto Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp> Signed-off-by: Patrick McHardy <kaber@trash.net> --- commit f1ab39bebc088ba296db8e047b21700b4a77d51c tree d3276fe947a35054a48f9ba00ec7a31e2d375432 parent aeca1c226efa93ec47d21303d907d7ab18c30f0e author Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp> Tue, 08 May 2007 11:06:18 +0200 committer Patrick McHardy <kaber@trash.net> 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(-) diff --git a/include/net/netfilter/nf_conntrack_l3proto.h b/include/net/netfilter/nf_conntrack_l3proto.h index f32f714..96a58d8 100644 --- a/include/net/netfilter/nf_conntrack_l3proto.h +++ b/include/net/netfilter/nf_conntrack_l3proto.h @@ -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 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c index e132c8a..94000a4 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c @@ -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) ^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [NETFILTER 04/09]: nf_conntrack: Removes unused destroy operation of l3proto 2007-05-10 13:41 ` [NETFILTER 04/09]: nf_conntrack: Removes unused destroy operation of l3proto Patrick McHardy @ 2007-05-10 21:15 ` David Miller 0 siblings, 0 replies; 20+ messages in thread From: David Miller @ 2007-05-10 21:15 UTC (permalink / raw) To: kaber; +Cc: netfilter-devel From: Patrick McHardy <kaber@trash.net> Date: Thu, 10 May 2007 15:41:15 +0200 (MEST) > [NETFILTER]: nf_conntrack: Removes unused destroy operation of l3proto > > Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp> > Signed-off-by: Patrick McHardy <kaber@trash.net> Applied. ^ permalink raw reply [flat|nested] 20+ messages in thread
* [NETFILTER 05/09]: ctnetlink: clear helper area and handle unchanged helper 2007-05-10 13:41 [NETFILTER 00/09]: Netfilter patches Patrick McHardy ` (3 preceding siblings ...) 2007-05-10 13:41 ` [NETFILTER 04/09]: nf_conntrack: Removes unused destroy operation of l3proto Patrick McHardy @ 2007-05-10 13:41 ` Patrick McHardy 2007-05-10 21:16 ` David Miller 2007-05-10 13:41 ` [NETFILTER 06/09]: nf_nat: Clears helper private area when NATing Patrick McHardy ` (3 subsequent siblings) 8 siblings, 1 reply; 20+ messages in thread From: Patrick McHardy @ 2007-05-10 13:41 UTC (permalink / raw) To: davem; +Cc: netfilter-devel, 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. Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp> Signed-off-by: Patrick McHardy <kaber@trash.net> --- commit 9655305aa47e326950ad24fc072ff19aaf5691f9 tree f8c4bc7c4772b99427327af7bf93007f82e8c69f parent f1ab39bebc088ba296db8e047b21700b4a77d51c author Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp> Tue, 08 May 2007 11:06:18 +0200 committer Patrick McHardy <kaber@trash.net> Tue, 08 May 2007 11:06:18 +0200 net/netfilter/nf_conntrack_netlink.c | 40 +++++++++++++++++++--------------- 1 files changed, 22 insertions(+), 18 deletions(-) diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c index aa1a97e..d6d39e2 100644 --- a/net/netfilter/nf_conntrack_netlink.c +++ b/net/netfilter/nf_conntrack_netlink.c @@ -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; ^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [NETFILTER 05/09]: ctnetlink: clear helper area and handle unchanged helper 2007-05-10 13:41 ` [NETFILTER 05/09]: ctnetlink: clear helper area and handle unchanged helper Patrick McHardy @ 2007-05-10 21:16 ` David Miller 0 siblings, 0 replies; 20+ messages in thread From: David Miller @ 2007-05-10 21:16 UTC (permalink / raw) To: kaber; +Cc: netfilter-devel From: Patrick McHardy <kaber@trash.net> Date: Thu, 10 May 2007 15:41:16 +0200 (MEST) > [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 <yasuyuki.kozakai@toshiba.co.jp> > Signed-off-by: Patrick McHardy <kaber@trash.net> Applied. ^ permalink raw reply [flat|nested] 20+ messages in thread
* [NETFILTER 06/09]: nf_nat: Clears helper private area when NATing 2007-05-10 13:41 [NETFILTER 00/09]: Netfilter patches Patrick McHardy ` (4 preceding siblings ...) 2007-05-10 13:41 ` [NETFILTER 05/09]: ctnetlink: clear helper area and handle unchanged helper Patrick McHardy @ 2007-05-10 13:41 ` Patrick McHardy 2007-05-10 21:16 ` David Miller 2007-05-10 13:41 ` [NETFILTER 07/09]: iptable_{filter, mangle}: more descriptive "happy cracking" message Patrick McHardy ` (2 subsequent siblings) 8 siblings, 1 reply; 20+ messages in thread From: Patrick McHardy @ 2007-05-10 13:41 UTC (permalink / raw) To: davem; +Cc: netfilter-devel, 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. Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp> Signed-off-by: Patrick McHardy <kaber@trash.net> --- commit 204674154410105c5b614101779698b439c2d864 tree c1d5f9835776353a1c53b7313f880ae4a6d8b2f1 parent 9655305aa47e326950ad24fc072ff19aaf5691f9 author Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp> Tue, 08 May 2007 11:06:19 +0200 committer Patrick McHardy <kaber@trash.net> Tue, 08 May 2007 11:06:19 +0200 net/netfilter/nf_conntrack_core.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c index 94000a4..e8b5c2d 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c @@ -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); ^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [NETFILTER 06/09]: nf_nat: Clears helper private area when NATing 2007-05-10 13:41 ` [NETFILTER 06/09]: nf_nat: Clears helper private area when NATing Patrick McHardy @ 2007-05-10 21:16 ` David Miller 0 siblings, 0 replies; 20+ messages in thread From: David Miller @ 2007-05-10 21:16 UTC (permalink / raw) To: kaber; +Cc: netfilter-devel From: Patrick McHardy <kaber@trash.net> Date: Thu, 10 May 2007 15:41:18 +0200 (MEST) > [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. > > Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp> > Signed-off-by: Patrick McHardy <kaber@trash.net> Applied. ^ permalink raw reply [flat|nested] 20+ messages in thread
* [NETFILTER 07/09]: iptable_{filter, mangle}: more descriptive "happy cracking" message 2007-05-10 13:41 [NETFILTER 00/09]: Netfilter patches Patrick McHardy ` (5 preceding siblings ...) 2007-05-10 13:41 ` [NETFILTER 06/09]: nf_nat: Clears helper private area when NATing Patrick McHardy @ 2007-05-10 13:41 ` Patrick McHardy 2007-05-10 21:17 ` [NETFILTER 07/09]: iptable_{filter,mangle}: " David Miller 2007-05-10 13:41 ` [NETFILTER 08/09]: iptable_raw: ignore short packets sent by SOCK_RAW sockets Patrick McHardy 2007-05-10 13:41 ` [NETFILTER 09/09]: xt_conntrack: add compat support Patrick McHardy 8 siblings, 1 reply; 20+ messages in thread From: Patrick McHardy @ 2007-05-10 13:41 UTC (permalink / raw) To: davem; +Cc: netfilter-devel, Patrick McHardy [NETFILTER]: iptable_{filter,mangle}: more descriptive "happy cracking" message Signed-off-by: Patrick McHardy <kaber@trash.net> --- commit 2a5f3d9533016d5f7914b75ea5f7a5fe98872f24 tree e20bd2440ccf6814b349fb00cee0941d63b31d61 parent 204674154410105c5b614101779698b439c2d864 author Patrick McHardy <kaber@trash.net> Thu, 10 May 2007 15:30:22 +0200 committer Patrick McHardy <kaber@trash.net> 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(-) diff --git a/net/ipv4/netfilter/iptable_filter.c b/net/ipv4/netfilter/iptable_filter.c index ea14979..4f51c1d 100644 --- a/net/ipv4/netfilter/iptable_filter.c +++ b/net/ipv4/netfilter/iptable_filter.c @@ -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; } diff --git a/net/ipv4/netfilter/iptable_mangle.c b/net/ipv4/netfilter/iptable_mangle.c index c3827ba..902446f 100644 --- a/net/ipv4/netfilter/iptable_mangle.c +++ b/net/ipv4/netfilter/iptable_mangle.c @@ -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; } ^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [NETFILTER 07/09]: iptable_{filter,mangle}: more descriptive "happy cracking" message 2007-05-10 13:41 ` [NETFILTER 07/09]: iptable_{filter, mangle}: more descriptive "happy cracking" message Patrick McHardy @ 2007-05-10 21:17 ` David Miller 2007-05-11 0:44 ` Patrick McHardy 0 siblings, 1 reply; 20+ messages in thread From: David Miller @ 2007-05-10 21:17 UTC (permalink / raw) To: kaber; +Cc: netfilter-devel From: Patrick McHardy <kaber@trash.net> Date: Thu, 10 May 2007 15:41:19 +0200 (MEST) > [NETFILTER]: iptable_{filter,mangle}: more descriptive "happy cracking" message > > Signed-off-by: Patrick McHardy <kaber@trash.net> In a way I'm very sad to see this message go away, but such is "progress", so applied ;-) ^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [NETFILTER 07/09]: iptable_{filter,mangle}: more descriptive "happy cracking" message 2007-05-10 21:17 ` [NETFILTER 07/09]: iptable_{filter,mangle}: " David Miller @ 2007-05-11 0:44 ` Patrick McHardy 0 siblings, 0 replies; 20+ messages in thread From: Patrick McHardy @ 2007-05-11 0:44 UTC (permalink / raw) To: David Miller; +Cc: netfilter-devel David Miller wrote: > From: Patrick McHardy <kaber@trash.net> > Date: Thu, 10 May 2007 15:41:19 +0200 (MEST) > > >>[NETFILTER]: iptable_{filter,mangle}: more descriptive "happy cracking" message >> >>Signed-off-by: Patrick McHardy <kaber@trash.net> > > > 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 :) ^ permalink raw reply [flat|nested] 20+ messages in thread
* [NETFILTER 08/09]: iptable_raw: ignore short packets sent by SOCK_RAW sockets 2007-05-10 13:41 [NETFILTER 00/09]: Netfilter patches Patrick McHardy ` (6 preceding siblings ...) 2007-05-10 13:41 ` [NETFILTER 07/09]: iptable_{filter, mangle}: more descriptive "happy cracking" message Patrick McHardy @ 2007-05-10 13:41 ` Patrick McHardy 2007-05-10 21:17 ` David Miller 2007-05-10 13:41 ` [NETFILTER 09/09]: xt_conntrack: add compat support Patrick McHardy 8 siblings, 1 reply; 20+ messages in thread From: Patrick McHardy @ 2007-05-10 13:41 UTC (permalink / raw) To: davem; +Cc: netfilter-devel, 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. Signed-off-by: Patrick McHardy <kaber@trash.net> --- commit e319b2005352790a24e1a91dc1af4b2f8643a876 tree 20b707b1bb83996c701f78745f18c75d3e06a3d0 parent 2a5f3d9533016d5f7914b75ea5f7a5fe98872f24 author Patrick McHardy <kaber@trash.net> Thu, 10 May 2007 15:38:16 +0200 committer Patrick McHardy <kaber@trash.net> Thu, 10 May 2007 15:38:16 +0200 net/ipv4/netfilter/iptable_raw.c | 21 ++++++++++++++++++++- 1 files changed, 20 insertions(+), 1 deletions(-) diff --git a/net/ipv4/netfilter/iptable_raw.c b/net/ipv4/netfilter/iptable_raw.c index f7d28fd..d6e5033 100644 --- a/net/ipv4/netfilter/iptable_raw.c +++ b/net/ipv4/netfilter/iptable_raw.c @@ -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, ^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [NETFILTER 08/09]: iptable_raw: ignore short packets sent by SOCK_RAW sockets 2007-05-10 13:41 ` [NETFILTER 08/09]: iptable_raw: ignore short packets sent by SOCK_RAW sockets Patrick McHardy @ 2007-05-10 21:17 ` David Miller 0 siblings, 0 replies; 20+ messages in thread From: David Miller @ 2007-05-10 21:17 UTC (permalink / raw) To: kaber; +Cc: netfilter-devel From: Patrick McHardy <kaber@trash.net> Date: Thu, 10 May 2007 15:41:20 +0200 (MEST) > [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. > > Signed-off-by: Patrick McHardy <kaber@trash.net> Applied. ^ permalink raw reply [flat|nested] 20+ messages in thread
* [NETFILTER 09/09]: xt_conntrack: add compat support 2007-05-10 13:41 [NETFILTER 00/09]: Netfilter patches Patrick McHardy ` (7 preceding siblings ...) 2007-05-10 13:41 ` [NETFILTER 08/09]: iptable_raw: ignore short packets sent by SOCK_RAW sockets Patrick McHardy @ 2007-05-10 13:41 ` Patrick McHardy 2007-05-10 21:18 ` David Miller 8 siblings, 1 reply; 20+ messages in thread From: Patrick McHardy @ 2007-05-10 13:41 UTC (permalink / raw) To: davem; +Cc: netfilter-devel, Patrick McHardy [NETFILTER]: xt_conntrack: add compat support Signed-off-by: Patrick McHardy <kaber@trash.net> --- commit 18a31ce74f45310a1133fadd17f36b879fd0221b tree 2b0e1102cbb2625a350309348ac0b15a7b54db5d parent e319b2005352790a24e1a91dc1af4b2f8643a876 author Patrick McHardy <kaber@trash.net> Thu, 10 May 2007 15:39:08 +0200 committer Patrick McHardy <kaber@trash.net> Thu, 10 May 2007 15:39:08 +0200 net/netfilter/xt_conntrack.c | 54 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 54 insertions(+), 0 deletions(-) diff --git a/net/netfilter/xt_conntrack.c b/net/netfilter/xt_conntrack.c index f4ea8fe..189ded5 100644 --- a/net/netfilter/xt_conntrack.c +++ b/net/netfilter/xt_conntrack.c @@ -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, }; ^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [NETFILTER 09/09]: xt_conntrack: add compat support 2007-05-10 13:41 ` [NETFILTER 09/09]: xt_conntrack: add compat support Patrick McHardy @ 2007-05-10 21:18 ` David Miller 0 siblings, 0 replies; 20+ messages in thread From: David Miller @ 2007-05-10 21:18 UTC (permalink / raw) To: kaber; +Cc: netfilter-devel From: Patrick McHardy <kaber@trash.net> Date: Thu, 10 May 2007 15:41:22 +0200 (MEST) > [NETFILTER]: xt_conntrack: add compat support > > Signed-off-by: Patrick McHardy <kaber@trash.net> Also applied, thanks a lot Patrick. ^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2007-05-11 0:44 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-10 13:41 [NETFILTER 00/09]: Netfilter patches Patrick McHardy
2007-05-10 13:41 ` [NETFILTER 01/09]: Clean up table initialization Patrick McHardy
2007-05-10 21:14 ` David Miller
2007-05-10 13:41 ` [NETFILTER 02/09]: nf_nat: remove unused argument of function allocating binding Patrick McHardy
2007-05-10 21:14 ` David Miller
2007-05-10 13:41 ` [NETFILTER 03/09]: nf_conntrack: Removes duplicated declarations Patrick McHardy
2007-05-10 21:15 ` David Miller
2007-05-10 13:41 ` [NETFILTER 04/09]: nf_conntrack: Removes unused destroy operation of l3proto Patrick McHardy
2007-05-10 21:15 ` David Miller
2007-05-10 13:41 ` [NETFILTER 05/09]: ctnetlink: clear helper area and handle unchanged helper Patrick McHardy
2007-05-10 21:16 ` David Miller
2007-05-10 13:41 ` [NETFILTER 06/09]: nf_nat: Clears helper private area when NATing Patrick McHardy
2007-05-10 21:16 ` David Miller
2007-05-10 13:41 ` [NETFILTER 07/09]: iptable_{filter, mangle}: more descriptive "happy cracking" message Patrick McHardy
2007-05-10 21:17 ` [NETFILTER 07/09]: iptable_{filter,mangle}: " David Miller
2007-05-11 0:44 ` Patrick McHardy
2007-05-10 13:41 ` [NETFILTER 08/09]: iptable_raw: ignore short packets sent by SOCK_RAW sockets Patrick McHardy
2007-05-10 21:17 ` David Miller
2007-05-10 13:41 ` [NETFILTER 09/09]: xt_conntrack: add compat support Patrick McHardy
2007-05-10 21:18 ` David Miller
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.