Patches for 2.6.26
Subsystems (6)
Rebased against net-2.6.26/master (f0bdb7b). There were some changes regarding netns, which were likely the cause of your most recent merge attempts/conflicts.
N.B. I needed a command no less than 3 lines to get it done... guess what options should be made default :^)
rm -f 00*; git-format-patch -C -M --stat=72 --summary -p --thread -n 455b3b0^..HEAD && git-send-email --suppress-from --no-chain --compose --to kaber --cc netfilter-devel 00*
PATCH 1/24 : remove arpt_table indirection macro
--- include/linux/netfilter_arp/arp_tables.h | 11 ++++----- net/ipv4/netfilter/arp_tables.c | 27 ++++++++++----------- net/ipv4/netfilter/arptable_filter.c | 2 +- 3 files changed, 19 insertions(+), 21 deletions(-)
include/linux/netfilter_arp/arp_tables.h +5 -6
@@ -24,7 +24,6 @@#define ARPT_FUNCTION_MAXNAMELEN XT_FUNCTION_MAXNAMELEN#define ARPT_TABLE_MAXNAMELEN XT_TABLE_MAXNAMELEN#define arpt_target xt_target -#define arpt_table xt_table#define ARPT_DEV_ADDR_LEN_MAX 16
@@ -271,15 +270,15 @@ struct arpt_error xt_register_target(tgt); })#define arpt_unregister_target (tgt) xt_unregister_target(tgt) -extern struct arpt_table *arpt_register_table (struct net *net, -struct arpt_table *table, -const struct arpt_replace *repl); -extern void arpt_unregister_table (struct arpt_table *table); +extern struct xt_table * +arpt_register_table (struct net *net,struct xt_table *table, +const struct arpt_replace *repl); +extern void arpt_unregister_table (struct xt_table *table);extern unsigned int arpt_do_table (struct sk_buff *skb,unsigned int hook,const struct net_device *in,const struct net_device *out, -struct arpt_table *table); +struct xt_table *table);#define ARPT_ALIGN (s) XT_ALIGN(s)
net/ipv4/netfilter/arp_tables.c +13 -14
@@ -222,7 +222,7 @@ unsigned int arpt_do_table(struct sk_buff *skb,unsigned int hook, const struct net_device *in, const struct net_device *out, - struct arpt_table *table) + struct xt_table *table) { static const char nulldevname[IFNAMSIZ];unsigned int verdict =NF_DROP ;
@@ -706,7 +706,7 @@ static void get_counters(const struct xt_table_info *t, } } -static inline struct xt_counters *alloc_counters (struct arpt_table *table) +static inline struct xt_counters *alloc_counters (struct xt_table *table) {unsigned int countersize;struct xt_counters *counters;
@@ -731,13 +731,13 @@ static inline struct xt_counters *alloc_counters(struct arpt_table *table) }static int copy_entries_to_user (unsigned int total_size, -struct arpt_table *table, +struct xt_table *table,void __user *userptr) {unsigned int off, num;struct arpt_entry *e;struct xt_counters *counters; -const struct xt_table_info *private = table->private; +struct xt_table_info *private = table->private;int ret =0 ;void *loc_cpu_entry;
@@ -851,7 +851,7 @@ static int compat_table_info(const struct xt_table_info *info,static int get_info (struct net *net,void __user *user,int *len,int compat) {char name[ARPT_TABLE_MAXNAMELEN ]; -struct arpt_table *t; +struct xt_table *t;int ret;if (*len !=sizeof (struct arpt_getinfo )) {
@@ -911,7 +911,7 @@ static int get_entries(struct net *net, struct arpt_get_entries __user *uptr, {int ret;struct arpt_get_entries get; -struct arpt_table *t; +struct xt_table *t;if (*len <sizeof (get)) {duprintf ("get_entries: %u < %Zu\n" , *len,sizeof (get));
@@ -954,7 +954,7 @@ static int __do_replace(struct net *net, const char *name, void __user *counters_ptr) {int ret; -struct arpt_table *t; +struct xt_table *t;struct xt_table_info *oldinfo;struct xt_counters *counters;void *loc_cpu_old_entry;
@@ -1091,7 +1091,7 @@ static int do_add_counters(struct net *net, void __user *user, unsigned int len,const char *name;int size;void *ptmp; -struct arpt_table *t; +struct xt_table *t;const struct xt_table_info *private;int ret =0 ;void *loc_cpu_entry;
@@ -1555,7 +1555,7 @@ out: }static int compat_copy_entries_to_user (unsigned int total_size, -struct arpt_table *table, +struct xt_table *table,void __user *userptr) {struct xt_counters *counters;
@@ -1593,7 +1593,7 @@ static int compat_get_entries(struct net *net, {int ret;struct compat_arpt_get_entries get; -struct arpt_table *t; +struct xt_table *t;if (*len <sizeof (get)) {duprintf ("compat_get_entries: %u < %zu\n" , *len,sizeof (get));
@@ -1723,9 +1723,8 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *lenreturn ret; } -struct arpt_table *arpt_register_table (struct net *net, -struct arpt_table *table, -const struct arpt_replace *repl) +struct xt_table *arpt_register_table (struct net *net,struct xt_table *table, +const struct arpt_replace *repl) {int ret;struct xt_table_info *newinfo;
@@ -1767,7 +1766,7 @@ out:return ERR_PTR (ret); } -void arpt_unregister_table (struct arpt_table *table) +void arpt_unregister_table (struct xt_table *table) {struct xt_table_info *private;void *loc_cpu_entry;
net/ipv4/netfilter/arptable_filter.c +1 -1
@@ -45,7 +45,7 @@ static struct .term = ARPT_ERROR_INIT, }; -static struct arpt_table packet_filter = { +static struct xt_table packet_filter = { .name ="filter" , .valid_hooks =FILTER_VALID_HOOKS , .lock =RW_LOCK_UNLOCKED ,
Signature · 1 line
1.5.4.4
Patrick McHardy
AppliedRe: [PATCH 01/24] [NETFILTER]: remove arpt_table indirection macro
Quoted 5 lines · Jan Engelhardt
Signed-off-by Jan Engelhardt <[email protected]>--- include/linux/netfilter_arp/arp_tables.h | 11 ++++----- net/ipv4/netfilter/arp_tables.c | 27 ++++++++++----------- net/ipv4/netfilter/arptable_filter.c | 2 +-
Applied.
PATCH 2/24 : remove arpt_target indirection macro
In reply to Jan Engelhardt--- include/linux/netfilter_arp/arp_tables.h | 1 - net/ipv4/netfilter/arp_tables.c | 8 ++++---- net/ipv4/netfilter/arpt_mangle.c | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-)
include/linux/netfilter_arp/arp_tables.h +0 -1
@@ -23,7 +23,6 @@#define ARPT_FUNCTION_MAXNAMELEN XT_FUNCTION_MAXNAMELEN#define ARPT_TABLE_MAXNAMELEN XT_TABLE_MAXNAMELEN -#define arpt_target xt_target#define ARPT_DEV_ADDR_LEN_MAX 16
net/ipv4/netfilter/arp_tables.c +4 -4
@@ -457,7 +457,7 @@ static inline int check_entry(struct arpt_entry *e, const char *name)static inline int check_target (struct arpt_entry *e,const char *name) {struct arpt_entry_target *t; -struct arpt_target *target; +struct xt_target *target;int ret; t =arpt_get_target (e);
@@ -480,7 +480,7 @@ find_check_entry(struct arpt_entry *e, const char *name, unsigned int size, unsigned int *i) {struct arpt_entry_target *t; -struct arpt_target *target; +struct xt_target *target;int ret; ret =check_entry (e, name);
@@ -1784,7 +1784,7 @@ void arpt_unregister_table(struct xt_table *table) }/* The built-in targets: standard (NULL) and error. */ -static struct arpt_target arpt_standard_target__read_mostly = { +static struct xt_target arpt_standard_target__read_mostly = { .name =ARPT_STANDARD_TARGET , .targetsize =sizeof (int ), .family =NF_ARP ,
@@ -1795,7 +1795,7 @@ static struct arpt_target arpt_standard_target __read_mostly = {#endif }; -static struct arpt_target arpt_error_target__read_mostly = { +static struct xt_target arpt_error_target__read_mostly = { .name =ARPT_ERROR_TARGET , .target = arpt_error, .targetsize =ARPT_FUNCTION_MAXNAMELEN ,
net/ipv4/netfilter/arpt_mangle.c +1 -1
@@ -73,7 +73,7 @@ checkentry(const char *tablename, const void *e, const struct xt_target *target,return true; } -static struct arpt_target arpt_mangle_reg__read_mostly = { +static struct xt_target arpt_mangle_reg__read_mostly = { .name ="mangle" , .target = target, .targetsize =sizeof (struct arpt_mangle ),
Signature · 1 line
1.5.4.4
Patrick McHardy
AppliedRe: [PATCH 02/24] [NETFILTER]: remove arpt_target indirection macro
Quoted 5 lines · Jan Engelhardt
Signed-off-by Jan Engelhardt <[email protected]>--- include/linux/netfilter_arp/arp_tables.h | 1 - net/ipv4/netfilter/arp_tables.c | 8 ++++---- net/ipv4/netfilter/arpt_mangle.c | 2 +-
Applied.
PATCH 3/24 : remove ARPT_{STANDARD,ERROR}_TARGET indirection macro
In reply to Jan Engelhardt--- include/linux/netfilter_arp/arp_tables.h | 9 ++------- net/ipv4/netfilter/arp_tables.c | 8 ++++---- 2 files changed, 6 insertions(+), 11 deletions(-)
include/linux/netfilter_arp/arp_tables.h +2 -7
@@ -203,11 +203,6 @@ struct arpt_get_entriesstruct arpt_entry entrytable[0 ]; }; -/* Standard return verdict, or do jump. */ -#define ARPT_STANDARD_TARGET XT_STANDARD_TARGET -/* Error verdict. */ -#define ARPT_ERROR_TARGET XT_ERROR_TARGET -/* Helper functions */ static __inline__struct arpt_entry_target *arpt_get_target (struct arpt_entry *e) {
@@ -251,7 +246,7 @@ struct arpt_error#define ARPT_STANDARD_INIT (__verdict) \ { \ .entry = ARPT_ENTRY_INIT(sizeof(struct arpt_standard)), \ - .target = XT_TARGET_INIT(ARPT_STANDARD_TARGET, \ + .target = XT_TARGET_INIT(XT_STANDARD_TARGET, \ sizeof(struct arpt_standard_target)), \ .target.verdict = -(__verdict) - 1, \ }
@@ -259,7 +254,7 @@ struct arpt_error#define ARPT_ERROR_INIT \ { \ .entry = ARPT_ENTRY_INIT(sizeof(struct arpt_error)), \ - .target = XT_TARGET_INIT(ARPT_ERROR_TARGET, \ + .target = XT_TARGET_INIT(XT_ERROR_TARGET, \ sizeof(struct arpt_error_target)), \ .target.errorname = "ERROR", \ }
net/ipv4/netfilter/arp_tables.c +4 -4
@@ -367,7 +367,7 @@ static int mark_source_chains(struct xt_table_info *newinfo,/* Unconditional return/END. */ if ((e->target_offset ==sizeof (struct arpt_entry ) && (strcmp (t->target.u.user.name, -ARPT_STANDARD_TARGET ) ==0 ) +XT_STANDARD_TARGET ) ==0 ) && t->verdict <0 &&unconditional (&e->arp)) || visited) {unsigned int oldpos, size;
@@ -406,7 +406,7 @@ static int mark_source_chains(struct xt_table_info *newinfo,int newpos = t->verdict;if (strcmp (t->target.u.user.name, -ARPT_STANDARD_TARGET ) ==0 +XT_STANDARD_TARGET ) ==0 && newpos >=0 ) {if (newpos > newinfo->size -sizeof (struct arpt_entry )) {
@@ -1785,7 +1785,7 @@ void arpt_unregister_table(struct xt_table *table)/* The built-in targets: standard (NULL) and error. */ static struct xt_target arpt_standard_target__read_mostly = { - .name =ARPT_STANDARD_TARGET , + .name =XT_STANDARD_TARGET , .targetsize =sizeof (int ), .family =NF_ARP , #ifdef CONFIG_COMPAT
@@ -1796,7 +1796,7 @@ static struct xt_target arpt_standard_target __read_mostly = { };static struct xt_target arpt_error_target__read_mostly = { - .name =ARPT_ERROR_TARGET , + .name =XT_ERROR_TARGET , .target = arpt_error, .targetsize =ARPT_FUNCTION_MAXNAMELEN , .family =NF_ARP ,
Signature · 1 line
1.5.4.4
Patrick McHardy
AppliedRe: [PATCH 03/24] [NETFILTER]: remove ARPT_{STANDARD,ERROR}_TARGET indirection macro
Quoted 4 lines · Jan Engelhardt
Signed-off-by Jan Engelhardt <[email protected]>--- include/linux/netfilter_arp/arp_tables.h | 9 ++------- net/ipv4/netfilter/arp_tables.c | 8 ++++----
Applied.
PATCH 4/24 : remove unused ARPT_ALIGN indirection macros
In reply to Jan Engelhardt--- include/linux/netfilter_arp/arp_tables.h | 4 ---- 1 files changed, 0 insertions(+), 4 deletions(-)
include/linux/netfilter_arp/arp_tables.h +0 -4
@@ -274,8 +274,6 @@ extern unsigned int arpt_do_table(struct sk_buff *skb,const struct net_device *out, struct xt_table *table); -#define ARPT_ALIGN (s) XT_ALIGN(s) -#ifdef CONFIG_COMPAT #include <net/compat.h>
@@ -295,8 +293,6 @@ compat_arpt_get_target(struct compat_arpt_entry *e)return (void *)e + e->target_offset; } -#define COMPAT_ARPT_ALIGN (s) COMPAT_XT_ALIGN(s) -/* fn returns 0 to continue iteration */ #define COMPAT_ARPT_ENTRY_ITERATE(entries, size, fn, args...) \ XT_ENTRY_ITERATE(struct compat_arpt_entry, entries, size, fn, ## args)
Signature · 1 line
1.5.4.4
Re: [PATCH 04/24] [NETFILTER]: remove unused ARPT_ALIGN indirection macros
Quoted 10 lines · Jan Engelhardt
Signed-off-by Jan Engelhardt <[email protected]>--- include/linux/netfilter_arp/arp_tables.h | 4 ---- 1 files changed, 0 insertions(+), 4 deletions(-)include/linux/netfilter_arp/arp_tables.h +0
-0
include/linux/netfilter_arp/arp_tables.h extern unsigned int arpt_do_table(struct sk_buff *skb, · line 277
Quoted 4 lines
include/linux/netfilter_arp/arp_tables.h +0
-1@@ -274,8 +274,6 @@ extern unsigned int arpt_do_table(struct sk_buff *skb,const struct net_device *out, struct xt_table *table); -#define ARPT_ALIGN (s) XT_ALIGN(s)
This is exported to userspace, so I can't apply this. I'm also reverting 03/24 since that also breaks userspace.
Re: [PATCH 04/24] [NETFILTER]: remove unused ARPT_ALIGN indirection macros
Quoted 15 lines · Patrick McHardy
Quoted 14 lines · Jan Engelhardt
Signed-off-by Jan Engelhardt <[email protected]>---
include/linux/netfilter_arp/arp_tables.h | 4 ---- 1 files changed, 0 insertions(+), 4 deletions(-)diff --git
a/include/linux/netfilter_arp/arp_tables.hb/include/linux/netfilter_arp/arp_tables.h
index 0e6b5e1..1cb698b 100644
---a/include/linux/netfilter_arp/arp_tables.h
+++b/include/linux/netfilter_arp/arp_tables.h
@@ -274,8 +274,6 @@ extern unsigned int arpt_do_table(structsk_buff*skb,
const structnet_device*out,
structxt_table*table);
Quoted 4 lines
Quoted 1 line
-#define
ARPT_ALIGN(s)XT_ALIGN(s)This is exported to userspace, so I can't apply this. I'm also reverting 03/24 since that also breaks userspace.
I would not expect anything but arptables to use these macros; and actually arptables has its own copies of the .h files much like iptables does. Just my 13 cents.
Re: [PATCH 04/24] [NETFILTER]: remove unused ARPT_ALIGN indirection macros
Quoted 18 lines · Jan Engelhardt
Quoted 16 lines · Patrick McHardy
Quoted 15 lines · Jan Engelhardt
Signed-off-by Jan Engelhardt <[email protected]>---
include/linux/netfilter_arp/arp_tables.h | 4 ---- 1 files changed, 0 insertions(+), 4 deletions(-)diff --git
a/include/linux/netfilter_arp/arp_tables.hb/include/linux/netfilter_arp/arp_tables.h
index 0e6b5e1..1cb698b 100644
---a/include/linux/netfilter_arp/arp_tables.h
+++b/include/linux/netfilter_arp/arp_tables.h
@@ -274,8 +274,6 @@ extern unsigned int arpt_do_table(structsk_buff
*skb,
const structnet_device*out,
structxt_table*table);
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
-#define
ARPT_ALIGN(s)XT_ALIGN(s)This is exported to userspace, so I can't apply this. I'm also reverting 03/24 since that also breaks userspace.
I would not expect anything but arptables to use these macros; and actually arptables has its own copies of the .h files much like iptables does. Just my 13 cents.
I wouldn't be so sure of that, there also have been other programs using the iptables API, besides the fact that arptables can also be compiled against the current headers. Speculation is not enough for breaking an interface, sorry.
PATCH 5/24 : remove arpt_(un)register_target indirection macros
In reply to Jan Engelhardt--- include/linux/netfilter_arp/arp_tables.h | 5 ----- net/ipv4/netfilter/arpt_mangle.c | 8 +++----- 2 files changed, 3 insertions(+), 10 deletions(-)
include/linux/netfilter_arp/arp_tables.h +0 -5
@@ -259,11 +259,6 @@ struct arpt_error .target.errorname = "ERROR", \ } -#define arpt_register_target (tgt) \ -({ (tgt)->family = NF_ARP; \ - xt_register_target(tgt); }) -#define arpt_unregister_target (tgt) xt_unregister_target(tgt) -extern struct xt_table *arpt_register_table (struct net *net,struct xt_table *table,const struct arpt_replace *repl);
net/ipv4/netfilter/arpt_mangle.c +3 -5
@@ -75,6 +75,7 @@ checkentry(const char *tablename, const void *e, const struct xt_target *target,static struct xt_target arpt_mangle_reg__read_mostly = { .name ="mangle" , + .family =NF_ARP , .target = target, .targetsize =sizeof (struct arpt_mangle ), .checkentry = checkentry,
@@ -83,15 +84,12 @@ static struct xt_target arpt_mangle_reg __read_mostly = {static int __init arpt_mangle_init (void ) { -if (arpt_register_target (&arpt_mangle_reg)) -return -EINVAL ; - -return 0 ; +return xt_register_target (&arpt_mangle_reg); } static void __exit arpt_mangle_fini(void) { -arpt_unregister_target (&arpt_mangle_reg); +xt_unregister_target (&arpt_mangle_reg); }module_init (arpt_mangle_init);
Signature · 1 line
1.5.4.4
Patrick McHardy
AppliedRe: [PATCH 05/24] [NETFILTER]: remove arpt_(un)register_target indirection macros
Quoted 5 lines · Jan Engelhardt
Signed-off-by Jan Engelhardt <[email protected]>--- include/linux/netfilter_arp/arp_tables.h | 5 ----- net/ipv4/netfilter/arpt_mangle.c | 8 +++----- 2 files changed, 3 insertions(+), 10 deletions(-)
Applied.
PATCH 6/24 : remove ARPT_{CONTINUE,RETURN} indirection macros
In reply to Jan Engelhardt--- include/linux/netfilter_arp/arp_tables.h | 6 ------ net/ipv4/netfilter/arp_tables.c | 6 +++--- net/ipv4/netfilter/arpt_mangle.c | 2 +- 3 files changed, 4 insertions(+), 10 deletions(-)
include/linux/netfilter_arp/arp_tables.h +0 -6
@@ -125,12 +125,6 @@ struct arpt_entry#define ARPT_SO_GET_REVISION_TARGET (ARPT_BASE_CTL + 3)#define ARPT_SO_GET_MAX (ARPT_SO_GET_REVISION_TARGET) -/* CONTINUE verdict for targets */ -#define ARPT_CONTINUE XT_CONTINUE - -/* For standard target */ -#define ARPT_RETURN XT_RETURN -/* The argument to ARPT_SO_GET_INFO */ struct arpt_getinfo {
net/ipv4/netfilter/arp_tables.c +3 -3
@@ -264,7 +264,7 @@ unsigned int arpt_do_table(struct sk_buff *skb, v = ((struct arpt_standard_target *)t)->verdict;if (v <0 ) {/* Pop from stack? */ -if (v !=ARPT_RETURN ) { +if (v !=XT_RETURN ) { verdict = (unsigned )(-v) -1 ;break ; }
@@ -299,7 +299,7 @@ unsigned int arpt_do_table(struct sk_buff *skb,/* Target might have changed stuff. */ arp =arp_hdr (skb); -if (verdict ==ARPT_CONTINUE ) +if (verdict ==XT_CONTINUE ) e = (void *)e + e->next_offset;else /* Verdict */
@@ -542,7 +542,7 @@ static inline int check_entry_size_and_hooks(struct arpt_entry *e, }/* FIXME: underflows must be unconditional, standard verdicts -< 0 (not ARPT_RETURN). --RR */ +< 0 (not XT_RETURN). --RR */ /* Clear counters and comefrom */ e->counters = ((struct xt_counters ) {0 ,0 });
net/ipv4/netfilter/arpt_mangle.c +1 -1
@@ -68,7 +68,7 @@ checkentry(const char *tablename, const void *e, const struct xt_target *target,return false;if (mangle->target !=NF_DROP && mangle->target !=NF_ACCEPT && - mangle->target !=ARPT_CONTINUE ) + mangle->target !=XT_CONTINUE )return false;return true; }
Signature · 1 line
1.5.4.4
Re: [PATCH 06/24] [NETFILTER]: remove ARPT_{CONTINUE,RETURN} indirection macros
Quoted 12 lines · Jan Engelhardt
Signed-off-by Jan Engelhardt <[email protected]>--- include/linux/netfilter_arp/arp_tables.h | 6 ------ net/ipv4/netfilter/arp_tables.c | 6 +++--- net/ipv4/netfilter/arpt_mangle.c | 2 +- 3 files changed, 4 insertions(+), 10 deletions(-)include/linux/netfilter_arp/arp_tables.h +0
-0
include/linux/netfilter_arp/arp_tables.h struct arpt_entry · line 132
Quoted 8 lines
include/linux/netfilter_arp/arp_tables.h +0
-5@@ -125,12 +125,6 @@ struct arpt_entry#define ARPT_SO_GET_REVISION_TARGET (ARPT_BASE_CTL + 3)#define ARPT_SO_GET_MAX (ARPT_SO_GET_REVISION_TARGET) -/* CONTINUE verdict for targets */ -#define ARPT_CONTINUE XT_CONTINUE - -/* For standard target */ -#define ARPT_RETURN XT_RETURN
These are also used by userspace.
PATCH 7/24 : remove ARPT_{CONTINUE,RETURN} indirection macros
In reply to Jan Engelhardt--- include/linux/netfilter_arp/arp_tables.h | 4 ---- 1 files changed, 0 insertions(+), 4 deletions(-)
include/linux/netfilter_arp/arp_tables.h +0 -4
@@ -180,10 +180,6 @@ struct arpt_replacestruct arpt_entry entries[0 ]; }; -/* The argument to ARPT_SO_ADD_COUNTERS. */ -#define arpt_counters_info xt_counters_info -#define arpt_counters xt_counters -/* The argument to ARPT_SO_GET_ENTRIES. */ struct arpt_get_entries {
Signature · 1 line
1.5.4.4
Re: [PATCH 07/24] [NETFILTER]: remove ARPT_{CONTINUE,RETURN} indirection macros
Quoted 10 lines · Jan Engelhardt
Signed-off-by Jan Engelhardt <[email protected]>--- include/linux/netfilter_arp/arp_tables.h | 4 ---- 1 files changed, 0 insertions(+), 4 deletions(-)include/linux/netfilter_arp/arp_tables.h +0
-0
include/linux/netfilter_arp/arp_tables.h struct arpt_replace · line 186
Quoted 7 lines
include/linux/netfilter_arp/arp_tables.h +0
-4@@ -180,10 +180,6 @@ struct arpt_replacestruct arpt_entry entries[0 ]; }; -/* The argument to ARPT_SO_ADD_COUNTERS. */ -#define arpt_counters_info xt_counters_info -#define arpt_counters xt_counters -
Used by userspace.
PATCH 8/24 : rename NF_ARP to AF_ARP and assign a non-clashing value
In reply to Jan EngelhardtFor coming Xtables patches, we want to use AF_UNSPEC, but NF_ARP currently evaluates to the same value so it gets changed.
--- include/linux/netfilter_arp.h | 3 - include/linux/socket.h | 2 + net/bridge/br_netfilter.c | 2 +- net/ipv4/arp.c | 4 +- net/ipv4/netfilter/arp_tables.c | 56 +++++++++++++------------- net/ipv4/netfilter/arpt_mangle.c | 2 +- net/ipv4/netfilter/arptable_filter.c | 8 ++-- net/ipv4/netfilter/ipt_CLUSTERIP.c | 2 +- net/netfilter/x_tables.c | 2 +- net/netfilter/xt_NFQUEUE.c | 2 +- 10 files changed, 41 insertions(+), 42 deletions(-)
include/linux/netfilter_arp.h +0 -3
@@ -7,9 +7,6 @@#include <linux/netfilter.h> -/* There is no PF_ARP. */ -#define NF_ARP 0 -/* ARP Hooks */ #define NF_ARP_IN 0#define NF_ARP_OUT 1
include/linux/socket.h +2 -0
@@ -179,6 +179,7 @@ struct ucred {#define AF_ASH 18/* Ash */ #define AF_ECONET 19/* Acorn Econet */ #define AF_ATMSVC 20/* ATM SVCs */ +#define AF_ARP 21/* Address Resolution for IPv4 */ #define AF_SNA 22/* Linux SNA Project (nutters!) */ #define AF_IRDA 23/* IRDA sockets */ #define AF_PPPOX 24/* PPPoX sockets */
@@ -215,6 +216,7 @@ struct ucred {#define PF_ASH AF_ASH#define PF_ECONET AF_ECONET#define PF_ATMSVC AF_ATMSVC +#define PF_ARP AF_ARP#define PF_SNA AF_SNA#define PF_IRDA AF_IRDA#define PF_PPPOX AF_PPPOX
net/bridge/br_netfilter.c +1 -1
@@ -711,7 +711,7 @@ static unsigned int br_nf_forward_arp(unsigned int hook, struct sk_buff *skb,return NF_ACCEPT ; } *d = (struct net_device *)in; -NF_HOOK (NF_ARP ,NF_ARP_FORWARD , skb, (struct net_device *)in, +NF_HOOK (AF_ARP ,NF_ARP_FORWARD , skb, (struct net_device *)in, (struct net_device *)out, br_nf_forward_finish);return NF_STOLEN ;
net/ipv4/arp.c +2 -2
@@ -664,7 +664,7 @@ out:void arp_xmit (struct sk_buff *skb) {/* Send it off, maybe filter it using firewalling first. */ -NF_HOOK (NF_ARP ,NF_ARP_OUT , skb,NULL , skb->dev, dev_queue_xmit); +NF_HOOK (AF_ARP ,NF_ARP_OUT , skb,NULL , skb->dev, dev_queue_xmit); }/*
@@ -929,7 +929,7 @@ static int arp_rcv(struct sk_buff *skb, struct net_device *dev,memset (NEIGH_CB (skb),0 ,sizeof (struct neighbour_cb )); -return NF_HOOK (NF_ARP ,NF_ARP_IN , skb, dev,NULL , arp_process); +return NF_HOOK (AF_ARP ,NF_ARP_IN , skb, dev,NULL , arp_process); freeskb:kfree_skb (skb);
net/ipv4/netfilter/arp_tables.c +28 -28
198 lines not on this page · raw message
net/ipv4/netfilter/arpt_mangle.c +1 -1
@@ -75,7 +75,7 @@ checkentry(const char *tablename, const void *e, const struct xt_target *target,static struct xt_target arpt_mangle_reg__read_mostly = { .name ="mangle" , - .family =NF_ARP , + .family =AF_ARP , .target = target, .targetsize =sizeof (struct arpt_mangle ), .checkentry = checkentry,
net/ipv4/netfilter/arptable_filter.c +4 -4
@@ -51,7 +51,7 @@ static struct xt_table packet_filter = { .lock = RW_LOCK_UNLOCKED, .private = NULL, .me = THIS_MODULE, - .af = NF_ARP, + .af = AF_ARP, };/* The work comes in here from netfilter.c */
@@ -68,19 +68,19 @@ static struct nf_hook_ops arpt_ops[] __read_mostly = { { .hook = arpt_hook, .owner = THIS_MODULE, - .pf = NF_ARP, + .pf = AF_ARP, .hooknum = NF_ARP_IN, }, { .hook = arpt_hook, .owner = THIS_MODULE, - .pf = NF_ARP, + .pf = AF_ARP, .hooknum = NF_ARP_OUT, }, { .hook = arpt_hook, .owner = THIS_MODULE, - .pf = NF_ARP, + .pf = AF_ARP, .hooknum = NF_ARP_FORWARD, }, };
net/ipv4/netfilter/ipt_CLUSTERIP.c +1 -1
@@ -545,7 +545,7 @@ arp_mangle(unsigned int hook,static struct nf_hook_ops cip_arp_ops__read_mostly = { .hook = arp_mangle, - .pf =NF_ARP , + .pf =AF_ARP , .hooknum =NF_ARP_OUT , .priority =-1 };
net/netfilter/x_tables.c +1 -1
@@ -61,7 +61,7 @@ static struct xt_af *xt;static const char *const xt_prefix[NPROTO ] = { [AF_INET ] ="ip" , [AF_INET6 ] ="ip6" , - [NF_ARP ] ="arp" , + [AF_ARP ] ="arp" , };/* Registration hooks for targets. */
net/netfilter/xt_NFQUEUE.c +1 -1
@@ -50,7 +50,7 @@ static struct xt_target nfqueue_tg_reg[] __read_mostly = { }, { .name = "NFQUEUE", - .family = NF_ARP, + .family = AF_ARP, .target = nfqueue_tg, .targetsize = sizeof(struct xt_NFQ_info), .me = THIS_MODULE,
Signature · 1 line
1.5.4.4
Re: [PATCH 08/24] [NETFILTER]: rename NF_ARP to AF_ARP and assign a non-clashing value
include/linux/socket.h struct ucred { · line 182
Quoted 10 lines · Jan Engelhardt
For coming Xtables patches, we want to use
AF_UNSPEC, butNF_ARPcurrently evaluates to the same value so it gets changed.include/linux/socket.h +1
-0@@ -179,6 +179,7 @@ struct ucred {#define AF_ASH 18/* Ash */ #define AF_ECONET 19/* Acorn Econet */ #define AF_ATMSVC 20/* ATM SVCs */ +#define AF_ARP 21/* Address Resolution for IPv4 */
Did you make sure this value wasn't ever used by something else? Is this used by userspace? If not, why change it?
Re: [PATCH 08/24] [NETFILTER]: rename NF_ARP to AF_ARP and assign a non-clashing value
Quoted 12 lines · Patrick McHardy
Quoted 10 lines · Jan Engelhardt
For coming Xtables patches, we want to use
AF_UNSPEC, butNF_ARPcurrently evaluates to the same value so it gets changed.---
a/include/linux/socket.h
+++b/include/linux/socket.h
@@ -179,6 +179,7 @@ struct ucred {
#defineAF_ASH18 /* Ash */
#defineAF_ECONET19 /* Acorn Econet */
#defineAF_ATMSVC20 /* ATM SVCs */
+#defineAF_ARP21 /* Address Resolution for IPv4 */
Quoted 1 line
Did you make sure this value wasn't ever used by something else?
There are no traces of 21 in the entire history [/nico/archive.git, /tglx/history.git].
Quoted 1 line
Is this used by userspace? If not, why change it?
Change, because NF_ARP is used to wrongly index into xt_afinfo -- it overlaps with PF_UNSPEC. Since NF_ARP is only used very internally in the kernel, it can be changed. To avoid problems, PF_ARP gets a proper slot.
Re: [PATCH 08/24] [NETFILTER]: rename NF_ARP to AF_ARP and assign a non-clashing value
Quoted 19 lines · Jan Engelhardt
Quoted 12 lines · Patrick McHardy
Quoted 10 lines · Jan Engelhardt
For coming Xtables patches, we want to use
AF_UNSPEC, butNF_ARPcurrently evaluates to the same value so it gets changed.---
a/include/linux/socket.h
+++b/include/linux/socket.h
@@ -179,6 +179,7 @@ struct ucred {
#defineAF_ASH18 /* Ash */#define AF_ECONET 19 /* Acorn Econet */ #define AF_ATMSVC 20 /* ATM SVCs */+#define
AF_ARP21 /* Address Resolution for IPv4 */Quoted 1 line
Did you make sure this value wasn't ever used by something else?
There are no traces of 21 in the entire history [/nico/archive.git, /tglx/history.git].
Quoted 6 lines
Quoted 1 line
Is this used by userspace? If not, why change it?
Change, because
NF_ARPis used to wrongly index intoxt_afinfo-- it overlaps withPF_UNSPEC. SinceNF_ARPis only used very internally in the kernel, it can be changed. To avoid problems,PF_ARPgets a proper slot.
I don't like exporting this since, as you say, userspace doesn't need it and arp isn't an address family. I would suggest to just define something kernel-internally that doesn't clash, like using AF_MAX + X as base.
Re: [PATCH 08/24] [NETFILTER]: rename NF_ARP to AF_ARP and assign a non-clashing value
Quoted 8 lines · Patrick McHardy
Quoted 6 lines
Quoted 1 line
Is this used by userspace? If not, why change it?
Change, because
NF_ARPis used to wrongly index intoxt_afinfo-- it overlaps withPF_UNSPEC. SinceNF_ARPis only used very internally in the kernel, it can be changed. To avoid problems,PF_ARPgets a proper slot.and arp isn't an address family.
Neither is PF_BRIDGE, yet this is also used.
Quoted 3 lines
I would suggest to
just define something kernel-internally that doesn't clash, like usingAF_MAX+ X as base.
Then we'd have to insert a bunch of if()s in hotpaths that filter out the nonconformists again, or have a higher memory footprint.
Quoted 2 lines
I don't like exporting this since, as you say, userspace doesn't need it
Somehow you have to say that an extension if for arp only. We could abuse ETH_P_ARP, but using just the same name and value across both user and kernelspace seems just more logical.
static struct xtables_target new_arp_mangle = {
.family = ETH_P_ARP,
};
Re: [PATCH 08/24] [NETFILTER]: rename NF_ARP to AF_ARP and assign a non-clashing value
Quoted 4 lines · Jan Engelhardt
Quoted 2 lines · Patrick McHardy
Quoted 2 lines
Quoted 1 line
Is this used by userspace? If not, why change it?
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Change, because
NF_ARPis used to wrongly index intoxt_afinfo-- it overlaps withPF_UNSPEC. SinceNF_ARPis only used very internally in the kernel, it can be changed. To avoid problems,PF_ARPgets a proper slot.and arp isn't an address family.
Neither is
PF_BRIDGE, yet this is also used.
That has a different reason and is not ideal either.
Quoted 7 lines
Quoted 3 lines
I would suggest to
just define something kernel-internally that doesn't clash, like usingAF_MAX+ X as base.Then we'd have to insert a bunch of if()s in hotpaths that filter out the nonconformists again, or have a higher memory footprint.
You don't need any new conditions for this.
Quoted 10 lines
Quoted 2 lines
I don't like exporting this since, as you say, userspace doesn't need it
Somehow you have to say that an extension if for arp only. We could abuse
ETH_P_ARP, but using just the same name and value across both user and kernelspace seems just more logical.static struct
xtables_targetnew_arp_mangle= {
.family =ETH_P_ARP,
};
Whats the problem with moving NF_ARP outside userspace visibility and defining it to AF_MAX + 1?
Re: [PATCH 08/24] [NETFILTER]: rename NF_ARP to AF_ARP and assign a non-clashing value
Quoted 8 lines · Patrick McHardy
Quoted 8 lines
Quoted 3 lines
I don't like exporting this since, as you say, userspace doesn't need it
Somehow you have to say that an extension if for arp only. We could abuse
ETH_P_ARP, but using just the same name and value across both user and kernelspace seems just more logical.
Quoted 7 lines
Quoted 3 lines
static struct
xtables_targetnew_arp_mangle= {
.family =ETH_P_ARP,
};Whats the problem with moving
NF_ARPoutside userspace visibility and defining it toAF_MAX+ 1?
I guess it would work. Given that my currently running kernel did not break on removing NF_ARP entirely and substituting it by PF_ARP=21...
can we at least go for a more verbose name like NFPROTO_ARP?
Re: [PATCH 08/24] [NETFILTER]: rename NF_ARP to AF_ARP and assign a non-clashing value
Quoted 14 lines · Jan Engelhardt
Quoted 12 lines · Patrick McHardy
Quoted 11 lines
Quoted 3 lines
I don't like exporting this since, as you say, userspace doesn't need it
Somehow you have to say that an extension if for arp only. We could abuse
ETH_P_ARP, but using just the same name and value across both user and kernelspace seems just more logical.static struct
xtables_targetnew_arp_mangle= {
.family =ETH_P_ARP,
};
Quoted 7 lines
Quoted 3 lines
Whats the problem with moving
NF_ARPoutside userspace visibility and defining it toAF_MAX+ 1?I guess it would work. Given that my currently running kernel did not break on removing
NF_ARPentirely and substituting it by PF_ARP=21...
can we at least go for a more verbose name likeNFPROTO_ARP?
Sure. I'd suggest to do something like this:
enum nf_protos {
__NF_PROTO_MIN = AF_MAX,
NF_PROTO_ARP,
};BTW, I'll go over your remaining non-arptables patch today, please only repost the arptables patchces (and the ebtables one if it logically belongs together) as one series with some explanations on what it is trying to do as a whole and the concept.
Re: [PATCH 08/24] [NETFILTER]: rename NF_ARP to AF_ARP and assign a non-clashing value
In reply to Patrick McHardyIn article <[email protected]> (at Thu, 03 Apr 2008 15:17:39 +0200), Patrick McHardy <[email protected]> says:
:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
#define AF_ECONET 19 /* Acorn Econet */ #define AF_ATMSVC 20 /* ATM SVCs */+#define
AF_ARP21 /* Address Resolution for IPv4 */
:
Quoted 2 lines
I don't like exporting this since, as you say, userspace doesn't need it and arp isn't an address family. I would suggest to
:
Why not #ifdef __KERNEL__ .. #endif?
Or just add a comment not to use the value.
--yoshfuji
Re: [PATCH 08/24] [NETFILTER]: rename NF_ARP to AF_ARP and assign a non-clashing value
Quoted 6 lines · YOSHIFUJI Hideaki / $B5HF#1QL@ wrote:
In article <[email protected]> (at Thu, 03 Apr 2008 15:17:39 +0200), Patrick McHardy <[email protected]> says:
:
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
#define AF_ECONET 19 /* Acorn Econet */ #define AF_ATMSVC 20 /* ATM SVCs */+#define
AF_ARP21 /* Address Resolution for IPv4 */
Quoted 7 lines
:
Quoted 2 lines
I don't like exporting this since, as you say, userspace doesn't need it and arp isn't an address family. I would suggest to
:
Why not #ifdef
__KERNEL__.. #endif?
Or just add a comment not to use the value.
It sets a bad example to add new non-families there as well. We're dimensioning lots of things using AF_MAX, so its better to avoid misuse.
Re: [PATCH 08/24] [NETFILTER]: rename NF_ARP to AF_ARP and assign a non-clashing value
In article <[email protected]> (at Thu, 03 Apr 2008 15:58:38 +0200), Patrick McHardy <[email protected]> says:
Quoted 3 lines
It sets a bad example to add new non-families there as well. We're dimensioning lots of things using
AF_MAX, so its better to avoid misuse.
Assuming large values do not harm, I totally agree.
--yoshfuji
PATCH 9/24 : Implement AF_UNSPEC as a wildcard for extensions
In reply to Jan EngelhardtWhen a match or target is looked up using xt_find_{match,target}, Xtables will also search the AF_UNSPEC module list. This allows for extensions to be reused from other components (e.g. arptables, ebtables).
Extensions that take different codepaths depending on match->family or target->family of course cannot use AF_UNSPEC within the registration structure (e.g. xt_pkttype).
--- net/netfilter/x_tables.c | 11 +++++++++ net/netfilter/xt_CLASSIFY.c | 38 ++++++++++---------------------- net/netfilter/xt_MARK.c | 10 +------- net/netfilter/xt_RATEEST.c | 33 +++++++++------------------ net/netfilter/xt_SECMARK.c | 35 ++++++++++------------------- net/netfilter/xt_TRACE.c | 27 ++++++++-------------- net/netfilter/xt_limit.c | 40 +++++++++++----------------------- net/netfilter/xt_mark.c | 26 +-------------------- net/netfilter/xt_quota.c | 29 ++++++++---------------- net/netfilter/xt_rateest.c | 33 +++++++++------------------ net/netfilter/xt_statistic.c | 31 ++++++++----------------- net/netfilter/xt_string.c | 32 +++++++++----------------- net/netfilter/xt_time.c | 28 +++++++---------------- net/netfilter/xt_u32.c | 26 +++++++-------------- 14 files changed, 132 insertions(+), 267 deletions(-)
net/netfilter/x_tables.c +11 -0
@@ -59,6 +59,7 @@ static struct xt_af *xt;#endif static const char *const xt_prefix[NPROTO ] = { + [AF_UNSPEC ] ="x" , [AF_INET ] ="ip" , [AF_INET6 ] ="ip6" , [AF_ARP ] ="arp" ,
@@ -207,6 +208,11 @@ struct xt_match *xt_find_match(unsigned int af, const char *name, u8 revision) } }mutex_unlock (&xt[af].mutex); + +if (af !=AF_UNSPEC ) +/* Try searching again in the family-independent list */ +return xt_find_match (AF_UNSPEC , name, revision); +return ERR_PTR (err); }EXPORT_SYMBOL (xt_find_match);
@@ -232,6 +238,11 @@ struct xt_target *xt_find_target(unsigned int af, const char *name, u8 revision) } }mutex_unlock (&xt[af].mutex); + +if (af !=AF_UNSPEC ) +/* Try searching again in the family-independent list */ +return xt_find_target (AF_UNSPEC , name, revision); +return ERR_PTR (err); }EXPORT_SYMBOL (xt_find_target);
net/netfilter/xt_CLASSIFY.c +12 -26
@@ -37,40 +37,26 @@ classify_tg(struct sk_buff *skb, const struct net_device *in,return XT_CONTINUE ; } -static struct xt_target classify_tg_reg[]__read_mostly = { - { - .family =AF_INET , - .name ="CLASSIFY" , - .target = classify_tg, - .targetsize =sizeof (struct xt_classify_target_info ), - .table ="mangle" , - .hooks = (1 <<NF_INET_LOCAL_OUT ) | - (1 <<NF_INET_FORWARD ) | - (1 <<NF_INET_POST_ROUTING ), - .me =THIS_MODULE , - }, - { - .name ="CLASSIFY" , - .family =AF_INET6 , - .target = classify_tg, - .targetsize =sizeof (struct xt_classify_target_info ), - .table ="mangle" , - .hooks = (1 <<NF_INET_LOCAL_OUT ) | - (1 <<NF_INET_FORWARD ) | - (1 <<NF_INET_POST_ROUTING ), - .me =THIS_MODULE , - }, +static struct xt_target classify_tg_reg__read_mostly = { + .name ="CLASSIFY" , + .revision =0 , + .family =AF_UNSPEC , + .table ="mangle" , + .hooks = (1 <<NF_INET_LOCAL_OUT ) | (1 <<NF_INET_FORWARD ) | + (1 <<NF_INET_POST_ROUTING ), + .target = classify_tg, + .targetsize =sizeof (struct xt_classify_target_info ), + .me =THIS_MODULE , };static int __init classify_tg_init (void ) { -return xt_register_targets (classify_tg_reg, -ARRAY_SIZE (classify_tg_reg)); +return xt_register_target (&classify_tg_reg); } static void __exit classify_tg_exit(void) { -xt_unregister_targets (classify_tg_reg,ARRAY_SIZE (classify_tg_reg)); +xt_unregister_target (&classify_tg_reg); }module_init (classify_tg_init);
net/netfilter/xt_MARK.c +1 -9
@@ -222,15 +222,7 @@ static struct xt_target mark_tg_reg[] __read_mostly = { { .name = "MARK", .revision = 2, - .family = AF_INET, - .target = mark_tg, - .targetsize = sizeof(struct xt_mark_tginfo2), - .me = THIS_MODULE, - }, - { - .name = "MARK", - .revision = 2, - .family = AF_INET6, + .family = AF_UNSPEC, .target = mark_tg, .targetsize = sizeof(struct xt_mark_tginfo2), .me = THIS_MODULE,
net/netfilter/xt_RATEEST.c +11 -22
@@ -157,25 +157,15 @@ static void xt_rateest_tg_destroy(const struct xt_target *target,xt_rateest_put (info->est); } -static struct xt_target xt_rateest_target[]__read_mostly = { - { - .family =AF_INET , - .name ="RATEEST" , - .target = xt_rateest_tg, - .checkentry = xt_rateest_tg_checkentry, - .destroy = xt_rateest_tg_destroy, - .targetsize =sizeof (struct xt_rateest_target_info ), - .me =THIS_MODULE , - }, - { - .family =AF_INET6 , - .name ="RATEEST" , - .target = xt_rateest_tg, - .checkentry = xt_rateest_tg_checkentry, - .destroy = xt_rateest_tg_destroy, - .targetsize =sizeof (struct xt_rateest_target_info ), - .me =THIS_MODULE , - }, +static struct xt_target xt_rateest_tg_reg__read_mostly = { + .name ="RATEEST" , + .revision =0 , + .family =AF_UNSPEC , + .target = xt_rateest_tg, + .checkentry = xt_rateest_tg_checkentry, + .destroy = xt_rateest_tg_destroy, + .targetsize =sizeof (struct xt_rateest_target_info ), + .me =THIS_MODULE , };static int __init xt_rateest_tg_init (void )
@@ -186,13 +176,12 @@ static int __init xt_rateest_tg_init(void)INIT_HLIST_HEAD (&rateest_hash[i]);get_random_bytes (&jhash_rnd,sizeof (jhash_rnd)); -return xt_register_targets (xt_rateest_target, -ARRAY_SIZE (xt_rateest_target)); +return xt_register_target (&xt_rateest_tg_reg); } static void __exit xt_rateest_tg_fini(void) { -xt_unregister_targets (xt_rateest_target,ARRAY_SIZE (xt_rateest_target)); +xt_unregister_target (&xt_rateest_tg_reg); }
net/netfilter/xt_SECMARK.c +12 -23
@@ -119,37 +119,26 @@ static void secmark_tg_destroy(const struct xt_target *target, void *targinfo) } } -static struct xt_target secmark_tg_reg[]__read_mostly = { - { - .name ="SECMARK" , - .family =AF_INET , - .checkentry = secmark_tg_check, - .destroy = secmark_tg_destroy, - .target = secmark_tg, - .targetsize =sizeof (struct xt_secmark_target_info ), - .table ="mangle" , - .me =THIS_MODULE , - }, - { - .name ="SECMARK" , - .family =AF_INET6 , - .checkentry = secmark_tg_check, - .destroy = secmark_tg_destroy, - .target = secmark_tg, - .targetsize =sizeof (struct xt_secmark_target_info ), - .table ="mangle" , - .me =THIS_MODULE , - }, +static struct xt_target secmark_tg_reg__read_mostly = { + .name ="SECMARK" , + .revision =0 , + .family =AF_UNSPEC , + .table ="mangle" , + .target = secmark_tg, + .checkentry = secmark_tg_check, + .destroy = secmark_tg_destroy, + .targetsize =sizeof (struct xt_secmark_target_info ), + .me =THIS_MODULE , };static int __init secmark_tg_init (void ) { -return xt_register_targets (secmark_tg_reg,ARRAY_SIZE (secmark_tg_reg)); +return xt_register_target (&secmark_tg_reg); } static void __exit secmark_tg_exit(void) { -xt_unregister_targets (secmark_tg_reg,ARRAY_SIZE (secmark_tg_reg)); +xt_unregister_target (&secmark_tg_reg); }module_init (secmark_tg_init);
net/netfilter/xt_TRACE.c +10 -17
@@ -19,31 +19,24 @@ trace_tg(struct sk_buff *skb, const struct net_device *in,return XT_CONTINUE ; } -static struct xt_target trace_tg_reg[]__read_mostly = { - { - .name ="TRACE" , - .family =AF_INET , - .target = trace_tg, - .table ="raw" , - .me =THIS_MODULE , - }, - { - .name ="TRACE" , - .family =AF_INET6 , - .target = trace_tg, - .table ="raw" , - .me =THIS_MODULE , - }, +static struct xt_target trace_tg_reg__read_mostly = { + .name ="TRACE" , + .revision =0 , + .family =AF_UNSPEC , + .table ="raw" , + .target = trace_tg, + .targetsize =XT_ALIGN (0 ), + .me =THIS_MODULE , };static int __init trace_tg_init (void ) { -return xt_register_targets (trace_tg_reg,ARRAY_SIZE (trace_tg_reg)); +return xt_register_target (&trace_tg_reg); } static void __exit trace_tg_exit(void) { -xt_unregister_targets (trace_tg_reg,ARRAY_SIZE (trace_tg_reg)); +xt_unregister_target (&trace_tg_reg); }module_init (trace_tg_init);
net/netfilter/xt_limit.c +13 -27
@@ -167,43 +167,29 @@ static int limit_mt_compat_to_user(void __user *dst, void *src) }#endif /* CONFIG_COMPAT */ -static struct xt_match limit_mt_reg[]__read_mostly = { - { - .name ="limit" , - .family =AF_INET , - .checkentry = limit_mt_check, - .match = limit_mt, - .matchsize =sizeof (struct xt_rateinfo ), +static struct xt_match limit_mt_reg__read_mostly = { + .name ="limit" , + .revision =0 , + .family =AF_UNSPEC , + .match = limit_mt, + .checkentry = limit_mt_check, + .matchsize =sizeof (struct xt_rateinfo ), #ifdef CONFIG_COMPAT - .compatsize =sizeof (struct compat_xt_rateinfo ), - .compat_from_user = limit_mt_compat_from_user, - .compat_to_user = limit_mt_compat_to_user, + .compatsize =sizeof (struct compat_xt_rateinfo ), + .compat_from_user = limit_mt_compat_from_user, + .compat_to_user = limit_mt_compat_to_user, #endif - .me =THIS_MODULE , - }, - { - .name ="limit" , - .family =AF_INET6 , - .checkentry = limit_mt_check, - .match = limit_mt, - .matchsize =sizeof (struct xt_rateinfo ), -#ifdef CONFIG_COMPAT - .compatsize =sizeof (struct compat_xt_rateinfo ), - .compat_from_user = limit_mt_compat_from_user, - .compat_to_user = limit_mt_compat_to_user, -#endif - .me =THIS_MODULE , - }, + .me =THIS_MODULE , };static int __init limit_mt_init (void ) { -return xt_register_matches (limit_mt_reg,ARRAY_SIZE (limit_mt_reg)); +return xt_register_match (&limit_mt_reg); } static void __exit limit_mt_exit(void) { -xt_unregister_matches (limit_mt_reg,ARRAY_SIZE (limit_mt_reg)); +xt_unregister_match (&limit_mt_reg); }module_init (limit_mt_init);
net/netfilter/xt_mark.c +2 -24
@@ -92,7 +92,7 @@ static struct xt_match mark_mt_reg[] __read_mostly = { { .name = "mark", .revision = 0, - .family = AF_INET, + .family = AF_UNSPEC, .checkentry = mark_mt_check_v0, .match = mark_mt_v0, .matchsize = sizeof(struct xt_mark_info),
@@ -104,31 +104,9 @@ static struct xt_match mark_mt_reg[] __read_mostly = { .me = THIS_MODULE, }, { - .name = "mark", - .revision = 0, - .family = AF_INET6, - .checkentry = mark_mt_check_v0, - .match = mark_mt_v0, - .matchsize =sizeof (struct xt_mark_info ), -#ifdef CONFIG_COMPAT - .compatsize =sizeof (struct compat_xt_mark_info ), - .compat_from_user = mark_mt_compat_from_user_v0, - .compat_to_user = mark_mt_compat_to_user_v0, -#endif - .me = THIS_MODULE, - }, - { - .name ="mark" , - .revision = 1, - .family = AF_INET, - .match = mark_mt, - .matchsize = sizeof(struct xt_mark_mtinfo1), - .me = THIS_MODULE, - }, - { .name = "mark", .revision = 1, - .family = AF_INET6, + .family = AF_UNSPEC, .match = mark_mt, .matchsize = sizeof(struct xt_mark_mtinfo1), .me = THIS_MODULE,
net/netfilter/xt_quota.c +10 -19
@@ -54,33 +54,24 @@ quota_mt_check(const char *tablename, const void *entry,return true; } -static struct xt_match quota_mt_reg[]__read_mostly = { - { - .name ="quota" , - .family =AF_INET , - .checkentry = quota_mt_check, - .match = quota_mt, - .matchsize =sizeof (struct xt_quota_info ), - .me =THIS_MODULE - }, - { - .name ="quota" , - .family =AF_INET6 , - .checkentry = quota_mt_check, - .match = quota_mt, - .matchsize =sizeof (struct xt_quota_info ), - .me =THIS_MODULE - }, +static struct xt_match quota_mt_reg__read_mostly = { + .name ="quota" , + .revision =0 , + .family =AF_UNSPEC , + .match = quota_mt, + .checkentry = quota_mt_check, + .matchsize =sizeof (struct xt_quota_info ), + .me =THIS_MODULE , };static int __init quota_mt_init (void ) { -return xt_register_matches (quota_mt_reg,ARRAY_SIZE (quota_mt_reg)); +return xt_register_match ("a_mt_reg); } static void __exit quota_mt_exit(void) { -xt_unregister_matches (quota_mt_reg,ARRAY_SIZE (quota_mt_reg)); +xt_unregister_match ("a_mt_reg); }module_init (quota_mt_init);
net/netfilter/xt_rateest.c +11 -22
@@ -137,36 +137,25 @@ static void xt_rateest_mt_destroy(const struct xt_match *match,xt_rateest_put (info->est2); } -static struct xt_match xt_rateest_match[]__read_mostly = { - { - .family =AF_INET , - .name ="rateest" , - .match = xt_rateest_mt, - .checkentry = xt_rateest_mt_checkentry, - .destroy = xt_rateest_mt_destroy, - .matchsize =sizeof (struct xt_rateest_match_info ), - .me =THIS_MODULE , - }, - { - .family =AF_INET6 , - .name ="rateest" , - .match = xt_rateest_mt, - .checkentry = xt_rateest_mt_checkentry, - .destroy = xt_rateest_mt_destroy, - .matchsize =sizeof (struct xt_rateest_match_info ), - .me =THIS_MODULE , - }, +static struct xt_match xt_rateest_mt_reg__read_mostly = { + .name ="rateest" , + .revision =0 , + .family =AF_UNSPEC , + .match = xt_rateest_mt, + .checkentry = xt_rateest_mt_checkentry, + .destroy = xt_rateest_mt_destroy, + .matchsize =sizeof (struct xt_rateest_match_info ), + .me =THIS_MODULE , };static int __init xt_rateest_mt_init (void ) { -return xt_register_matches (xt_rateest_match, -ARRAY_SIZE (xt_rateest_match)); +return xt_register_match (&xt_rateest_mt_reg); } static void __exit xt_rateest_mt_fini(void) { -xt_unregister_matches (xt_rateest_match,ARRAY_SIZE (xt_rateest_match)); +xt_unregister_match (&xt_rateest_mt_reg); }MODULE_AUTHOR ("Patrick McHardy <[email protected]>" );
net/netfilter/xt_statistic.c +10 -21
@@ -66,35 +66,24 @@ statistic_mt_check(const char *tablename, const void *entry,return true; } -static struct xt_match statistic_mt_reg[]__read_mostly = { - { - .name ="statistic" , - .family =AF_INET , - .checkentry = statistic_mt_check, - .match = statistic_mt, - .matchsize =sizeof (struct xt_statistic_info ), - .me =THIS_MODULE , - }, - { - .name ="statistic" , - .family =AF_INET6 , - .checkentry = statistic_mt_check, - .match = statistic_mt, - .matchsize =sizeof (struct xt_statistic_info ), - .me =THIS_MODULE , - }, +static struct xt_match xt_statistic_mt_reg__read_mostly = { + .name ="statistic" , + .revision =0 , + .family =AF_UNSPEC , + .match = statistic_mt, + .checkentry = statistic_mt_check, + .matchsize =sizeof (struct xt_statistic_info ), + .me =THIS_MODULE , };static int __init statistic_mt_init (void ) { -return xt_register_matches (statistic_mt_reg, -ARRAY_SIZE (statistic_mt_reg)); +return xt_register_match (&xt_statistic_mt_reg); } static void __exit statistic_mt_exit(void) { -xt_unregister_matches (statistic_mt_reg, -ARRAY_SIZE (statistic_mt_reg)); +xt_unregister_match (&xt_statistic_mt_reg); }module_init (statistic_mt_init);
net/netfilter/xt_string.c +11 -21
@@ -69,35 +69,25 @@ static void string_mt_destroy(const struct xt_match *match, void *matchinfo)textsearch_destroy (STRING_TEXT_PRIV (matchinfo)->config); } -static struct xt_match string_mt_reg[]__read_mostly = { - { - .name ="string" , - .family =AF_INET , - .checkentry = string_mt_check, - .match = string_mt, - .destroy = string_mt_destroy, - .matchsize =sizeof (struct xt_string_info ), - .me =THIS_MODULE - }, - { - .name ="string" , - .family =AF_INET6 , - .checkentry = string_mt_check, - .match = string_mt, - .destroy = string_mt_destroy, - .matchsize =sizeof (struct xt_string_info ), - .me =THIS_MODULE - }, +static struct xt_match xt_string_mt_reg__read_mostly = { + .name ="string" , + .revision =0 , + .family =AF_UNSPEC , + .match = string_mt, + .checkentry = string_mt_check, + .destroy = string_mt_destroy, + .matchsize =sizeof (struct xt_string_info ), + .me =THIS_MODULE , };static int __init string_mt_init (void ) { -return xt_register_matches (string_mt_reg,ARRAY_SIZE (string_mt_reg)); +return xt_register_match (&xt_string_mt_reg); } static void __exit string_mt_exit(void) { -xt_unregister_matches (string_mt_reg,ARRAY_SIZE (string_mt_reg)); +xt_unregister_match (&xt_string_mt_reg); }module_init (string_mt_init);
net/netfilter/xt_time.c +9 -19
@@ -235,33 +235,23 @@ time_mt_check(const char *tablename, const void *ip,return true; } -static struct xt_match time_mt_reg[]__read_mostly = { - { - .name ="time" , - .family =AF_INET , - .match = time_mt, - .matchsize =sizeof (struct xt_time_info ), - .checkentry = time_mt_check, - .me =THIS_MODULE , - }, - { - .name ="time" , - .family =AF_INET6 , - .match = time_mt, - .matchsize =sizeof (struct xt_time_info ), - .checkentry = time_mt_check, - .me =THIS_MODULE , - }, +static struct xt_match xt_time_mt_reg__read_mostly = { + .name ="time" , + .family =AF_UNSPEC , + .match = time_mt, + .checkentry = time_mt_check, + .matchsize =sizeof (struct xt_time_info ), + .me =THIS_MODULE , };static int __init time_mt_init (void ) { -return xt_register_matches (time_mt_reg,ARRAY_SIZE (time_mt_reg)); +return xt_register_match (&xt_time_mt_reg); } static void __exit time_mt_exit(void) { -xt_unregister_matches (time_mt_reg,ARRAY_SIZE (time_mt_reg)); +xt_unregister_match (&xt_time_mt_reg); }module_init (time_mt_init);
net/netfilter/xt_u32.c +9 -17
@@ -99,31 +99,23 @@ u32_mt(const struct sk_buff *skb, const struct net_device *in,return ret ^ data->invert; } -static struct xt_match u32_mt_reg[]__read_mostly = { - { - .name ="u32" , - .family =AF_INET , - .match = u32_mt, - .matchsize =sizeof (struct xt_u32 ), - .me =THIS_MODULE , - }, - { - .name ="u32" , - .family =AF_INET6 , - .match = u32_mt, - .matchsize =sizeof (struct xt_u32 ), - .me =THIS_MODULE , - }, +static struct xt_match xt_u32_mt_reg__read_mostly = { + .name ="u32" , + .revision =0 , + .family =AF_UNSPEC , + .match = u32_mt, + .matchsize =sizeof (struct xt_u32 ), + .me =THIS_MODULE , };static int __init u32_mt_init (void ) { -return xt_register_matches (u32_mt_reg,ARRAY_SIZE (u32_mt_reg)); +return xt_register_match (&xt_u32_mt_reg); } static void __exit u32_mt_exit(void) { -xt_unregister_matches (u32_mt_reg,ARRAY_SIZE (u32_mt_reg)); +xt_unregister_match (&xt_u32_mt_reg); }module_init (u32_mt_init);
Signature · 1 line
1.5.4.4
Re: [PATCH 09/24] [NETFILTER]: Implement AF_UNSPEC as a wildcard for extensions
Quoted 8 lines · Jan Engelhardt
When a match or target is looked up using xt_find_{match,target}, Xtables will also search the
AF_UNSPECmodule list. This allows for extensions to be reused from other components (e.g. arptables, ebtables).Extensions that take different codepaths depending on
match->familyortarget->familyof course cannot useAF_UNSPECwithin the registration structure (e.g.xt_pkttype).
I'm skipping this patch until we've sorted out the AF_ARP thing.
PATCH 10/24 : Explicitly initialize .priority in arptable_filter
In reply to Jan Engelhardt--- net/ipv4/netfilter/arptable_filter.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
net/ipv4/netfilter/arptable_filter.c +3 -0
@@ -70,18 +70,21 @@ static struct nf_hook_ops arpt_ops[] __read_mostly = { .owner = THIS_MODULE, .pf = AF_ARP, .hooknum = NF_ARP_IN, + .priority = NF_IP_PRI_FILTER, }, { .hook = arpt_hook, .owner = THIS_MODULE, .pf = AF_ARP, .hooknum = NF_ARP_OUT, + .priority = NF_IP_PRI_FILTER, }, { .hook = arpt_hook, .owner = THIS_MODULE, .pf = AF_ARP, .hooknum = NF_ARP_FORWARD, + .priority = NF_IP_PRI_FILTER, }, };
Signature · 1 line
1.5.4.4
Patrick McHardy
AppliedRe: [PATCH 10/24] [NETFILTER]: Explicitly initialize .priority in arptable_filter
Quoted 1 line · Jan Engelhardt
Signed-off-by Jan Engelhardt <[email protected]>
Applied.
PATCH 11/24 : Rename ipt_recent to xt_recent
In reply to Jan EngelhardtLike with other modules (such as ipt_state), ipt_recent.h is changed to forward definitions to (IOW include) xt_recent.h, and xt_recent.c is changed to use the new constant names.
---
include/linux/netfilter/xt_recent.h | 26 ++++++++
include/linux/netfilter_ipv4/ipt_recent.h | 28 ++++-----
net/ipv4/netfilter/Kconfig | 13 ----
net/ipv4/netfilter/Makefile | 1 -
net/netfilter/Kconfig | 11 ++++
net/netfilter/Makefile | 1 +
.../ipt_recent.c => netfilter/xt_recent.c} | 37 ++++++------
7 files changed, 68 insertions(+), 49 deletions(-)
create mode 100644 include/linux/netfilter/xt_recent.h
rename net/{ipv4/netfilter/ipt_recent.c => netfilter/xt_recent.c} (92%)include/linux/netfilter/xt_recent.h new file +26 -0
@@ -0,0 +1,26 @@ +#ifndef _LINUX_NETFILTER_XT_RECENT_H +#define _LINUX_NETFILTER_XT_RECENT_H 1 + +enum { +XT_RECENT_CHECK =1 <<0 , +XT_RECENT_SET =1 <<1 , +XT_RECENT_UPDATE =1 <<2 , +XT_RECENT_REMOVE =1 <<3 , +XT_RECENT_TTL =1 <<4 , + +XT_RECENT_SOURCE =0 , +XT_RECENT_DEST =1 , + +XT_RECENT_NAME_LEN =200 , +}; + +struct xt_recent_mtinfo { +u_int32_t seconds; +u_int32_t hit_count; +u_int8_t check_set; +u_int8_t invert; +char name[XT_RECENT_NAME_LEN ]; +u_int8_t side; +}; + +#endif /* _LINUX_NETFILTER_XT_RECENT_H */
include/linux/netfilter_ipv4/ipt_recent.h +11 -17
@@ -1,27 +1,21 @@#ifndef _IPT_RECENT_H#define _IPT_RECENT_H -#define RECENT_NAME "ipt_recent" -#define RECENT_VER "v0.3.1" +#include <linux/netfilter/xt_recent.h> -#define IPT_RECENT_CHECK 1 -#define IPT_RECENT_SET 2 -#define IPT_RECENT_UPDATE 4 -#define IPT_RECENT_REMOVE 8 -#define IPT_RECENT_TTL 16 +#define ipt_recent_info xt_recent_mtinfo -#define IPT_RECENT_SOURCE 0 -#define IPT_RECENT_DEST 1 +enum { +IPT_RECENT_CHECK =XT_RECENT_CHECK , +IPT_RECENT_SET =XT_RECENT_SET , +IPT_RECENT_UPDATE =XT_RECENT_UPDATE , +IPT_RECENT_REMOVE =XT_RECENT_REMOVE , +IPT_RECENT_TTL =XT_RECENT_TTL , -#define IPT_RECENT_NAME_LEN 200 +IPT_RECENT_SOURCE =XT_RECENT_SOURCE , +IPT_RECENT_DEST =XT_RECENT_DEST , -struct ipt_recent_info { -u_int32_t seconds; -u_int32_t hit_count; -u_int8_t check_set; -u_int8_t invert; -char name[IPT_RECENT_NAME_LEN ]; -u_int8_t side; +IPT_RECENT_NAME_LEN =XT_RECENT_NAME_LEN , };#endif /*_IPT_RECENT_H*/
net/ipv4/netfilter/Kconfig +0 -13
@@ -57,19 +57,6 @@ config IP_NF_IPTABLES To compile it as a module, choose M here. If unsure, say N. # The matches. -config IP_NF_MATCH_RECENT - tristate '"recent" match support' - depends on IP_NF_IPTABLES - depends on NETFILTER_ADVANCED - help - This match is used for creating one or many lists of recently - used addresses and then matching against that/those list(s). - - Short options are available by using 'iptables -m recent -h' - Official Website: <http://snowman.net/projects/ipt_recent/> - - To compile it as a module, choose M here. If unsure, say N. - config IP_NF_MATCH_ECN tristate '"ecn" match support' depends on IP_NF_IPTABLES
net/ipv4/netfilter/Makefile +0 -1
@@ -44,7 +44,6 @@ obj-$(CONFIG_IP_NF_RAW) += iptable_raw.o obj-$(CONFIG_IP_NF_MATCH_ADDRTYPE) += ipt_addrtype.o obj-$(CONFIG_IP_NF_MATCH_AH) += ipt_ah.o obj-$(CONFIG_IP_NF_MATCH_ECN) += ipt_ecn.o -obj-$(CONFIG_IP_NF_MATCH_RECENT) += ipt_recent.o obj-$(CONFIG_IP_NF_MATCH_TTL) += ipt_ttl.o # targets
net/netfilter/Kconfig +11 -0
@@ -711,6 +711,17 @@ config NETFILTER_XT_MATCH_REALM If you want to compile it as a module, say M here and read <file:Documentation/kbuild/modules.txt>. If unsure, say `N'. +config NETFILTER_XT_MATCH_RECENT + tristate '"recent" match support' + depends on NETFILTER_XTABLES + depends on NETFILTER_ADVANCED + ---help--- + This match is used for creating one or many lists of recently + used addresses and then matching against that/those list(s). + + Short options are available by using 'iptables -m recent -h' + Official Website: <http://snowman.net/projects/ipt_recent/> + config NETFILTER_XT_MATCH_SCTP tristate '"sctp" protocol match support (EXPERIMENTAL)' depends on NETFILTER_XTABLES && EXPERIMENTAL
net/netfilter/Makefile +1 -0
@@ -75,6 +75,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_POLICY) += xt_policy.o obj-$(CONFIG_NETFILTER_XT_MATCH_QUOTA) += xt_quota.o obj-$(CONFIG_NETFILTER_XT_MATCH_RATEEST) += xt_rateest.o obj-$(CONFIG_NETFILTER_XT_MATCH_REALM) += xt_realm.o +obj-$(CONFIG_NETFILTER_XT_MATCH_RECENT) += xt_recent.o obj-$(CONFIG_NETFILTER_XT_MATCH_SCTP) += xt_sctp.o obj-$(CONFIG_NETFILTER_XT_MATCH_STATE) += xt_state.o obj-$(CONFIG_NETFILTER_XT_MATCH_STATISTIC) += xt_statistic.o
net/netfilter/xt_recent.c renamed from net/ipv4/netfilter/ipt_recent.c +19 -18
@@ -27,11 +27,12 @@#include <net/net_namespace.h> #include <linux/netfilter/x_tables.h> -#include <linux/netfilter_ipv4/ipt_recent.h> +#include <linux/netfilter/xt_recent.h> MODULE_AUTHOR ("Patrick McHardy <[email protected]>" );MODULE_DESCRIPTION ("Xtables: \"recently-seen\" host matching for IPv4" );MODULE_LICENSE ("GPL" ); +MODULE_ALIAS ("ipt_recent" );static unsigned int ip_list_tot =100 ;static unsigned int ip_pkt_list_tot =20 ;
@@ -64,7 +65,7 @@ struct recent_entry {struct recent_table {struct list_head list; -char name[IPT_RECENT_NAME_LEN ]; +char name[XT_RECENT_NAME_LEN ];#ifdef CONFIG_PROC_FS struct proc_dir_entry *proc;#endif
@@ -175,14 +176,14 @@ recent_mt(const struct sk_buff *skb, const struct net_device *in, const void *matchinfo, int offset, unsigned int protoff, bool *hotdrop) { - const struct ipt_recent_info *info = matchinfo; + const struct xt_recent_mtinfo *info = matchinfo;struct recent_table *t;struct recent_entry *e;__be32 addr;u_int8_t ttl;bool ret = info->invert; -if (info->side ==IPT_RECENT_DEST ) +if (info->side ==XT_RECENT_DEST ) addr =ip_hdr (skb)->daddr;else addr =ip_hdr (skb)->saddr;
@@ -195,9 +196,9 @@ recent_mt(const struct sk_buff *skb, const struct net_device *in,spin_lock_bh (&recent_lock); t =recent_table_lookup (info->name); e =recent_entry_lookup (t, addr, - info->check_set &IPT_RECENT_TTL ? ttl :0 ); + info->check_set &XT_RECENT_TTL ? ttl :0 );if (e ==NULL ) { -if (!(info->check_set &IPT_RECENT_SET )) +if (!(info->check_set &XT_RECENT_SET )) goto out; e =recent_entry_init (t, addr, ttl);if (e ==NULL )
@@ -206,12 +207,12 @@ recent_mt(const struct sk_buff *skb, const struct net_device *in, goto out; } -if (info->check_set &IPT_RECENT_SET ) +if (info->check_set &XT_RECENT_SET ) ret = !ret; -else if (info->check_set &IPT_RECENT_REMOVE ) { +else if (info->check_set &XT_RECENT_REMOVE ) {recent_entry_remove (t, e); ret = !ret; - }else if (info->check_set & (IPT_RECENT_CHECK |IPT_RECENT_UPDATE )) { + }else if (info->check_set & (XT_RECENT_CHECK |XT_RECENT_UPDATE )) {unsigned long time = jiffies - info->seconds *HZ ;unsigned int i, hits =0 ;
@@ -225,8 +226,8 @@ recent_mt(const struct sk_buff *skb, const struct net_device *in, } } -if (info->check_set &IPT_RECENT_SET || - (info->check_set &IPT_RECENT_UPDATE && ret)) { +if (info->check_set &XT_RECENT_SET || + (info->check_set &XT_RECENT_UPDATE && ret)) {recent_entry_update (t, e); e->ttl = ttl; }
@@ -240,22 +241,22 @@ recent_mt_check(const char *tablename, const void *ip, const struct xt_match *match, void *matchinfo, unsigned int hook_mask) { - const struct ipt_recent_info *info = matchinfo; + const struct xt_recent_mtinfo *info = matchinfo;struct recent_table *t;unsigned i;bool ret = false;if (hweight8 (info->check_set & - (IPT_RECENT_SET |IPT_RECENT_REMOVE | -IPT_RECENT_CHECK |IPT_RECENT_UPDATE )) !=1 ) + (XT_RECENT_SET |XT_RECENT_REMOVE | +XT_RECENT_CHECK |XT_RECENT_UPDATE )) !=1 )return false; -if ((info->check_set & (IPT_RECENT_SET |IPT_RECENT_REMOVE )) && +if ((info->check_set & (XT_RECENT_SET |XT_RECENT_REMOVE )) && (info->seconds || info->hit_count))return false;if (info->hit_count > ip_pkt_list_tot)return false;if (info->name[0 ] =='\0' || -strnlen (info->name,IPT_RECENT_NAME_LEN ) ==IPT_RECENT_NAME_LEN ) +strnlen (info->name,XT_RECENT_NAME_LEN ) ==XT_RECENT_NAME_LEN )return false;mutex_lock (&recent_mutex);
@@ -296,7 +297,7 @@ out:static void recent_mt_destroy (const struct xt_match *match,void *matchinfo) { -const struct ipt_recent_info *info = matchinfo; +const struct xt_recent_mtinfo *info = matchinfo;struct recent_table *t;mutex_lock (&recent_mutex);
@@ -461,7 +462,7 @@ static struct xt_match recent_mt_reg __read_mostly = { .name = "recent", .family = AF_INET, .match = recent_mt, - .matchsize = sizeof(struct ipt_recent_info), + .matchsize = sizeof(struct xt_recent_mtinfo), .checkentry = recent_mt_check, .destroy = recent_mt_destroy, .me = THIS_MODULE,
Signature · 1 line
1.5.4.4
PATCH 12/24 : xt_recent: IPv6 support
In reply to Jan EngelhardtThis updates xt_recent to support IPv6 handling. It is sort of a flag day, as the new control directory is /proc/net/xt_recent with a new, more strict protocol (the string you ought to write into /proc/net/xt_recent/LIST). But on the other hand, I kept the binary interface towards iptables (which is quite memory consuming I must say) to keep the patch small.
--- net/netfilter/xt_recent.c | 207 +++++++++++++++++++++++++------------ 1 files changed, 143 insertions(+), 64 deletions(-)
net/netfilter/xt_recent.c +143 -64
@@ -1,5 +1,6 @@/* * Copyright (c) 2006 Patrick McHardy <[email protected]> +* Copyright © CC Computer Consultants GmbH, 2007 - 2008 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as
@@ -13,6 +14,8 @@*/ #include <linux/init.h> #include <linux/ip.h> +#include <linux/ipv6.h> +#include <linux/module.h> #include <linux/moduleparam.h> #include <linux/proc_fs.h> #include <linux/seq_file.h>
@@ -30,9 +33,11 @@#include <linux/netfilter/xt_recent.h> MODULE_AUTHOR ("Patrick McHardy <[email protected]>" ); +MODULE_AUTHOR ("Jan Engelhardt <[email protected]>" );MODULE_DESCRIPTION ("Xtables: \"recently-seen\" host matching for IPv4" );MODULE_LICENSE ("GPL" );MODULE_ALIAS ("ipt_recent" ); +MODULE_ALIAS ("ip6t_recent" );static unsigned int ip_list_tot =100 ;static unsigned int ip_pkt_list_tot =20 ;
@@ -49,14 +54,15 @@ module_param(ip_list_gid, uint, 0400);MODULE_PARM_DESC (ip_list_tot,"number of IPs to remember per list" );MODULE_PARM_DESC (ip_pkt_list_tot,"number of packets per IP to remember (max. 255)" );MODULE_PARM_DESC (ip_list_hash_size,"size of hash table used to look up IPs" ); -MODULE_PARM_DESC (ip_list_perms,"permissions on /proc/net/ipt_recent/* files" ); -MODULE_PARM_DESC (ip_list_uid,"owner of /proc/net/ipt_recent/* files" ); -MODULE_PARM_DESC (ip_list_gid,"owning group of /proc/net/ipt_recent/* files" ); +MODULE_PARM_DESC (ip_list_perms,"permissions on /proc/net/xt_recent/* files" ); +MODULE_PARM_DESC (ip_list_uid,"owner of /proc/net/xt_recent/* files" ); +MODULE_PARM_DESC (ip_list_gid,"owning group of /proc/net/xt_recent/* files" );struct recent_entry {struct list_head list;struct list_head lru_list; -__be32 addr; +union nf_inet_addr addr; +u_int16_t family;u_int8_t ttl;u_int8_t index;u_int16_t nstamps;
@@ -87,24 +93,43 @@ static const struct file_operations recent_fops;static u_int32_t hash_rnd;static int hash_rnd_initted; -static unsigned int recent_entry_hash (__be32 addr) +static unsigned int recent_entry_hash4 (const union nf_inet_addr *addr) {if (!hash_rnd_initted) { -get_random_bytes (&hash_rnd,4 ); +get_random_bytes (&hash_rnd,sizeof (hash_rnd)); hash_rnd_initted =1 ; } -return jhash_1word ((__force u32 )addr, hash_rnd) & (ip_list_hash_size -1 ); +return jhash_1word ((__force u32 )addr->ip, hash_rnd) & + (ip_list_hash_size -1 ); +} + +static unsigned int recent_entry_hash6 (const union nf_inet_addr *addr) +{ +if (!hash_rnd_initted) { +get_random_bytes (&hash_rnd,sizeof (hash_rnd)); + hash_rnd_initted =1 ; + } +return jhash2 ((u32 *)addr->ip6,ARRAY_SIZE (addr->ip6), hash_rnd) & + (ip_list_hash_size -1 ); }static struct recent_entry * -recent_entry_lookup (const struct recent_table *table,__be32 addr,u_int8_t ttl) +recent_entry_lookup (const struct recent_table *table, +const union nf_inet_addr *addrp,u_int16_t family, +u_int8_t ttl) {struct recent_entry *e;unsigned int h; - h =recent_entry_hash (addr); +if (family ==AF_INET ) + h =recent_entry_hash4 (addrp); +else + h =recent_entry_hash6 (addrp); +list_for_each_entry (e, &table->iphash[h], list) -if (e->addr == addr && (ttl == e->ttl || !ttl || !e->ttl)) +if (e->family == family && +memcmp (&e->addr, addrp,sizeof (e->addr)) ==0 && + (ttl == e->ttl || ttl ==0 || e->ttl ==0 ))return e;return NULL ; }
@@ -118,7 +143,8 @@ static void recent_entry_remove(struct recent_table *t, struct recent_entry *e) }static struct recent_entry * -recent_entry_init (struct recent_table *t,__be32 addr,u_int8_t ttl) +recent_entry_init (struct recent_table *t,const union nf_inet_addr *addr, +u_int16_t family,u_int8_t ttl) {struct recent_entry *e;
@@ -130,12 +156,16 @@ recent_entry_init(struct recent_table *t, __be32 addr, u_int8_t ttl) GFP_ATOMIC);if (e ==NULL )return NULL ; - e->addr = addr; +memcpy (&e->addr, addr,sizeof (e->addr)); e->ttl = ttl; e->stamps[0 ] = jiffies; e->nstamps =1 ; e->index =1 ; -list_add_tail (&e->list, &t->iphash[recent_entry_hash (addr)]); + e->family = family; +if (family ==AF_INET ) +list_add_tail (&e->list, &t->iphash[recent_entry_hash4 (addr)]); +else +list_add_tail (&e->list, &t->iphash[recent_entry_hash6 (addr)]);list_add_tail (&e->lru_list, &t->lru_list); t->entries++;return e;
@@ -179,28 +209,42 @@ recent_mt(const struct sk_buff *skb, const struct net_device *in,const struct xt_recent_mtinfo *info = matchinfo;struct recent_table *t;struct recent_entry *e; -__be32 addr; +union nf_inet_addr addr;u_int8_t ttl;bool ret = info->invert; -if (info->side ==XT_RECENT_DEST ) - addr =ip_hdr (skb)->daddr; -else - addr =ip_hdr (skb)->saddr; +if (match->family ==AF_INET ) { +const struct iphdr *iph =ip_hdr (skb); + +if (info->side ==XT_RECENT_DEST ) + addr.ip = iph->daddr; +else + addr.ip = iph->saddr; + + ttl = iph->ttl; + }else { +const struct ipv6hdr *iph =ipv6_hdr (skb); + +if (info->side ==XT_RECENT_DEST ) +memcpy (&addr.in6, &iph->daddr,sizeof (addr.in6)); +else +memcpy (&addr.in6, &iph->saddr,sizeof (addr.in6)); + + ttl = iph->hop_limit; + } - ttl =ip_hdr (skb)->ttl;/* use TTL as seen before forwarding */ if (out && !skb->sk) ttl++;spin_lock_bh (&recent_lock); t =recent_table_lookup (info->name); - e =recent_entry_lookup (t, addr, + e =recent_entry_lookup (t, &addr, match->family, info->check_set &XT_RECENT_TTL ? ttl :0 );if (e ==NULL ) {if (!(info->check_set &XT_RECENT_SET )) goto out; - e =recent_entry_init (t, addr, ttl); + e =recent_entry_init (t, &addr, match->family, ttl);if (e ==NULL ) *hotdrop = true; ret = !ret;
@@ -317,7 +361,7 @@ static void recent_mt_destroy(const struct xt_match *match, void *matchinfo)#ifdef CONFIG_PROC_FS struct recent_iter_state { -struct recent_table *table; +const struct recent_table *table;unsigned int bucket; };
@@ -342,8 +386,8 @@ static void *recent_seq_next(struct seq_file *seq, void *v, loff_t *pos) {struct recent_iter_state *st = seq->private;const struct recent_table *t = st->table; -struct recent_entry *e = v; -struct list_head *head = e->list.next; +const struct recent_entry *e = v; +const struct list_head *head = e->list.next;while (head == &t->iphash[st->bucket]) {if (++st->bucket >= ip_list_hash_size)
@@ -366,8 +410,14 @@ static int recent_seq_show(struct seq_file *seq, void *v)unsigned int i; i = (e->index -1 ) % ip_pkt_list_tot; -seq_printf (seq,"src=%u.%u.%u.%u ttl: %u last_seen: %lu oldest_pkt: %u" , -NIPQUAD (e->addr), e->ttl, e->stamps[i], e->index); +if (e->family ==AF_INET ) +seq_printf (seq,"src=" NIPQUAD_FMT " ttl: %u last_seen: %lu " +"oldest_pkt: %u" ,NIPQUAD (e->addr.ip), e->ttl, + e->stamps[i], e->index); +else +seq_printf (seq,"src=" NIP6_FMT " ttl: %u last_seen: %lu " +"oldest_pkt: %u" ,NIP6 (e->addr.in6), e->ttl, + e->stamps[i], e->index);for (i =0 ; i < e->nstamps; i++)seq_printf (seq,"%s %lu" , i ?"," :"" , e->stamps[i]);seq_printf (seq,"\n" );
@@ -400,45 +450,59 @@ static ssize_t recent_proc_write(struct file *file, const char __user *input,const struct proc_dir_entry *pde =PDE (file->f_path.dentry->d_inode);struct recent_table *t = pde->data;struct recent_entry *e; -char buf[sizeof ("+255.255.255.255" )], *c = buf; -__be32 addr; -int add; +char buf[sizeof ("+b335:1d35:1e55:dead:c0de:1715:5afe:c0de" )], *c = buf; +union nf_inet_addr addr; +u_int16_t family; +bool add, succ; +if (size ==0 ) +return 0 ;if (size >sizeof (buf)) size =sizeof (buf); -if (copy_from_user (buf, input, size)) +if (copy_from_user (buf, input, size) !=0 )return -EFAULT ; -while (isspace (*c)) - c++; -if (size - (c - buf) <5 ) -return c - buf; -if (!strncmp (c,"clear" ,5 )) { - c +=5 ; +/* Strict protocol! */ +if (*loff !=0 ) +return -ESPIPE ; +switch (*c) { +case '/' :/* flush table */ spin_lock_bh (&recent_lock);recent_table_flush (t);spin_unlock_bh (&recent_lock); -return c - buf; - } - -switch (*c) { -case '-' : - add =0 ; - c++; +return size; +case '-' :/* remove address */ + add = false;break ; -case '+' : - c++; -default : - add =1 ; +case '+' :/* add address */ + add = true;break ; +default : + printk(KERN_INFO KBUILD_MODNAME ": Need +ip, -ip or /\n"); +return -EINVAL ; + } + + ++c; + --size; +if (strnchr (c, size,':' ) !=NULL ) { + family =AF_INET6 ; + succ =in6_pton (c, size, (void *)&addr,'\n' ,NULL ); + }else { + family =AF_INET ; + succ =in4_pton (c, size, (void *)&addr,'\n' ,NULL ); + } + +if (!succ) { + printk(KERN_INFO KBUILD_MODNAME ": illegal address written " + "to procfs\n"); +return -EINVAL ; } - addr =in_aton (c);spin_lock_bh (&recent_lock); - e =recent_entry_lookup (t, addr,0 ); + e =recent_entry_lookup (t, &addr, family,0 );if (e ==NULL ) {if (add) -recent_entry_init (t, addr,0 ); +recent_entry_init (t, &addr, family,0 ); }else {if (add)recent_entry_update (t, e);
@@ -446,7 +510,9 @@ static ssize_t recent_proc_write(struct file *file, const char __user *input,recent_entry_remove (t, e); }spin_unlock_bh (&recent_lock); -return size; +/* Note we removed one above */ + *loff += size +1 ; +return size +1 ; }static const struct file_operations recent_fops = {
@@ -458,14 +524,27 @@ static const struct file_operations recent_fops = { };#endif /* CONFIG_PROC_FS */ -static struct xt_match recent_mt_reg__read_mostly = { - .name ="recent" , - .family =AF_INET , - .match = recent_mt, - .matchsize =sizeof (struct xt_recent_mtinfo ), - .checkentry = recent_mt_check, - .destroy = recent_mt_destroy, - .me =THIS_MODULE , +static struct xt_match recent_mt_reg[]__read_mostly = { + { + .name ="recent" , + .revision =0 , + .family =AF_INET , + .match = recent_mt, + .matchsize =sizeof (struct xt_recent_mtinfo ), + .checkentry = recent_mt_check, + .destroy = recent_mt_destroy, + .me =THIS_MODULE , + }, + { + .name ="recent" , + .revision =0 , + .family =AF_INET6 , + .match = recent_mt, + .matchsize =sizeof (struct xt_recent_mtinfo ), + .checkentry = recent_mt_check, + .destroy = recent_mt_destroy, + .me =THIS_MODULE , + }, };static int __init recent_mt_init (void )
@@ -476,13 +555,13 @@ static int __init recent_mt_init(void)return -EINVAL ; ip_list_hash_size =1 <<fls (ip_list_tot); - err =xt_register_match (&recent_mt_reg); + err =xt_register_matches (recent_mt_reg,ARRAY_SIZE (recent_mt_reg));#ifdef CONFIG_PROC_FS if (err)return err; - proc_dir =proc_mkdir ("ipt_recent" , init_net.proc_net); + proc_dir =proc_mkdir ("xt_recent" , init_net.proc_net);if (proc_dir ==NULL ) { -xt_unregister_match (&recent_mt_reg); +xt_unregister_matches (recent_mt_reg,ARRAY_SIZE (recent_mt_reg)); err = -ENOMEM ; }#endif
@@ -492,9 +571,9 @@ static int __init recent_mt_init(void) static void __exit recent_mt_exit(void) {BUG_ON (!list_empty (&tables)); -xt_unregister_match (&recent_mt_reg); +xt_unregister_matches (recent_mt_reg,ARRAY_SIZE (recent_mt_reg));#ifdef CONFIG_PROC_FS -remove_proc_entry ("ipt_recent" , init_net.proc_net); +remove_proc_entry ("xt_recent" , init_net.proc_net);#endif }
Signature · 6 lines
1.5.4.4 -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 12/24] [NETFILTER]: xt_recent: IPv6 support
Quoted 6 lines · Jan Engelhardt
This updates
xt_recentto support IPv6 handling. It is sort of a flag day, as the new control directory is/proc/net/xt_recentwith a new, more strict protocol (the string you ought to write into/proc/net/xt_recent/LIST). But on the other hand, I kept the binary interface towards iptables (which is quite memory consuming I must say) to keep the patch small.
No flag days please, either keep ipt_recent as compat interface (in case you want to share lists) or do something like hashlimit and add one file per family, but no xt_recent file.
Re: [PATCH 12/24] [NETFILTER]: xt_recent: IPv6 support
Quoted 11 lines · Patrick McHardy
Quoted 6 lines · Jan Engelhardt
This updates
xt_recentto support IPv6 handling. It is sort of a flag day, as the new control directory is/proc/net/xt_recentwith a new, more strict protocol (the string you ought to write into/proc/net/xt_recent/LIST). But on the other hand, I kept the binary interface towards iptables (which is quite memory consuming I must say) to keep the patch small.No flag days please, either keep
ipt_recentas compat interface (in case you want to share lists) or do something like hashlimit and add one file per family, but noxt_recentfile.
I actually thought of using sysfs instead — do you know if I can tie a sysfs file to a seq_file?
Signature · 5 lines
make boldconfig -- to boldly select what no one has selected before -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 12/24] [NETFILTER]: xt_recent: IPv6 support
Quoted 10 lines · Jan Engelhardt
Quoted 8 lines · Patrick McHardy
Quoted 6 lines · Jan Engelhardt
This updates
xt_recentto support IPv6 handling. It is sort of a flag day, as the new control directory is/proc/net/xt_recentwith a new, more strict protocol (the string you ought to write into/proc/net/xt_recent/LIST). But on the other hand, I kept the binary interface towards iptables (which is quite memory consuming I must say) to keep the patch small.
Quoted 6 lines
Quoted 3 lines
No flag days please, either keep
ipt_recentas compat interface (in case you want to share lists) or do something like hashlimit and add one file per family, but noxt_recentfile.I actually thought of using sysfs instead — do you know if I can tie a sysfs file to a
seq_file?
I have no idea, but we've discussed this before, all netfilter modules use /proc, so we've decided to keep it this way for consistency. Its also doesn't seem to be a good fit for changing lists of addresses.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 12/24] [NETFILTER]: xt_recent: IPv6 support
Quoted 6 lines · Patrick McHardy
Quoted 3 lines
I actually thought of using sysfs instead — do you know if I can tie a sysfs file to a
seq_file?I have no idea, but we've discussed this before, all netfilter modules use /proc,
I miss the “do not use /proc for new files” consensus.. :-/
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 12/24] [NETFILTER]: xt_recent: IPv6 support
Quoted 10 lines · Jan Engelhardt
Quoted 6 lines · Patrick McHardy
Quoted 3 lines
I actually thought of using sysfs instead — do you know if I can tie a sysfs file to a
seq_file?I have no idea, but we've discussed this before, all netfilter modules use /proc,
I miss the “do not use /proc for new files” consensus.. :-/
That has never been the consensus for networking.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 12/24] [NETFILTER]: xt_recent: IPv6 support
In reply to Jan EngelhardtQuoted 10 lines · Jan Engelhardt
Quoted 8 lines · Patrick McHardy
Quoted 6 lines · Jan Engelhardt
This updates
xt_recentto support IPv6 handling. It is sort of a flag day, as the new control directory is/proc/net/xt_recentwith a new, more strict protocol (the string you ought to write into/proc/net/xt_recent/LIST). But on the other hand, I kept the binary interface towards iptables (which is quite memory consuming I must say) to keep the patch small.
Quoted 6 lines
Quoted 3 lines
No flag days please, either keep
ipt_recentas compat interface (in case you want to share lists) or do something like hashlimit and add one file per family, but noxt_recentfile.I actually thought of using sysfs instead????? do you know if I can tie a sysfs file to a
seq_file?
No you can not, as that would defeat the "one value per file" rule for sysfs files.
thanks,
greg k-h
PATCH 13/24 : nf_nat: autoload IPv4 connection tracking
In reply to Jan EngelhardtWithout this patch, the generic L3 tracker would kick in if nf_conntrack_ipv4 was not loaded before nf_nat, which would lead to translation problems with ICMP errors.
NAT does not make sense without IPv4 connection tracking anyway, so just add a call to need_ipv4_conntrack().
--- net/ipv4/netfilter/nf_nat_core.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
net/ipv4/netfilter/nf_nat_core.c +2 -0
@@ -629,6 +629,8 @@ static int __init nf_nat_init(void)size_t i;int ret; +need_ipv4_conntrack (); + ret =nf_ct_extend_register (&nat_extend);if (ret <0 ) {printk (KERN_ERR "nf_nat_core: Unable to register extension\n" );
Signature · 1 line
1.5.4.4
Patrick McHardy
AppliedRe: [PATCH 13/24] [NETFILTER]: nf_nat: autoload IPv4 connection tracking
Quoted 6 lines · Jan Engelhardt
Without this patch, the generic L3 tracker would kick in if
nf_conntrack_ipv4was not loaded beforenf_nat, which would lead to translation problems with ICMP errors.NAT does not make sense without IPv4 connection tracking anyway, so just add a call to
need_ipv4_conntrack().
Queued for 2.6.25, thanks.
PATCH 14/24 : Use bool in nf_conntrack_l4proto
In reply to Jan Engelhardt--- include/net/netfilter/nf_conntrack_l4proto.h | 13 ++-- net/ipv4/netfilter/nf_conntrack_proto_icmp.c | 25 ++++---- net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c | 27 ++++----- net/netfilter/nf_conntrack_proto_generic.c | 20 +++--- net/netfilter/nf_conntrack_proto_gre.c | 25 ++++---- net/netfilter/nf_conntrack_proto_sctp.c | 33 +++++------ net/netfilter/nf_conntrack_proto_tcp.c | 48 +++++++--------- net/netfilter/nf_conntrack_proto_udp.c | 21 +++---- net/netfilter/nf_conntrack_proto_udplite.c | 22 ++++---- 9 files changed, 111 insertions(+), 123 deletions(-)
include/net/netfilter/nf_conntrack_l4proto.h +6 -7
@@ -25,15 +25,14 @@ struct nf_conntrack_l4proto/* Try to fill in the third arg: dataoff is offset past network protocol hdr. Return true if possible. */ -int (*pkt_to_tuple)(const struct sk_buff *skb, -unsigned int dataoff, -struct nf_conntrack_tuple *tuple); +bool (*pkt_to_tuple)(const struct sk_buff *skb,unsigned int dataoff, +struct nf_conntrack_tuple *tuple);/* Invert the per-proto part of the tuple: ie. turn xmit into reply. * Some packets can't be inverted: return 0 in that case. */ -int (*invert_tuple)(struct nf_conntrack_tuple *inverse, -const struct nf_conntrack_tuple *orig); +bool (*invert_tuple)(struct nf_conntrack_tuple *inverse, +const struct nf_conntrack_tuple *orig);/* Returns verdict for packet, or -1 for invalid. */ int (*packet)(struct nf_conn *ct,
@@ -45,8 +44,8 @@ struct nf_conntrack_l4proto/* Called when a new connection for this protocol found; * returns TRUE if it's OK. If so, packet() called next. */ -int (*new)(struct nf_conn *ct,const struct sk_buff *skb, -unsigned int dataoff); +bool (*new)(struct nf_conn *ct,const struct sk_buff *skb, +unsigned int dataoff);/* Called when a conntrack entry is destroyed */ void (*destroy)(struct nf_conn *ct);
net/ipv4/netfilter/nf_conntrack_proto_icmp.c +12 -13
@@ -22,22 +22,21 @@static unsigned long nf_ct_icmp_timeout__read_mostly =30 *HZ ; -static int icmp_pkt_to_tuple (const struct sk_buff *skb, -unsigned int dataoff, -struct nf_conntrack_tuple *tuple) +static bool icmp_pkt_to_tuple (const struct sk_buff *skb,unsigned int dataoff, +struct nf_conntrack_tuple *tuple) {const struct icmphdr *hp;struct icmphdr _hdr; hp =skb_header_pointer (skb, dataoff,sizeof (_hdr), &_hdr);if (hp ==NULL ) -return 0 ; +return false; tuple->dst.u.icmp.type = hp->type; tuple->src.u.icmp.id = hp->un.echo.id; tuple->dst.u.icmp.code = hp->code; -return 1 ; +return true; }/* Add 1; spaces filled with 0. */
@@ -52,17 +51,17 @@ static const u_int8_t invmap[] = { [ICMP_ADDRESSREPLY] = ICMP_ADDRESS + 1 }; -static int icmp_invert_tuple (struct nf_conntrack_tuple *tuple, -const struct nf_conntrack_tuple *orig) +static bool icmp_invert_tuple (struct nf_conntrack_tuple *tuple, +const struct nf_conntrack_tuple *orig) {if (orig->dst.u.icmp.type >=sizeof (invmap) || !invmap[orig->dst.u.icmp.type]) -return 0 ; +return false; tuple->src.u.icmp.id = orig->src.u.icmp.id; tuple->dst.u.icmp.type = invmap[orig->dst.u.icmp.type] -1 ; tuple->dst.u.icmp.code = orig->dst.u.icmp.code; -return 1 ; +return true; }/* Print out the per-protocol part of the tuple. */
@@ -101,8 +100,8 @@ static int icmp_packet(struct nf_conn *ct, }/* Called when a new connection for this protocol found. */ -static int icmp_new (struct nf_conn *ct, -const struct sk_buff *skb,unsigned int dataoff) +static bool icmp_new (struct nf_conn *ct,const struct sk_buff *skb, +unsigned int dataoff) {static const u_int8_t valid_new[] = { [ICMP_ECHO ] =1 ,
@@ -117,10 +116,10 @@ static int icmp_new(struct nf_conn *ct,pr_debug ("icmp: can't create new conn with type %u\n" , ct->tuplehash[0 ].tuple.dst.u.icmp.type);NF_CT_DUMP_TUPLE (&ct->tuplehash[0 ].tuple); -return 0 ; +return false; }atomic_set (&ct->proto.icmp.count,0 ); -return 1 ; +return true; }/* Returns conntrack if it dealt with ICMP, and filled in skb fields */
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +13 -14
@@ -28,21 +28,21 @@static unsigned long nf_ct_icmpv6_timeout__read_mostly =30 *HZ ; -static int icmpv6_pkt_to_tuple (const struct sk_buff *skb, -unsigned int dataoff, -struct nf_conntrack_tuple *tuple) +static bool +icmpv6_pkt_to_tuple (const struct sk_buff *skb,unsigned int dataoff, +struct nf_conntrack_tuple *tuple) {const struct icmp6hdr *hp;struct icmp6hdr _hdr; hp =skb_header_pointer (skb, dataoff,sizeof (_hdr), &_hdr);if (hp ==NULL ) -return 0 ; +return false; tuple->dst.u.icmp.type = hp->icmp6_type; tuple->src.u.icmp.id = hp->icmp6_identifier; tuple->dst.u.icmp.code = hp->icmp6_code; -return 1 ; +return true; }/* Add 1; spaces filled with 0. */
@@ -53,17 +53,17 @@ static const u_int8_t invmap[] = { [ICMPV6_NI_REPLY - 128] = ICMPV6_NI_REPLY +1 }; -static int icmpv6_invert_tuple (struct nf_conntrack_tuple *tuple, -const struct nf_conntrack_tuple *orig) +static bool icmpv6_invert_tuple (struct nf_conntrack_tuple *tuple, +const struct nf_conntrack_tuple *orig) {int type = orig->dst.u.icmp.type -128 ;if (type <0 || type >=sizeof (invmap) || !invmap[type]) -return 0 ; +return false; tuple->src.u.icmp.id = orig->src.u.icmp.id; tuple->dst.u.icmp.type = invmap[type] -1 ; tuple->dst.u.icmp.code = orig->dst.u.icmp.code; -return 1 ; +return true; }/* Print out the per-protocol part of the tuple. */
@@ -102,9 +102,8 @@ static int icmpv6_packet(struct nf_conn *ct, }/* Called when a new connection for this protocol found. */ -static int icmpv6_new (struct nf_conn *ct, -const struct sk_buff *skb, -unsigned int dataoff) +static bool icmpv6_new (struct nf_conn *ct,const struct sk_buff *skb, +unsigned int dataoff) {static const u_int8_t valid_new[] = { [ICMPV6_ECHO_REQUEST -128 ] =1 ,
@@ -117,10 +116,10 @@ static int icmpv6_new(struct nf_conn *ct,pr_debug ("icmpv6: can't create new conn with type %u\n" , type +128 );NF_CT_DUMP_TUPLE (&ct->tuplehash[0 ].tuple); -return 0 ; +return false; }atomic_set (&ct->proto.icmp.count,0 ); -return 1 ; +return true; } static int
net/netfilter/nf_conntrack_proto_generic.c +10 -10
@@ -14,23 +14,23 @@static unsigned int nf_ct_generic_timeout__read_mostly =600 *HZ ; -static int generic_pkt_to_tuple (const struct sk_buff *skb, -unsigned int dataoff, -struct nf_conntrack_tuple *tuple) +static bool +generic_pkt_to_tuple (const struct sk_buff *skb,unsigned int dataoff, +struct nf_conntrack_tuple *tuple) { tuple->src.u.all =0 ; tuple->dst.u.all =0 ; -return 1 ; +return true; } -static int generic_invert_tuple (struct nf_conntrack_tuple *tuple, -const struct nf_conntrack_tuple *orig) +static bool generic_invert_tuple (struct nf_conntrack_tuple *tuple, +const struct nf_conntrack_tuple *orig) { tuple->src.u.all =0 ; tuple->dst.u.all =0 ; -return 1 ; +return true; }/* Print out the per-protocol part of the tuple. */
@@ -53,10 +53,10 @@ static int packet(struct nf_conn *ct, }/* Called when a new connection for this protocol found. */ -static int new (struct nf_conn *ct,const struct sk_buff *skb, -unsigned int dataoff) +static bool new (struct nf_conn *ct,const struct sk_buff *skb, +unsigned int dataoff) { -return 1 ; +return true; }#ifdef CONFIG_SYSCTL
net/netfilter/nf_conntrack_proto_gre.c +12 -13
@@ -148,18 +148,17 @@ EXPORT_SYMBOL_GPL(nf_ct_gre_keymap_destroy);/* PUBLIC CONNTRACK PROTO HELPER FUNCTIONS */ /* invert gre part of tuple */ -static int gre_invert_tuple (struct nf_conntrack_tuple *tuple, -const struct nf_conntrack_tuple *orig) +static bool gre_invert_tuple (struct nf_conntrack_tuple *tuple, +const struct nf_conntrack_tuple *orig) { tuple->dst.u.gre.key = orig->src.u.gre.key; tuple->src.u.gre.key = orig->dst.u.gre.key; -return 1 ; +return true; }/* gre hdr info to tuple */ -static int gre_pkt_to_tuple (const struct sk_buff *skb, -unsigned int dataoff, -struct nf_conntrack_tuple *tuple) +static bool gre_pkt_to_tuple (const struct sk_buff *skb,unsigned int dataoff, +struct nf_conntrack_tuple *tuple) {const struct gre_hdr_pptp *pgrehdr;struct gre_hdr_pptp _pgrehdr;
@@ -173,24 +172,24 @@ static int gre_pkt_to_tuple(const struct sk_buff *skb,/* try to behave like "nf_conntrack_proto_generic" */ tuple->src.u.all =0 ; tuple->dst.u.all =0 ; -return 1 ; +return true; }/* PPTP header is variable length, only need up to the call_id field */ pgrehdr =skb_header_pointer (skb, dataoff,8 , &_pgrehdr);if (!pgrehdr) -return 1 ; +return true;if (ntohs (grehdr->protocol) !=GRE_PROTOCOL_PPTP ) {pr_debug ("GRE_VERSION_PPTP but unknown proto\n" ); -return 0 ; +return false; } tuple->dst.u.gre.key = pgrehdr->call_id; srckey =gre_keymap_lookup (tuple); tuple->src.u.gre.key = srckey; -return 1 ; +return true; }/* print gre part of tuple */
@@ -235,8 +234,8 @@ static int gre_packet(struct nf_conn *ct, }/* Called when a new connection for this protocol found. */ -static int gre_new (struct nf_conn *ct,const struct sk_buff *skb, -unsigned int dataoff) +static bool gre_new (struct nf_conn *ct,const struct sk_buff *skb, +unsigned int dataoff) {pr_debug (": " );NF_CT_DUMP_TUPLE (&ct->tuplehash[IP_CT_DIR_ORIGINAL ].tuple);
@@ -246,7 +245,7 @@ static int gre_new(struct nf_conn *ct, const struct sk_buff *skb, ct->proto.gre.stream_timeout =GRE_STREAM_TIMEOUT ; ct->proto.gre.timeout =GRE_TIMEOUT ; -return 1 ; +return true; }/* Called when a conntrack entry has already been removed from the hashes
net/netfilter/nf_conntrack_proto_sctp.c +16 -17
@@ -130,28 +130,27 @@ static const u8 sctp_conntracks[2][9][SCTP_CONNTRACK_MAX] = { } }; -static int sctp_pkt_to_tuple (const struct sk_buff *skb, -unsigned int dataoff, -struct nf_conntrack_tuple *tuple) +static bool sctp_pkt_to_tuple (const struct sk_buff *skb,unsigned int dataoff, +struct nf_conntrack_tuple *tuple) {sctp_sctphdr_t _hdr, *hp;/* Actually only need first 8 bytes. */ hp =skb_header_pointer (skb, dataoff,8 , &_hdr);if (hp ==NULL ) -return 0 ; +return false; tuple->src.u.sctp.port = hp->source; tuple->dst.u.sctp.port = hp->dest; -return 1 ; +return true; } -static int sctp_invert_tuple (struct nf_conntrack_tuple *tuple, -const struct nf_conntrack_tuple *orig) +static bool sctp_invert_tuple (struct nf_conntrack_tuple *tuple, +const struct nf_conntrack_tuple *orig) { tuple->src.u.sctp.port = orig->dst.u.sctp.port; tuple->dst.u.sctp.port = orig->src.u.sctp.port; -return 1 ; +return true; }/* Print out the per-protocol part of the tuple. */
@@ -390,8 +389,8 @@ out: }/* Called when a new connection for this protocol found. */ -static int sctp_new (struct nf_conn *ct,const struct sk_buff *skb, -unsigned int dataoff) +static bool sctp_new (struct nf_conn *ct,const struct sk_buff *skb, +unsigned int dataoff) {enum sctp_conntrack new_state;sctp_sctphdr_t _sctph, *sh;
@@ -401,16 +400,16 @@ static int sctp_new(struct nf_conn *ct, const struct sk_buff *skb, sh =skb_header_pointer (skb, dataoff,sizeof (_sctph), &_sctph);if (sh ==NULL ) -return 0 ; +return false;if (do_basic_checks (ct, skb, dataoff, map) !=0 ) -return 0 ; +return false;/* If an OOTB packet has any of these chunks discard (Sec 8.4) */ if (test_bit (SCTP_CID_ABORT , map) ||test_bit (SCTP_CID_SHUTDOWN_COMPLETE , map) ||test_bit (SCTP_CID_COOKIE_ACK , map)) -return 0 ; +return false; new_state =SCTP_CONNTRACK_MAX ; for_each_sctp_chunk (skb, sch, _sch, offset, dataoff, count) {
@@ -422,7 +421,7 @@ static int sctp_new(struct nf_conn *ct, const struct sk_buff *skb,if (new_state ==SCTP_CONNTRACK_NONE || new_state ==SCTP_CONNTRACK_MAX ) {pr_debug ("nf_conntrack_sctp: invalid new deleting.\n" ); -return 0 ; +return false; }/* Copy the vtag into the state info */
@@ -433,7 +432,7 @@ static int sctp_new(struct nf_conn *ct, const struct sk_buff *skb, ih =skb_header_pointer (skb, offset +sizeof (sctp_chunkhdr_t),sizeof (_inithdr), &_inithdr);if (ih ==NULL ) -return 0 ; +return false;pr_debug ("Setting vtag %x for new conn\n" , ih->init_tag);
@@ -442,7 +441,7 @@ static int sctp_new(struct nf_conn *ct, const struct sk_buff *skb, ih->init_tag; }else {/* Sec 8.5.1 (A) */ -return 0 ; +return false; } }/* If it is a shutdown ack OOTB packet, we expect a return
@@ -456,7 +455,7 @@ static int sctp_new(struct nf_conn *ct, const struct sk_buff *skb, ct->proto.sctp.state = new_state; } -return 1 ; +return true; }#ifdef CONFIG_SYSCTL
net/netfilter/nf_conntrack_proto_tcp.c +21 -27
119 lines not on this page · raw message
net/netfilter/nf_conntrack_proto_udp.c +10 -11
@@ -26,9 +26,8 @@static unsigned int nf_ct_udp_timeout__read_mostly =30 *HZ ;static unsigned int nf_ct_udp_timeout_stream__read_mostly =180 *HZ ; -static int udp_pkt_to_tuple (const struct sk_buff *skb, -unsigned int dataoff, -struct nf_conntrack_tuple *tuple) +static bool udp_pkt_to_tuple (const struct sk_buff *skb,unsigned int dataoff, +struct nf_conntrack_tuple *tuple) {const struct udphdr *hp;struct udphdr _hdr;
@@ -36,20 +35,20 @@ static int udp_pkt_to_tuple(const struct sk_buff *skb,/* Actually only need first 8 bytes. */ hp =skb_header_pointer (skb, dataoff,sizeof (_hdr), &_hdr);if (hp ==NULL ) -return 0 ; +return false; tuple->src.u.udp.port = hp->source; tuple->dst.u.udp.port = hp->dest; -return 1 ; +return true; } -static int udp_invert_tuple (struct nf_conntrack_tuple *tuple, -const struct nf_conntrack_tuple *orig) +static bool udp_invert_tuple (struct nf_conntrack_tuple *tuple, +const struct nf_conntrack_tuple *orig) { tuple->src.u.udp.port = orig->dst.u.udp.port; tuple->dst.u.udp.port = orig->src.u.udp.port; -return 1 ; +return true; }/* Print out the per-protocol part of the tuple. */
@@ -83,10 +82,10 @@ static int udp_packet(struct nf_conn *ct, }/* Called when a new connection for this protocol found. */ -static int udp_new (struct nf_conn *ct,const struct sk_buff *skb, -unsigned int dataoff) +static bool udp_new (struct nf_conn *ct,const struct sk_buff *skb, +unsigned int dataoff) { -return 1 ; +return true; } static int udp_error(struct sk_buff *skb, unsigned int dataoff,
net/netfilter/nf_conntrack_proto_udplite.c +11 -11
@@ -27,28 +27,28 @@static unsigned int nf_ct_udplite_timeout__read_mostly =30 *HZ ;static unsigned int nf_ct_udplite_timeout_stream__read_mostly =180 *HZ ; -static int udplite_pkt_to_tuple (const struct sk_buff *skb, -unsigned int dataoff, -struct nf_conntrack_tuple *tuple) +static bool +udplite_pkt_to_tuple (const struct sk_buff *skb,unsigned int dataoff, +struct nf_conntrack_tuple *tuple) {const struct udphdr *hp;struct udphdr _hdr; hp =skb_header_pointer (skb, dataoff,sizeof (_hdr), &_hdr);if (hp ==NULL ) -return 0 ; +return false; tuple->src.u.udp.port = hp->source; tuple->dst.u.udp.port = hp->dest; -return 1 ; +return true; } -static int udplite_invert_tuple (struct nf_conntrack_tuple *tuple, -const struct nf_conntrack_tuple *orig) +static bool udplite_invert_tuple (struct nf_conntrack_tuple *tuple, +const struct nf_conntrack_tuple *orig) { tuple->src.u.udp.port = orig->dst.u.udp.port; tuple->dst.u.udp.port = orig->src.u.udp.port; -return 1 ; +return true; }/* Print out the per-protocol part of the tuple. */
@@ -83,10 +83,10 @@ static int udplite_packet(struct nf_conn *ct, }/* Called when a new connection for this protocol found. */ -static int udplite_new (struct nf_conn *ct,const struct sk_buff *skb, -unsigned int dataoff) +static bool udplite_new (struct nf_conn *ct,const struct sk_buff *skb, +unsigned int dataoff) { -return 1 ; +return true; } static int udplite_error(struct sk_buff *skb, unsigned int dataoff,
Signature · 1 line
1.5.4.4
Re: [PATCH 14/24] [NETFILTER]: Use bool in nf_conntrack_l4proto
Quoted 11 lines · Jan Engelhardt
Signed-off-by Jan Engelhardt <[email protected]>--- include/net/netfilter/nf_conntrack_l4proto.h | 13 ++-- net/ipv4/netfilter/nf_conntrack_proto_icmp.c | 25 ++++---- net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c | 27 ++++----- net/netfilter/nf_conntrack_proto_generic.c | 20 +++--- net/netfilter/nf_conntrack_proto_gre.c | 25 ++++---- net/netfilter/nf_conntrack_proto_sctp.c | 33 +++++------ net/netfilter/nf_conntrack_proto_tcp.c | 48 +++++++--------- net/netfilter/nf_conntrack_proto_udp.c | 21 +++---- net/netfilter/nf_conntrack_proto_udplite.c | 22 ++++----
ERROR: use tabs not spaces
#13: FILE: include/net/netfilter/nf_conntrack_l4proto.h:29:
+^I struct nf_conntrack_tuple *tuple);$
ERROR: use tabs not spaces
#21: FILE: include/net/netfilter/nf_conntrack_l4proto.h:35:
+^I const struct nf_conntrack_tuple *orig);$
ERROR: use tabs not spaces
#32: FILE: include/net/netfilter/nf_conntrack_l4proto.h:48:
+^I unsigned int dataoff);$
<hundreds more>
Jan, applying your patches is getting too much work, I'm dropping everything I haven't applied yet. Your other patches also have checkpatch errors, I'll fix those up :|
Some hints for the future to make this easier for both of us:
- submit small batches, split into logical units
- don't mix cleanups with real changes
- avoid style changes like this, especially when the entire file uses a consistent style:
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c line 33
Quoted 6 lines
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +3
-3-static int icmpv6_pkt_to_tuple (const struct sk_buff *skb, -unsigned int dataoff, -struct nf_conntrack_tuple *tuple) +static bool +icmpv6_pkt_to_tuple (const struct sk_buff *skb,unsigned int dataoff, +struct nf_conntrack_tuple *tuple)
- run checkpatch
- run sparse with endian checks
- compile test all the code your changing, including CONFIG_COMPAT
Re: [PATCH 14/24] [NETFILTER]: Use bool in nf_conntrack_l4proto
Quoted 7 lines · Patrick McHardy
ERROR: use tabs not spaces
#32: FILE:include/net/netfilter/nf_conntrack_l4proto.h:48:
+^I unsigned int dataoff);$<hundreds more>
Quoted 7 lines
Jan, applying your patches is getting too much work, I'm dropping everything I haven't applied yet. Your other patches also have checkpatch errors, I'll fix those up :|
Some hints for the future to make this easier for both of us:
- submit small batches, split into logical units
This sets me up a bit.. sometimes it's "should have folded these" (like the const annotation patches that were at the start of the series), then it's "smaller batches" :-/
Quoted 6 lines
- avoid style changes like this, especially when the entire file uses a consistent style:
Quoted 3 lines
-static int icmpv6_pkt_to_tuple(const struct
sk_buff*skb,
- unsigned int dataoff,
- structnf_conntrack_tuple*tuple)
allow me the remark of "consistently odd", as you can see what a change in indent does when spaces are not used in the right place. But whatever, yeah.
Quoted 5 lines
Quoted 3 lines
+static bool
+icmpv6_pkt_to_tuple(const structsk_buff*skb, unsigned int dataoff,
+ structnf_conntrack_tuple*tuple)- run checkpatch
Not before I rip out that incredibly stupid "use tabs" warning. The warning may be right for users who apparently have not dealt with patch submitting process a lot, but for longtime contributers that get their style right the 1st time it's just wrong.
That program has no sense for when spaces are needed.
The style I used and use (tabs=indent, spaces=align - it only makes sense) was always fine by you, but now it's not because checkpatch says so?
Quoted 3 lines
- don't mix cleanups with real changes
- run sparse with endian checks
- compile test all the code your changing, includingCONFIG_COMPAT
Will do.
Re: [PATCH 14/24] [NETFILTER]: Use bool in nf_conntrack_l4proto
Quoted 9 lines · Jan Engelhardt
Quoted 4 lines · Patrick McHardy
Some hints for the future to make this easier for both of us:
- submit small batches, split into logical units
This sets me up a bit.. sometimes it's "should have folded these" (like the const annotation patches that were at the start of the series), then it's "smaller batches" :-/
Folding patches makes the batches smaller (note: batch, not patch) :) What I meant by this was to not flood me with 30 patches three times at once, if issues come up in one of the first patches it often results in the later ones not applying. Logical batches, like
- batch 1: constification
- batch 2: boolean conversions
- batch x: things like rename ipt_recent, add IPv6 support
- batch y: arp_tables userspace interface changes in order to achieve X.
Quoted 15 lines
Quoted 6 lines
- avoid style changes like this, especially when the entire file uses a consistent style:
Quoted 3 lines
-static int icmpv6_pkt_to_tuple(const struct
sk_buff*skb,
- unsigned int dataoff,
- structnf_conntrack_tuple*tuple)allow me the remark of "consistently odd", as you can see what a change in indent does when spaces are not used in the right place. But whatever, yeah.
Quoted 4 lines
Quoted 3 lines
+static bool
+icmpv6_pkt_to_tuple(const structsk_buff*skb, unsigned int dataoff,
+ structnf_conntrack_tuple*tuple)
Quoted 6 lines
Quoted 1 line
- run checkpatch
Not before I rip out that incredibly stupid "use tabs" warning. The warning may be right for users who apparently have not dealt with patch submitting process a lot, but for longtime contributers that get their style right the 1st time it's just wrong.
No, we've fixed up net/ more than once using scripts before checkpatch even existed. Simple: keep existing style.
Quoted 4 lines
That program has no sense for when spaces are needed.
The style I used and use (tabs=indent, spaces=align - it only makes sense) was always fine by you, but now it's not because checkpatch says so?
See above. I used to use a different indenting style as well, but I prefer consistency over having it exactly as I like it.
Quoted 6 lines
Quoted 3 lines
- don't mix cleanups with real changes
- run sparse with endian checks
- compile test all the code your changing, includingCONFIG_COMPATWill do.
PATCH 15/24 : Use bool in nf_conntrack_l3proto
In reply to Jan Engelhardt--- include/net/netfilter/nf_conntrack_l3proto.h | 10 +++++----- net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | 14 +++++++------- net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c | 14 +++++++------- net/netfilter/nf_conntrack_l3proto_generic.c | 12 ++++++------ 4 files changed, 25 insertions(+), 25 deletions(-)
include/net/netfilter/nf_conntrack_l3proto.h +5 -5
@@ -28,15 +28,15 @@ struct nf_conntrack_l3proto* Try to fill in the third arg: nhoff is offset of l3 proto * hdr. Return true if possible. */ -int (*pkt_to_tuple)(const struct sk_buff *skb,unsigned int nhoff, -struct nf_conntrack_tuple *tuple); +bool (*pkt_to_tuple)(const struct sk_buff *skb,unsigned int nhoff, +struct nf_conntrack_tuple *tuple);/* * Invert the per-proto part of the tuple: ie. turn xmit into reply. * Some packets can't be inverted: return 0 in that case. */ -int (*invert_tuple)(struct nf_conntrack_tuple *inverse, -const struct nf_conntrack_tuple *orig); +bool (*invert_tuple)(struct nf_conntrack_tuple *inverse, +const struct nf_conntrack_tuple *orig);/* Print out the per-protocol part of the tuple. */ int (*print_tuple)(struct seq_file *s,
@@ -51,7 +51,7 @@ struct nf_conntrack_l3proto* Called when a new connection for this protocol found; * returns TRUE if it's OK. If so, packet() called next. */ -int (*new)(struct nf_conn *ct,const struct sk_buff *skb); +bool (*new)(struct nf_conn *ct,const struct sk_buff *skb);/* * Called before tracking.
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c +7 -7
@@ -24,29 +24,29 @@#include <net/netfilter/nf_conntrack_core.h> #include <net/netfilter/ipv4/nf_conntrack_ipv4.h> -static int ipv4_pkt_to_tuple (const struct sk_buff *skb,unsigned int nhoff, -struct nf_conntrack_tuple *tuple) +static bool ipv4_pkt_to_tuple (const struct sk_buff *skb,unsigned int nhoff, +struct nf_conntrack_tuple *tuple) {const __be32 *ap;__be32 _addrs[2 ]; ap =skb_header_pointer (skb, nhoff + offsetof(struct iphdr , saddr),sizeof (u_int32_t) *2 , _addrs);if (ap ==NULL ) -return 0 ; +return false; tuple->src.u3.ip = ap[0 ]; tuple->dst.u3.ip = ap[1 ]; -return 1 ; +return true; } -static int ipv4_invert_tuple (struct nf_conntrack_tuple *tuple, -const struct nf_conntrack_tuple *orig) +static bool ipv4_invert_tuple (struct nf_conntrack_tuple *tuple, +const struct nf_conntrack_tuple *orig) { tuple->src.u3.ip = orig->dst.u3.ip; tuple->dst.u3.ip = orig->src.u3.ip; -return 1 ; +return true; } static int ipv4_print_tuple(struct seq_file *s,
net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c +7 -7
@@ -27,8 +27,8 @@#include <net/netfilter/nf_conntrack_l3proto.h> #include <net/netfilter/nf_conntrack_core.h> -static int ipv6_pkt_to_tuple (const struct sk_buff *skb,unsigned int nhoff, -struct nf_conntrack_tuple *tuple) +static bool ipv6_pkt_to_tuple (const struct sk_buff *skb,unsigned int nhoff, +struct nf_conntrack_tuple *tuple) {const u_int32_t *ap;u_int32_t _addrs[8 ];
@@ -36,21 +36,21 @@ static int ipv6_pkt_to_tuple(const struct sk_buff *skb, unsigned int nhoff, ap =skb_header_pointer (skb, nhoff + offsetof(struct ipv6hdr , saddr),sizeof (_addrs), _addrs);if (ap ==NULL ) -return 0 ; +return false;memcpy (tuple->src.u3.ip6, ap,sizeof (tuple->src.u3.ip6));memcpy (tuple->dst.u3.ip6, ap +4 ,sizeof (tuple->dst.u3.ip6)); -return 1 ; +return true; } -static int ipv6_invert_tuple (struct nf_conntrack_tuple *tuple, -const struct nf_conntrack_tuple *orig) +static bool ipv6_invert_tuple (struct nf_conntrack_tuple *tuple, +const struct nf_conntrack_tuple *orig) {memcpy (tuple->src.u3.ip6, orig->dst.u3.ip6,sizeof (tuple->src.u3.ip6));memcpy (tuple->dst.u3.ip6, orig->src.u3.ip6,sizeof (tuple->dst.u3.ip6)); -return 1 ; +return true; } static int ipv6_print_tuple(struct seq_file *s,
net/netfilter/nf_conntrack_l3proto_generic.c +6 -6
@@ -31,22 +31,22 @@#include <net/netfilter/nf_conntrack_core.h> #include <net/netfilter/ipv4/nf_conntrack_ipv4.h> -static int generic_pkt_to_tuple (const struct sk_buff *skb,unsigned int nhoff, -struct nf_conntrack_tuple *tuple) +static bool generic_pkt_to_tuple (const struct sk_buff *skb,unsigned int nhoff, +struct nf_conntrack_tuple *tuple) {memset (&tuple->src.u3,0 ,sizeof (tuple->src.u3));memset (&tuple->dst.u3,0 ,sizeof (tuple->dst.u3)); -return 1 ; +return true; } -static int generic_invert_tuple (struct nf_conntrack_tuple *tuple, -const struct nf_conntrack_tuple *orig) +static bool generic_invert_tuple (struct nf_conntrack_tuple *tuple, +const struct nf_conntrack_tuple *orig) {memset (&tuple->src.u3,0 ,sizeof (tuple->src.u3));memset (&tuple->dst.u3,0 ,sizeof (tuple->dst.u3)); -return 1 ; +return true; } static int generic_print_tuple(struct seq_file *s,
Signature · 1 line
1.5.4.4
PATCH 16/24 : nf_conntrack_sctp: const annotations
In reply to Jan Engelhardt--- net/netfilter/nf_conntrack_proto_sctp.c | 17 +++++++++++------ 1 files changed, 11 insertions(+), 6 deletions(-)
net/netfilter/nf_conntrack_proto_sctp.c +11 -6
@@ -33,7 +33,7 @@ static DEFINE_RWLOCK(sctp_lock);And so for me for SCTP :D -Kiran */ -static const char *sctp_conntrack_names[] = { +static const char *const sctp_conntrack_names[] = {"NONE" ,"CLOSED" ,"COOKIE_WAIT" ,
@@ -133,7 +133,8 @@ static const u8 sctp_conntracks[2][9][SCTP_CONNTRACK_MAX] = {static bool sctp_pkt_to_tuple (const struct sk_buff *skb,unsigned int dataoff,struct nf_conntrack_tuple *tuple) { -sctp_sctphdr_t _hdr, *hp; +const struct sctphdr *hp; +struct sctphdr _hdr;/* Actually only need first 8 bytes. */ hp =skb_header_pointer (skb, dataoff,8 , &_hdr);
@@ -291,8 +292,10 @@ static int sctp_packet(struct nf_conn *ct, {enum sctp_conntrack new_state, old_state;enum ip_conntrack_dir dir =CTINFO2DIR (ctinfo); -sctp_sctphdr_t _sctph, *sh; -sctp_chunkhdr_t _sch, *sch; +const struct sctphdr *sh; +struct sctphdr _sctph; +const struct sctp_chunkhdr *sch; +struct sctp_chunkhdr _sch;u_int32_t offset, count;unsigned long map[256 /sizeof (unsigned long )] = {0 };
@@ -393,8 +396,10 @@ static bool sctp_new(struct nf_conn *ct, const struct sk_buff *skb, unsigned int dataoff) {enum sctp_conntrack new_state; -sctp_sctphdr_t _sctph, *sh; -sctp_chunkhdr_t _sch, *sch; +const struct sctphdr *sh; +struct sctphdr _sctph; +const struct sctp_chunkhdr *sch; +struct sctp_chunkhdr _sch;u_int32_t offset, count;unsigned long map[256 /sizeof (unsigned long )] = {0 };
Signature · 1 line
1.5.4.4
PATCH 17/24 : Use bool in nf_conntrack_tuple.h
In reply to Jan Engelhardt--- include/net/netfilter/nf_conntrack.h | 11 +++--- include/net/netfilter/nf_conntrack_core.h | 4 +- include/net/netfilter/nf_conntrack_tuple.h | 39 +++++++++++--------- net/netfilter/nf_conntrack_core.c | 22 +++++------ 4 files changed, 38 insertions(+), 38 deletions(-)
include/net/netfilter/nf_conntrack.h +5 -6
@@ -189,12 +189,11 @@ extern void nf_conntrack_hash_insert(struct nf_conn *ct);extern void nf_conntrack_flush (void ); -extern int nf_ct_get_tuplepr (const struct sk_buff *skb, -unsigned int nhoff, -u_int16_t l3num, -struct nf_conntrack_tuple *tuple); -extern int nf_ct_invert_tuplepr (struct nf_conntrack_tuple *inverse, -const struct nf_conntrack_tuple *orig); +extern bool nf_ct_get_tuplepr (const struct sk_buff *skb, +unsigned int nhoff,u_int16_t l3num, +struct nf_conntrack_tuple *tuple); +extern bool nf_ct_invert_tuplepr (struct nf_conntrack_tuple *inverse, +const struct nf_conntrack_tuple *orig); extern void __nf_ct_refresh_acct(struct nf_conn *ct, enum ip_conntrack_info ctinfo,
include/net/netfilter/nf_conntrack_core.h +2 -2
@@ -30,7 +30,7 @@ extern void nf_conntrack_cleanup(void);extern int nf_conntrack_proto_init (void );extern void nf_conntrack_proto_fini (void ); -extern int +extern bool nf_ct_get_tuple(const struct sk_buff *skb, unsigned int nhoff, unsigned int dataoff,
@@ -40,7 +40,7 @@ nf_ct_get_tuple(const struct sk_buff *skb,const struct nf_conntrack_l3proto *l3proto, const struct nf_conntrack_l4proto *l4proto); -extern int +extern bool nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse, const struct nf_conntrack_tuple *orig, const struct nf_conntrack_l3proto *l3proto,
include/net/netfilter/nf_conntrack_tuple.h +21 -18
@@ -160,61 +160,64 @@ struct nf_conntrack_tuple_hash#endif /* __KERNEL__ */ -static inline int __nf_ct_tuple_src_equal (const struct nf_conntrack_tuple *t1, -const struct nf_conntrack_tuple *t2) +static inline bool __nf_ct_tuple_src_equal (const struct nf_conntrack_tuple *t1, +const struct nf_conntrack_tuple *t2) {return (nf_inet_addr_cmp (&t1->src.u3, &t2->src.u3) && t1->src.u.all == t2->src.u.all && t1->src.l3num == t2->src.l3num); } -static inline int __nf_ct_tuple_dst_equal (const struct nf_conntrack_tuple *t1, -const struct nf_conntrack_tuple *t2) +static inline bool __nf_ct_tuple_dst_equal (const struct nf_conntrack_tuple *t1, +const struct nf_conntrack_tuple *t2) {return (nf_inet_addr_cmp (&t1->dst.u3, &t2->dst.u3) && t1->dst.u.all == t2->dst.u.all && t1->dst.protonum == t2->dst.protonum); } -static inline int nf_ct_tuple_equal (const struct nf_conntrack_tuple *t1, -const struct nf_conntrack_tuple *t2) +static inline bool nf_ct_tuple_equal (const struct nf_conntrack_tuple *t1, +const struct nf_conntrack_tuple *t2) {return __nf_ct_tuple_src_equal (t1, t2) &&__nf_ct_tuple_dst_equal (t1, t2); } -static inline int nf_ct_tuple_mask_equal (const struct nf_conntrack_tuple_mask *m1, -const struct nf_conntrack_tuple_mask *m2) +static inline bool +nf_ct_tuple_mask_equal (const struct nf_conntrack_tuple_mask *m1, +const struct nf_conntrack_tuple_mask *m2) {return (nf_inet_addr_cmp (&m1->src.u3, &m2->src.u3) && m1->src.u.all == m2->src.u.all); } -static inline int nf_ct_tuple_src_mask_cmp (const struct nf_conntrack_tuple *t1, -const struct nf_conntrack_tuple *t2, -const struct nf_conntrack_tuple_mask *mask) +static inline bool +nf_ct_tuple_src_mask_cmp (const struct nf_conntrack_tuple *t1, +const struct nf_conntrack_tuple *t2, +const struct nf_conntrack_tuple_mask *mask) {int count;for (count =0 ; count <NF_CT_TUPLE_L3SIZE ; count++) {if ((t1->src.u3.all[count] ^ t2->src.u3.all[count]) & mask->src.u3.all[count]) -return 0 ; +return false; }if ((t1->src.u.all ^ t2->src.u.all) & mask->src.u.all) -return 0 ; +return false;if (t1->src.l3num != t2->src.l3num || t1->dst.protonum != t2->dst.protonum) -return 0 ; +return false; -return 1 ; +return true; } -static inline int nf_ct_tuple_mask_cmp (const struct nf_conntrack_tuple *t, -const struct nf_conntrack_tuple *tuple, -const struct nf_conntrack_tuple_mask *mask) +static inline bool +nf_ct_tuple_mask_cmp (const struct nf_conntrack_tuple *t, +const struct nf_conntrack_tuple *tuple, +const struct nf_conntrack_tuple_mask *mask) {return nf_ct_tuple_src_mask_cmp (t, tuple, mask) &&__nf_ct_tuple_dst_equal (t, tuple);
net/netfilter/nf_conntrack_core.c +10 -12
@@ -94,7 +94,7 @@ static inline u_int32_t hash_conntrack(const struct nf_conntrack_tuple *tuple) nf_conntrack_hash_rnd); } -int +bool nf_ct_get_tuple(const struct sk_buff *skb, unsigned int nhoff, unsigned int dataoff,
@@ -108,7 +108,7 @@ nf_ct_get_tuple(const struct sk_buff *skb, tuple->src.l3num = l3num;if (l3proto->pkt_to_tuple (skb, nhoff, tuple) ==0 ) -return 0 ; +return false; tuple->dst.protonum = protonum; tuple->dst.dir =IP_CT_DIR_ORIGINAL ;
@@ -117,10 +117,8 @@ nf_ct_get_tuple(const struct sk_buff *skb, }EXPORT_SYMBOL_GPL (nf_ct_get_tuple); -int nf_ct_get_tuplepr (const struct sk_buff *skb, -unsigned int nhoff, -u_int16_t l3num, -struct nf_conntrack_tuple *tuple) +bool nf_ct_get_tuplepr (const struct sk_buff *skb,unsigned int nhoff, +u_int16_t l3num,struct nf_conntrack_tuple *tuple) {struct nf_conntrack_l3proto *l3proto;struct nf_conntrack_l4proto *l4proto;
@@ -134,7 +132,7 @@ int nf_ct_get_tuplepr(const struct sk_buff *skb, ret = l3proto->get_l4proto (skb, nhoff, &protoff, &protonum);if (ret !=NF_ACCEPT ) {rcu_read_unlock (); -return 0 ; +return false; } l4proto =__nf_ct_l4proto_find (l3num, protonum);
@@ -147,7 +145,7 @@ int nf_ct_get_tuplepr(const struct sk_buff *skb, }EXPORT_SYMBOL_GPL (nf_ct_get_tuplepr); -int +bool nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse, const struct nf_conntrack_tuple *orig, const struct nf_conntrack_l3proto *l3proto,
@@ -157,7 +155,7 @@ nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse, inverse->src.l3num = orig->src.l3num;if (l3proto->invert_tuple (inverse, orig) ==0 ) -return 0 ; +return false; inverse->dst.dir = !orig->dst.dir;
@@ -739,10 +737,10 @@ nf_conntrack_in(unsigned int pf, unsigned int hooknum, struct sk_buff *skb) }EXPORT_SYMBOL_GPL (nf_conntrack_in); -int nf_ct_invert_tuplepr (struct nf_conntrack_tuple *inverse, -const struct nf_conntrack_tuple *orig) +bool nf_ct_invert_tuplepr (struct nf_conntrack_tuple *inverse, +const struct nf_conntrack_tuple *orig) { -int ret; +bool ret;rcu_read_lock (); ret = nf_ct_invert_tuple(inverse, orig,
Signature · 1 line
1.5.4.4
PATCH 18/24 : Replace anon union by nf_conntrack_man_proto
In reply to Jan Engelhardt--- include/net/netfilter/nf_conntrack_tuple.h | 28 +++++--------------- 1 files changed, 7 insertions(+), 21 deletions(-)
include/net/netfilter/nf_conntrack_tuple.h +7 -21
@@ -37,7 +37,12 @@ union nf_conntrack_man_proto__be16 port; } udp;struct { -__be16 id; +union { +__be16 id; +struct { +__u8 type, code; + }; + }; } icmp;struct {__be16 port;
@@ -64,26 +69,7 @@ struct nf_conntrack_tuple/* These are the parts of the tuple which are fixed. */ struct {union nf_inet_addr u3; -union { -/* Add other protocols here. */ -__be16 all; - -struct { -__be16 port; - } tcp; -struct { -__be16 port; - } udp; -struct { -u_int8_t type, code; - } icmp; -struct { -__be16 port; - } sctp; -struct { -__be16 key; - } gre; - } u; +union nf_conntrack_man_proto u;/* The protocol. */ u_int8_t protonum;
Signature · 1 line
1.5.4.4
PATCH 19/24 : Give AF-independent extensions an arpt_ alias
In reply to Jan Engelhardt--- net/netfilter/xt_CLASSIFY.c | 1 + net/netfilter/xt_MARK.c | 1 + net/netfilter/xt_RATEEST.c | 1 + net/netfilter/xt_limit.c | 1 + net/netfilter/xt_mark.c | 1 + net/netfilter/xt_quota.c | 1 + net/netfilter/xt_rateest.c | 1 + net/netfilter/xt_statistic.c | 1 + net/netfilter/xt_time.c | 1 + net/netfilter/xt_u32.c | 1 + 10 files changed, 10 insertions(+), 0 deletions(-)
net/netfilter/xt_CLASSIFY.c +1 -0
@@ -25,6 +25,7 @@ MODULE_LICENSE("GPL");MODULE_DESCRIPTION ("Xtables: Qdisc classification" );MODULE_ALIAS ("ipt_CLASSIFY" );MODULE_ALIAS ("ip6t_CLASSIFY" ); +MODULE_ALIAS ("arpt_CLASSIFY" ); static unsigned int classify_tg(struct sk_buff *skb, const struct net_device *in,
net/netfilter/xt_MARK.c +1 -0
@@ -23,6 +23,7 @@ MODULE_AUTHOR("Marc Boucher <[email protected]>");MODULE_DESCRIPTION ("Xtables: packet mark modification" );MODULE_ALIAS ("ipt_MARK" );MODULE_ALIAS ("ip6t_MARK" ); +MODULE_ALIAS ("arpt_MARK" ); static unsigned int mark_tg_v0(struct sk_buff *skb, const struct net_device *in,
net/netfilter/xt_RATEEST.c +1 -0
@@ -190,5 +190,6 @@ MODULE_LICENSE("GPL");MODULE_DESCRIPTION ("Xtables: packet rate estimator" );MODULE_ALIAS ("ipt_RATEEST" );MODULE_ALIAS ("ip6t_RATEEST" ); +MODULE_ALIAS ("arpt_RATEEST" );module_init (xt_rateest_tg_init);module_exit (xt_rateest_tg_fini);
net/netfilter/xt_limit.c +1 -0
@@ -19,6 +19,7 @@ MODULE_AUTHOR("Herve Eychenne <[email protected]>");MODULE_DESCRIPTION ("Xtables: rate-limit match" );MODULE_ALIAS ("ipt_limit" );MODULE_ALIAS ("ip6t_limit" ); +MODULE_ALIAS ("arpt_limit" );/* The algorithm used is the Simple Token Bucket Filter (TBF) * see net/sched/sch_tbf.c in the linux source tree
net/netfilter/xt_mark.c +1 -0
@@ -21,6 +21,7 @@ MODULE_AUTHOR("Marc Boucher <[email protected]>");MODULE_DESCRIPTION ("Xtables: packet mark match" );MODULE_ALIAS ("ipt_mark" );MODULE_ALIAS ("ip6t_mark" ); +MODULE_ALIAS ("arpt_mark" ); static bool mark_mt_v0(const struct sk_buff *skb, const struct net_device *in,
net/netfilter/xt_quota.c +1 -0
@@ -14,6 +14,7 @@ MODULE_AUTHOR("Sam Johnston <[email protected]>");MODULE_DESCRIPTION ("Xtables: countdown quota match" );MODULE_ALIAS ("ipt_quota" );MODULE_ALIAS ("ip6t_quota" ); +MODULE_ALIAS ("arpt_quota" );static DEFINE_SPINLOCK (quota_lock);
net/netfilter/xt_rateest.c +1 -0
@@ -163,5 +163,6 @@ MODULE_LICENSE("GPL");MODULE_DESCRIPTION ("xtables rate estimator match" );MODULE_ALIAS ("ipt_rateest" );MODULE_ALIAS ("ip6t_rateest" ); +MODULE_ALIAS ("arpt_rateest" );module_init (xt_rateest_mt_init);module_exit (xt_rateest_mt_fini);
net/netfilter/xt_statistic.c +1 -0
@@ -21,6 +21,7 @@ MODULE_AUTHOR("Patrick McHardy <[email protected]>");MODULE_DESCRIPTION ("Xtables: statistics-based matching (\"Nth\", random)" );MODULE_ALIAS ("ipt_statistic" );MODULE_ALIAS ("ip6t_statistic" ); +MODULE_ALIAS ("arpt_statistic" );static DEFINE_SPINLOCK (nth_lock);
net/netfilter/xt_time.c +1 -0
@@ -261,3 +261,4 @@ MODULE_DESCRIPTION("Xtables: time-based matching");MODULE_LICENSE ("GPL" );MODULE_ALIAS ("ipt_time" );MODULE_ALIAS ("ip6t_time" ); +MODULE_ALIAS ("arpt_time" );
net/netfilter/xt_u32.c +1 -0
@@ -125,3 +125,4 @@ MODULE_DESCRIPTION("Xtables: arbitrary byte matching");MODULE_LICENSE ("GPL" );MODULE_ALIAS ("ipt_u32" );MODULE_ALIAS ("ip6t_u32" ); +MODULE_ALIAS ("arpt_u32" );
Signature · 1 line
1.5.4.4
PATCH 20/24 : Make Ebtables use Xtables infrastructure
In reply to Jan Engelhardt--- include/linux/netfilter_bridge/ebtables.h | 15 +- net/bridge/netfilter/ebt_802_3.c | 41 ++-- net/bridge/netfilter/ebt_among.c | 45 ++-- net/bridge/netfilter/ebt_arp.c | 45 ++-- net/bridge/netfilter/ebt_arpreply.c | 49 +++-- net/bridge/netfilter/ebt_dnat.c | 47 ++-- net/bridge/netfilter/ebt_ip.c | 56 +++-- net/bridge/netfilter/ebt_limit.c | 44 ++-- net/bridge/netfilter/ebt_log.c | 52 +++-- net/bridge/netfilter/ebt_mark.c | 46 ++-- net/bridge/netfilter/ebt_mark_m.c | 45 ++-- net/bridge/netfilter/ebt_pkttype.c | 44 ++-- net/bridge/netfilter/ebt_redirect.c | 47 ++-- net/bridge/netfilter/ebt_snat.c | 55 +++-- net/bridge/netfilter/ebt_stp.c | 46 ++-- net/bridge/netfilter/ebt_ulog.c | 51 +++-- net/bridge/netfilter/ebt_vlan.c | 59 +++--- net/bridge/netfilter/ebtables.c | 266 ++++++++------------- net/netfilter/x_tables.c | 6 +- 19 files changed, 539 insertions(+), 520 deletions(-)
include/linux/netfilter_bridge/ebtables.h +6 -9
@@ -117,11 +117,14 @@ struct ebt_entries {#define EBT_INV_MASK (EBT_IPROTO | EBT_IIN | EBT_IOUT | EBT_ILOGICALIN \ | EBT_ILOGICALOUT | EBT_ISOURCE | EBT_IDEST) +struct xt_match ; +struct xt_target ; +struct ebt_entry_match {union {char name[EBT_FUNCTION_MAXNAMELEN ]; -struct ebt_match *match; +struct xt_match *match; } u;/* size of data */ unsigned int match_size;
@@ -132,7 +135,7 @@ struct ebt_entry_watcher {union {char name[EBT_FUNCTION_MAXNAMELEN ]; -struct ebt_watcher *watcher; +struct xt_target *watcher; } u;/* size of data */ unsigned int watcher_size;
@@ -143,7 +146,7 @@ struct ebt_entry_target {union {char name[EBT_FUNCTION_MAXNAMELEN ]; -struct ebt_target *target; +struct xt_target *target; } u;/* size of data */ unsigned int target_size;
@@ -288,12 +291,6 @@ struct ebt_table ~(__alignof__(struct ebt_replace)-1))extern int ebt_register_table (struct ebt_table *table);extern void ebt_unregister_table (struct ebt_table *table); -extern int ebt_register_match (struct ebt_match *match); -extern void ebt_unregister_match (struct ebt_match *match); -extern int ebt_register_watcher (struct ebt_watcher *watcher); -extern void ebt_unregister_watcher (struct ebt_watcher *watcher); -extern int ebt_register_target (struct ebt_target *target); -extern void ebt_unregister_target (struct ebt_target *target);extern unsigned int ebt_do_table (unsigned int hook,struct sk_buff *skb,const struct net_device *in,const struct net_device *out,struct ebt_table *table);
net/bridge/netfilter/ebt_802_3.c +23 -18
71 lines not on this page · raw message
net/bridge/netfilter/ebt_among.c +25 -20
88 lines not on this page · raw message
net/bridge/netfilter/ebt_arp.c +26 -19
78 lines not on this page · raw message
net/bridge/netfilter/ebt_arpreply.c +28 -21
86 lines not on this page · raw message
net/bridge/netfilter/ebt_dnat.c +26 -21
85 lines not on this page · raw message
net/bridge/netfilter/ebt_ip.c +31 -25
103 lines not on this page · raw message
net/bridge/netfilter/ebt_limit.c +23 -21
89 lines not on this page · raw message
net/bridge/netfilter/ebt_log.c +29 -23
101 lines not on this page · raw message
net/bridge/netfilter/ebt_mark.c +26 -20
85 lines not on this page · raw message
net/bridge/netfilter/ebt_mark_m.c +25 -20
76 lines not on this page · raw message
net/bridge/netfilter/ebt_pkttype.c +24 -20
74 lines not on this page · raw message
net/bridge/netfilter/ebt_redirect.c +26 -21
85 lines not on this page · raw message
net/bridge/netfilter/ebt_snat.c +30 -25
97 lines not on this page · raw message
net/bridge/netfilter/ebt_stp.c +26 -20
87 lines not on this page · raw message
net/bridge/netfilter/ebt_ulog.c +29 -22
98 lines not on this page · raw message
net/bridge/netfilter/ebt_vlan.c +28 -31
130 lines not on this page · raw message
net/bridge/netfilter/ebtables.c +104 -162
429 lines not on this page · raw message
net/netfilter/x_tables.c +4 -2
@@ -30,7 +30,7 @@MODULE_LICENSE ("GPL" );MODULE_AUTHOR ("Harald Welte <[email protected]>" ); -MODULE_DESCRIPTION ("[ip,ip6,arp]_tables backend module" ); +MODULE_DESCRIPTION ("{ip,eb,ip6,arp}_tables backend module" );#define SMP_ALIGN (x) (((x) + SMP_CACHE_BYTES-1) & ~(SMP_CACHE_BYTES-1))
@@ -61,6 +61,7 @@ static struct xt_af *xt;static const char *const xt_prefix[NPROTO ] = { [AF_UNSPEC ] ="x" , [AF_INET ] ="ip" , + [AF_BRIDGE ] ="eb" , [AF_INET6 ] ="ip6" , [AF_ARP ] ="arp" , };
@@ -327,7 +328,8 @@ int xt_check_match(const struct xt_match *match, unsigned short family, unsigned int size, const char *table, unsigned int hook_mask, unsigned short proto, int inv_proto) { - if (XT_ALIGN(match->matchsize) != size) { + /* testing for -1 is temporary until ebtables is fixed up */ + if (match->matchsize != -1 && XT_ALIGN(match->matchsize) != size) { printk("%s_tables: %s match: invalid size %Zu != %u\n", xt_prefix[family], match->name, XT_ALIGN(match->matchsize), size);
Signature · 1 line
1.5.4.4
PATCH 21/24 : xt_length match, revision 1
In reply to Jan EngelhardtIntroduce xt_length match revision 1. It adds support for layer-4, layer-5 and layer-7 length matching. It is much easier than writing up the according xt_u32 magic.
This can be used for packet scheduling; specific example are online games where all data is transferred over the same port, but the regular gameplay has a characteristically lower packet size than bulk downloads of game maps.
--- include/linux/netfilter/xt_length.h | 21 +++ net/netfilter/xt_length.c | 260 +++++++++++++++++++++++++-- 2 files changed, 264 insertions(+), 17 deletions(-)
include/linux/netfilter/xt_length.h +21 -0
@@ -6,4 +6,25 @@ struct xt_length_info { u_int8_t invert; }; +enum { +XT_LENGTH_INVERT =1 <<0 , + +/* IP header plus payload */ +XT_LENGTH_LAYER3 =1 <<1 , + +/* TCP/UDP/etc. header plus payload */ +XT_LENGTH_LAYER4 =1 <<2 , + +/* TCP/UDP/etc. payload */ +XT_LENGTH_LAYER5 =1 <<3 , + +/* SCTP payload */ +XT_LENGTH_LAYER7 =1 <<4 , +}; + +struct xt_length_mtinfo1 { +__u32 min, max; +__u16 flags; +}; +#endif /*_XT_LENGTH_H*/
net/netfilter/xt_length.c +243 -17
308 lines not on this page · raw message
Signature · 6 lines
1.5.4.4 -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 22/24 : Replace NF_CT_DUMP_TUPLE macro indrection by function call
In reply to Jan EngelhardtDirectly call IPv4 and IPv6 variants where the address family is easily known.
--- include/net/netfilter/nf_conntrack_tuple.h | 2 - net/ipv4/netfilter/ipt_CLUSTERIP.c | 2 +- net/ipv4/netfilter/nf_conntrack_proto_icmp.c | 2 +- net/ipv4/netfilter/nf_nat_pptp.c | 2 +- net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c | 2 +- net/netfilter/nf_conntrack_core.c | 2 +- net/netfilter/nf_conntrack_h323_main.c | 26 ++++++++-------- net/netfilter/nf_conntrack_pptp.c | 4 +- net/netfilter/nf_conntrack_proto_gre.c | 6 ++-- net/netfilter/nf_conntrack_proto_tcp.c | 6 ++-- net/netfilter/nf_conntrack_sane.c | 2 +- net/netfilter/nf_conntrack_tftp.c | 6 ++-- 12 files changed, 30 insertions(+), 32 deletions(-)
include/net/netfilter/nf_conntrack_tuple.h +0 -2
@@ -131,8 +131,6 @@ static inline void nf_ct_dump_tuple(const struct nf_conntrack_tuple *t) } } -#define NF_CT_DUMP_TUPLE (tp) nf_ct_dump_tuple(tp) -/* If we're the first tuple, it's the original dir. */ #define NF_CT_DIRECTION (h) \ ((enum ip_conntrack_dir)(h)->tuple.dst.dir)
net/ipv4/netfilter/ipt_CLUSTERIP.c +1 -1
@@ -331,7 +331,7 @@ clusterip_tg(struct sk_buff *skb, const struct net_device *in, }#ifdef DEBUG -NF_CT_DUMP_TUPLE (&ct->tuplehash[IP_CT_DIR_ORIGINAL ].tuple); +nf_ct_dump_tuple_ip (&ct->tuplehash[IP_CT_DIR_ORIGINAL ].tuple);#endif pr_debug ("hash=%u ct_hash=%u " , hash, ct->mark);if (!clusterip_responsible (cipinfo->config, hash)) {
net/ipv4/netfilter/nf_conntrack_proto_icmp.c +1 -1
@@ -115,7 +115,7 @@ static bool icmp_new(struct nf_conn *ct, const struct sk_buff *skb,/* Can't create a new ICMP `conn' with this. */ pr_debug ("icmp: can't create new conn with type %u\n" , ct->tuplehash[0 ].tuple.dst.u.icmp.type); -NF_CT_DUMP_TUPLE (&ct->tuplehash[0 ].tuple); +nf_ct_dump_tuple_ip (&ct->tuplehash[0 ].tuple);return false; }atomic_set (&ct->proto.icmp.count,0 );
net/ipv4/netfilter/nf_nat_pptp.c +1 -1
@@ -72,7 +72,7 @@ static void pptp_nat_expected(struct nf_conn *ct, }pr_debug ("trying to unexpect other dir: " ); -NF_CT_DUMP_TUPLE (&t); +nf_ct_dump_tuple_ip (&t); other_exp =nf_ct_expect_find_get (&t);if (other_exp) {nf_ct_unexpect_related (other_exp);
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +1 -1
@@ -115,7 +115,7 @@ static bool icmpv6_new(struct nf_conn *ct, const struct sk_buff *skb,/* Can't create a new ICMPv6 `conn' with this. */ pr_debug ("icmpv6: can't create new conn with type %u\n" , type +128 ); -NF_CT_DUMP_TUPLE (&ct->tuplehash[0 ].tuple); +nf_ct_dump_tuple_ipv6 (&ct->tuplehash[0 ].tuple);return false; }atomic_set (&ct->proto.icmp.count,0 );
net/netfilter/nf_conntrack_core.c +1 -1
@@ -764,7 +764,7 @@ void nf_conntrack_alter_reply(struct nf_conn *ct,NF_CT_ASSERT (!nf_ct_is_confirmed (ct));pr_debug ("Altering reply tuple of %p to " , ct); -NF_CT_DUMP_TUPLE (newreply); +nf_ct_dump_tuple (newreply); ct->tuplehash[IP_CT_DIR_REPLY ].tuple = *newreply;if (ct->master || (help && help->expecting !=0 ))
net/netfilter/nf_conntrack_h323_main.c +13 -13
@@ -306,9 +306,9 @@ static int expect_rtp_rtcp(struct sk_buff *skb, struct nf_conn *ct,if (nf_ct_expect_related (rtp_exp) ==0 ) {if (nf_ct_expect_related (rtcp_exp) ==0 ) {pr_debug ("nf_ct_h323: expect RTP " ); -NF_CT_DUMP_TUPLE (&rtp_exp->tuple); +nf_ct_dump_tuple (&rtp_exp->tuple);pr_debug ("nf_ct_h323: expect RTCP " ); -NF_CT_DUMP_TUPLE (&rtcp_exp->tuple); +nf_ct_dump_tuple (&rtcp_exp->tuple); }else {nf_ct_unexpect_related (rtp_exp); ret =-1 ;
@@ -364,7 +364,7 @@ static int expect_t120(struct sk_buff *skb, }else {/* Conntrack only */ if (nf_ct_expect_related (exp) ==0 ) {pr_debug ("nf_ct_h323: expect T.120 " ); -NF_CT_DUMP_TUPLE (&exp->tuple); +nf_ct_dump_tuple (&exp->tuple); }else ret =-1 ; }
@@ -586,7 +586,7 @@ static int h245_help(struct sk_buff *skb, unsigned int protoff,while (get_tpkt_data (skb, protoff, ct, ctinfo, &data, &datalen, &dataoff)) {pr_debug ("nf_ct_h245: TPKT len=%d " , datalen); -NF_CT_DUMP_TUPLE (&ct->tuplehash[CTINFO2DIR (ctinfo)].tuple); +nf_ct_dump_tuple (&ct->tuplehash[CTINFO2DIR (ctinfo)].tuple);/* Decode H.245 signal */ ret = DecodeMultimediaSystemControlMessage(data, datalen,
@@ -701,7 +701,7 @@ static int expect_h245(struct sk_buff *skb, struct nf_conn *ct, }else {/* Conntrack only */ if (nf_ct_expect_related (exp) ==0 ) {pr_debug ("nf_ct_q931: expect H.245 " ); -NF_CT_DUMP_TUPLE (&exp->tuple); +nf_ct_dump_tuple (&exp->tuple); }else ret =-1 ; }
@@ -818,7 +818,7 @@ static int expect_callforwarding(struct sk_buff *skb, }else {/* Conntrack only */ if (nf_ct_expect_related (exp) ==0 ) {pr_debug ("nf_ct_q931: expect Call Forwarding " ); -NF_CT_DUMP_TUPLE (&exp->tuple); +nf_ct_dump_tuple (&exp->tuple); }else ret =-1 ; }
@@ -1138,7 +1138,7 @@ static int q931_help(struct sk_buff *skb, unsigned int protoff,while (get_tpkt_data (skb, protoff, ct, ctinfo, &data, &datalen, &dataoff)) {pr_debug ("nf_ct_q931: TPKT len=%d " , datalen); -NF_CT_DUMP_TUPLE (&ct->tuplehash[CTINFO2DIR (ctinfo)].tuple); +nf_ct_dump_tuple (&ct->tuplehash[CTINFO2DIR (ctinfo)].tuple);/* Decode Q.931 signal */ ret =DecodeQ931 (data, datalen, &q931);
@@ -1288,7 +1288,7 @@ static int expect_q931(struct sk_buff *skb, struct nf_conn *ct, }else {/* Conntrack only */ if (nf_ct_expect_related (exp) ==0 ) {pr_debug ("nf_ct_ras: expect Q.931 " ); -NF_CT_DUMP_TUPLE (&exp->tuple); +nf_ct_dump_tuple (&exp->tuple);/* Save port for looking up expect in processing RCF */ info->sig_port[dir] = port;
@@ -1353,7 +1353,7 @@ static int process_gcf(struct sk_buff *skb, struct nf_conn *ct,if (nf_ct_expect_related (exp) ==0 ) {pr_debug ("nf_ct_ras: expect RAS " ); -NF_CT_DUMP_TUPLE (&exp->tuple); +nf_ct_dump_tuple (&exp->tuple); }else ret =-1 ;
@@ -1437,7 +1437,7 @@ static int process_rcf(struct sk_buff *skb, struct nf_conn *ct,pr_debug ("nf_ct_ras: set Q.931 expect " "timeout to %u seconds for" , info->timeout); -NF_CT_DUMP_TUPLE (&exp->tuple); +nf_ct_dump_tuple (&exp->tuple);set_expect_timeout (exp, info->timeout); }spin_unlock_bh (&nf_conntrack_lock);
@@ -1559,7 +1559,7 @@ static int process_acf(struct sk_buff *skb, struct nf_conn *ct,if (nf_ct_expect_related (exp) ==0 ) {pr_debug ("nf_ct_ras: expect Q.931 " ); -NF_CT_DUMP_TUPLE (&exp->tuple); +nf_ct_dump_tuple (&exp->tuple); }else ret =-1 ;
@@ -1613,7 +1613,7 @@ static int process_lcf(struct sk_buff *skb, struct nf_conn *ct,if (nf_ct_expect_related (exp) ==0 ) {pr_debug ("nf_ct_ras: expect Q.931 " ); -NF_CT_DUMP_TUPLE (&exp->tuple); +nf_ct_dump_tuple (&exp->tuple); }else ret =-1 ;
@@ -1717,7 +1717,7 @@ static int ras_help(struct sk_buff *skb, unsigned int protoff,if (data ==NULL ) goto accept;pr_debug ("nf_ct_ras: RAS message len=%d " , datalen); -NF_CT_DUMP_TUPLE (&ct->tuplehash[CTINFO2DIR (ctinfo)].tuple); +nf_ct_dump_tuple (&ct->tuplehash[CTINFO2DIR (ctinfo)].tuple);/* Decode RAS message */ ret =DecodeRasMessage (data, datalen, &ras);
net/netfilter/nf_conntrack_pptp.c +2 -2
@@ -119,7 +119,7 @@ static void pptp_expectfn(struct nf_conn *ct,/* obviously this tuple inversion only works until you do NAT */ nf_ct_invert_tuplepr (&inv_t, &exp->tuple);pr_debug ("trying to unexpect other dir: " ); -NF_CT_DUMP_TUPLE (&inv_t); +nf_ct_dump_tuple (&inv_t); exp_other =nf_ct_expect_find_get (&inv_t);if (exp_other) {
@@ -141,7 +141,7 @@ static int destroy_sibling_or_exp(const struct nf_conntrack_tuple *t)struct nf_conn *sibling;pr_debug ("trying to timeout ct or exp for tuple " ); -NF_CT_DUMP_TUPLE (t); +nf_ct_dump_tuple (t); h =nf_conntrack_find_get (t);if (h) {
net/netfilter/nf_conntrack_proto_gre.c +3 -3
@@ -82,7 +82,7 @@ static __be16 gre_keymap_lookup(struct nf_conntrack_tuple *t)read_unlock_bh (&nf_ct_gre_lock);pr_debug ("lookup src key 0x%x for " , key); -NF_CT_DUMP_TUPLE (t); +nf_ct_dump_tuple (t);return key; }
@@ -113,7 +113,7 @@ int nf_ct_gre_keymap_add(struct nf_conn *ct, enum ip_conntrack_dir dir, *kmp = km;pr_debug ("adding new entry %p: " , km); -NF_CT_DUMP_TUPLE (&km->tuple); +nf_ct_dump_tuple (&km->tuple);write_lock_bh (&nf_ct_gre_lock);list_add_tail (&km->list, &gre_keymap_list);
@@ -238,7 +238,7 @@ static bool gre_new(struct nf_conn *ct, const struct sk_buff *skb, unsigned int dataoff) {pr_debug (": " ); -NF_CT_DUMP_TUPLE (&ct->tuplehash[IP_CT_DIR_ORIGINAL ].tuple); +nf_ct_dump_tuple (&ct->tuplehash[IP_CT_DIR_ORIGINAL ].tuple);/* initialize to sane value. Ideally a conntrack helper * (e.g. in case of pptp) is increasing them */
net/netfilter/nf_conntrack_proto_tcp.c +3 -3
@@ -501,7 +501,7 @@ static bool tcp_in_window(const struct nf_conn *ct, struct ip_ct_tcp *state,pr_debug ("tcp_in_window: START\n" );pr_debug ("tcp_in_window: " ); -NF_CT_DUMP_TUPLE (tuple); +nf_ct_dump_tuple (tuple);pr_debug ("seq=%u ack=%u sack=%u win=%u end=%u\n" , seq, ack, sack, win, end); pr_debug("tcp_in_window: sender end=%u maxend=%u maxwin=%u scale=%i "
@@ -588,7 +588,7 @@ static bool tcp_in_window(const struct nf_conn *ct, struct ip_ct_tcp *state, seq = end = sender->td_end;pr_debug ("tcp_in_window: " ); -NF_CT_DUMP_TUPLE (tuple); +nf_ct_dump_tuple (tuple);pr_debug ("seq=%u ack=%u sack =%u win=%u end=%u\n" , seq, ack, sack, win, end); pr_debug("tcp_in_window: sender end=%u maxend=%u maxwin=%u scale=%i "
@@ -932,7 +932,7 @@ static int tcp_packet(struct nf_conn *ct, ct->proto.tcp.last_dir = dir;pr_debug ("tcp_conntracks: " ); -NF_CT_DUMP_TUPLE (tuple); +nf_ct_dump_tuple (tuple); pr_debug("syn=%i ack=%i fin=%i rst=%i old=%i new=%i\n", (th->syn ? 1 : 0), (th->ack ? 1 : 0), (th->fin ? 1 : 0), (th->rst ? 1 : 0),
net/netfilter/nf_conntrack_sane.c +1 -1
@@ -148,7 +148,7 @@ static int help(struct sk_buff *skb, IPPROTO_TCP, NULL, &reply->port);pr_debug ("nf_ct_sane: expect: " ); -NF_CT_DUMP_TUPLE (&exp->tuple); +nf_ct_dump_tuple (&exp->tuple);/* Can't expect this? Best to drop packet now. */ if (nf_ct_expect_related (exp) !=0 )
net/netfilter/nf_conntrack_tftp.c +3 -3
@@ -56,8 +56,8 @@ static int tftp_help(struct sk_buff *skb,case TFTP_OPCODE_READ :case TFTP_OPCODE_WRITE :/* RRQ and WRQ works the same way */ -NF_CT_DUMP_TUPLE (&ct->tuplehash[IP_CT_DIR_ORIGINAL ].tuple); -NF_CT_DUMP_TUPLE (&ct->tuplehash[IP_CT_DIR_REPLY ].tuple); +nf_ct_dump_tuple (&ct->tuplehash[IP_CT_DIR_ORIGINAL ].tuple); +nf_ct_dump_tuple (&ct->tuplehash[IP_CT_DIR_REPLY ].tuple); exp =nf_ct_expect_alloc (ct);if (exp ==NULL )
@@ -68,7 +68,7 @@ static int tftp_help(struct sk_buff *skb, IPPROTO_UDP, NULL, &tuple->dst.u.udp.port);pr_debug ("expect: " ); -NF_CT_DUMP_TUPLE (&exp->tuple); +nf_ct_dump_tuple (&exp->tuple); nf_nat_tftp =rcu_dereference (nf_nat_tftp_hook);if (nf_nat_tftp && ct->status &IPS_NAT_MASK )
Signature · 1 line
1.5.4.4
PATCH 23/24 : Collapse tcpmss_reverse_mtu{4,6} into one function
In reply to Jan Engelhardt--- net/netfilter/xt_TCPMSS.c | 46 ++++++++++++------------------------- 1 files changed, 15 insertions(+), 31 deletions(-)
net/netfilter/xt_TCPMSS.c +15 -31
@@ -147,17 +147,21 @@ tcpmss_mangle_packet(struct sk_buff *skb,return TCPOLEN_MSS ; } -static u_int32_t tcpmss_reverse_mtu4 (const struct iphdr *iph) +static u_int32_t tcpmss_reverse_mtu (const struct sk_buff *skb, +unsigned int family) { -struct flowi fl = { - .fl4_dst = iph->saddr, - }; +struct flowi fl = {};const struct nf_afinfo *ai;struct rtable *rt =NULL ;u_int32_t mtu = ~0U ; +if (family ==AF_INET ) + fl.fl4_dst =ip_hdr (skb)->saddr; +else + fl.fl6_dst =ipv6_hdr (skb)->saddr; +rcu_read_lock (); - ai =nf_get_afinfo (AF_INET ); + ai =nf_get_afinfo (family);if (ai !=NULL ) ai->route ((struct dst_entry **)&rt, &fl);rcu_read_unlock ();
@@ -178,9 +182,10 @@ tcpmss_tg4(struct sk_buff *skb, const struct net_device *in,__be16 newlen;int ret; - ret =tcpmss_mangle_packet (skb, targinfo,tcpmss_reverse_mtu4 (iph), - iph->ihl *4 , -sizeof (*iph) +sizeof (struct tcphdr )); + ret =tcpmss_mangle_packet (skb, targinfo, +tcpmss_reverse_mtu (skb,AF_INET ), + iph->ihl *4 , +sizeof (*iph) +sizeof (struct tcphdr ));if (ret <0 )return NF_DROP ;if (ret >0 ) {
@@ -193,28 +198,6 @@ tcpmss_tg4(struct sk_buff *skb, const struct net_device *in, }#if defined(CONFIG_IP6_NF_IPTABLES ) || defined(CONFIG_IP6_NF_IPTABLES_MODULE ) -static u_int32_t tcpmss_reverse_mtu6 (const struct ipv6hdr *iph) -{ -struct flowi fl = { - .fl6_dst = iph->saddr, - }; -const struct nf_afinfo *ai; -struct rtable *rt =NULL ; -u_int32_t mtu = ~0U ; - -rcu_read_lock (); - ai =nf_get_afinfo (AF_INET6 ); -if (ai !=NULL ) - ai->route ((struct dst_entry **)&rt, &fl); -rcu_read_unlock (); - -if (rt !=NULL ) { - mtu =dst_mtu (&rt->u.dst); -dst_release (&rt->u.dst); - } -return mtu; -} - static unsigned int tcpmss_tg6(struct sk_buff *skb, const struct net_device *in, const struct net_device *out, unsigned int hooknum,
@@ -229,7 +212,8 @@ tcpmss_tg6(struct sk_buff *skb, const struct net_device *in, tcphoff =ipv6_skip_exthdr (skb,sizeof (*ipv6h), &nexthdr);if (tcphoff <0 )return NF_DROP ; - ret =tcpmss_mangle_packet (skb, targinfo,tcpmss_reverse_mtu6 (ipv6h), + ret =tcpmss_mangle_packet (skb, targinfo, +tcpmss_reverse_mtu (skb,AF_INET6 ), tcphoff,sizeof (*ipv6h) +sizeof (struct tcphdr ));if (ret <0 )
Signature · 1 line
1.5.4.4
PATCH 24/24 : Remove unused callbacks in nf_conntrack_l3proto
In reply to Jan Engelhardt--- include/net/netfilter/nf_conntrack_l3proto.h | 11 ----------- 1 files changed, 0 insertions(+), 11 deletions(-)
include/net/netfilter/nf_conntrack_l3proto.h +0 -11
@@ -42,17 +42,6 @@ struct nf_conntrack_l3protoint (*print_tuple)(struct seq_file *s,const struct nf_conntrack_tuple *); -/* Returns verdict for packet, or -1 for invalid. */ -int (*packet)(struct nf_conn *ct, -const struct sk_buff *skb, -enum ip_conntrack_info ctinfo); - -/* -* Called when a new connection for this protocol found; -* returns TRUE if it's OK. If so, packet() called next. -*/ -bool (*new)(struct nf_conn *ct,const struct sk_buff *skb); -/* * Called before tracking. * *dataoff: offset of protocol header (TCP, UDP,...) in skb
Signature · 1 line
1.5.4.4