netfilter 00/03: netfilter fixes
Subsystems (3)
Hi Dave,
following are some netfilter fixes for 2.6.28, containing:
- restauration of a lost #ifdef to fix user-triggerable WARN_ONs in the NAT code. Also queued for -stable.
- restauration of ebtables dependencies that got lost during a Kconfig restructuring
- a slightly more involved patch from Pablo to remove the bogus NAT module dependencies from ctnetlink. It could be argued whether this qualifies as a real bugfix since its mainly a "it shouldn't be like this" thing and everything works properly, in my opinion it does though because of all the side effects that even just loading the NAT module causes. A somewhat fitting analogy would be an IPv6 module dependency in, lets say, TCP :)
Please apply, thanks.
include/linux/netfilter/nfnetlink.h | 3 + include/net/netfilter/nf_nat_core.h | 8 ++ net/bridge/netfilter/Kconfig | 1 + net/ipv4/netfilter/nf_defrag_ipv4.c | 3 +- net/ipv4/netfilter/nf_nat_core.c | 97 ++++++++++++++++++++++ net/netfilter/nf_conntrack_core.c | 7 ++ net/netfilter/nf_conntrack_netlink.c | 151 ++++++++++++++-------------------- net/netfilter/nfnetlink.c | 12 ++- 8 files changed, 188 insertions(+), 94 deletions(-)
Pablo Neira Ayuso (1):
netfilter: ctnetlink: remove bogus module dependency between ctnetlink and nf_nat
Patrick McHardy (2):
netfilter: restore lost #ifdef guarding defrag exception
netfilter: fix ebtables dependencies
netfilter 01/03: restore lost
commit 88e2364d9db799fec118e5a97f282762cdfb0d1a
Author: Patrick McHardy <[email protected]> Date: Mon Oct 13 15:43:20 2008 +0200
netfilter: restore lost #ifdef guarding defrag exception
Nir Tzachar <[email protected]> reported a warning when sending fragments over loopback with NAT:
[ 6658.338121] WARNING: at net/ipv4/netfilter/nf_nat_standalone.c:89 nf_nat_fn+0x33/0x155()
The reason is that defragmentation is skipped for already tracked connections. This is wrong in combination with NAT and ip_conntrack actually had some ifdefs to avoid this behaviour when NAT is compiled in.
The entire "optimization" may seem a bit silly, for now simply restoring the lost #ifdef is the easiest solution until we can come up with something better.
net/ipv4/netfilter/nf_defrag_ipv4.c +2 -1
@@ -41,12 +41,13 @@ static unsigned int ipv4_conntrack_defrag(unsigned int hooknum, int (*okfn)(struct sk_buff *)) {#if defined(CONFIG_NF_CONNTRACK ) || defined(CONFIG_NF_CONNTRACK_MODULE ) +#if !defined(CONFIG_NF_NAT ) && !defined(CONFIG_NF_NAT_MODULE )/* Previously seen (loopback)? Ignore. Do this before fragment check. */ if (skb->nfct)return NF_ACCEPT ;#endif - +#endif /* Gather fragments. */ if (ip_hdr (skb)->frag_off &htons (IP_MF |IP_OFFSET )) { if (nf_ct_ipv4_gather_frags(skb,
netfilter 02/03: fix ebtables dependencies
In reply to Patrick McHardycommit 0a536ab6cb2021d764921a42ad22a5aadee8fbb8
Author: Patrick McHardy <[email protected]> Date: Tue Oct 14 13:51:08 2008 +0200
netfilter: fix ebtables dependencies
Ingo Molnar reported a build error with ebtables:
ERROR: "ebt_register_table" [net/bridge/netfilter/ebtable_filter.ko] undefined!
ERROR: "ebt_do_table" [net/bridge/netfilter/ebtable_filter.ko] undefined!
ERROR: "ebt_unregister_table" [net/bridge/netfilter/ebtable_filter.ko] undefined!
ERROR: "ebt_register_table" [net/bridge/netfilter/ebtable_broute.ko] undefined!
ERROR: "ebt_do_table" [net/bridge/netfilter/ebtable_broute.ko] undefined!
ERROR: "ebt_unregister_table" [net/bridge/netfilter/ebtable_broute.ko] undefined! make[1]: *** [__modpost] Error 1
make: *** [modules] Error 2
This reason is a missing dependencies that got lost during Kconfig cleanups. Restore it.
net/bridge/netfilter/Kconfig +1 -0
@@ -4,6 +4,7 @@ menuconfig BRIDGE_NF_EBTABLES tristate "Ethernet Bridge tables (ebtables) support" + depends on BRIDGE && BRIDGE_NETFILTER select NETFILTER_XTABLES help ebtables is a general, extensible frame/packet identification
netfilter 03/03: ctnetlink: remove bogus module dependency between ctnetlink and nf_nat
In reply to Patrick McHardycommit 006bd260d57b89db8503d41896094c5d2d996723
Author: Pablo Neira Ayuso <[email protected]> Date: Tue Oct 14 15:50:49 2008 +0200
netfilter: ctnetlink: remove bogus module dependency between ctnetlink and nf_nat
This patch removes the module dependency between ctnetlink and nf_nat by means of an indirect call that is initialized when nf_nat is loaded. Now, nf_conntrack_netlink only requires nf_conntrack and nfnetlink.
This patch puts nfnetlink_parse_nat_setup_hook into the nf_conntrack_core to avoid dependencies between ctnetlink, nf_conntrack_ipv4 and nf_conntrack_ipv6.
This patch also introduces the function ctnetlink_change_nat that is only invoked from the creation path. Actually, the nat handling cannot be invoked from the update path since this is not allowed. By introducing this function, we remove the useless nat handling in the update path and we avoid deadlock-prone code.
This patch also adds the required EAGAIN logic for nfnetlink.
include/linux/netfilter/nfnetlink.h +3 -0
@@ -78,6 +78,9 @@ extern int nfnetlink_send(struct sk_buff *skb, u32 pid, unsigned group, int echo);extern int nfnetlink_unicast (struct sk_buff *skb,u_int32_t pid,int flags); +extern void nfnl_lock (void ); +extern void nfnl_unlock (void ); +#define MODULE_ALIAS_NFNL_SUBSYS (subsys) \ MODULE_ALIAS("nfnetlink-subsys-" __stringify(subsys))
include/net/netfilter/nf_nat_core.h +8 -0
@@ -25,4 +25,12 @@ static inline int nf_nat_initialized(struct nf_conn *ct, else return test_bit(IPS_DST_NAT_DONE_BIT, &ct->status); } + +struct nlattr ; + +extern int +(*nfnetlink_parse_nat_setup_hook)(struct nf_conn *ct, +enum nf_nat_manip_type manip, +struct nlattr *attr); +#endif /* _NF_NAT_CORE_H */
net/ipv4/netfilter/nf_nat_core.c +97 -0
119 lines not on this page · raw message
net/netfilter/nf_conntrack_core.c +7 -0
@@ -38,9 +38,16 @@#include <net/netfilter/nf_conntrack_core.h> #include <net/netfilter/nf_conntrack_extend.h> #include <net/netfilter/nf_conntrack_acct.h> +#include <net/netfilter/nf_nat.h> #define NF_CONNTRACK_VERSION "0.5.0" +unsigned int +(*nfnetlink_parse_nat_setup_hook)(struct nf_conn *ct, +enum nf_nat_manip_type manip, +struct nlattr *attr)__read_mostly ; +EXPORT_SYMBOL_GPL (nfnetlink_parse_nat_setup_hook); +DEFINE_SPINLOCK (nf_conntrack_lock);EXPORT_SYMBOL_GPL (nf_conntrack_lock);
net/netfilter/nf_conntrack_netlink.c +61 -90
181 lines not on this page · raw message
net/netfilter/nfnetlink.c +9 -3
@@ -44,15 +44,17 @@ static struct sock *nfnl = NULL;static const struct nfnetlink_subsystem *subsys_table[NFNL_SUBSYS_COUNT ];static DEFINE_MUTEX (nfnl_mutex); -static inline void nfnl_lock (void ) +void nfnl_lock (void ) {mutex_lock (&nfnl_mutex); } +EXPORT_SYMBOL_GPL (nfnl_lock); -static inline void nfnl_unlock (void ) +void nfnl_unlock (void ) {mutex_unlock (&nfnl_mutex); } +EXPORT_SYMBOL_GPL (nfnl_unlock);int nfnetlink_subsys_register (const struct nfnetlink_subsystem *n) {
@@ -132,6 +134,7 @@ static int nfnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)return 0 ; type = nlh->nlmsg_type; +replay: ss =nfnetlink_get_subsys (type);if (!ss) {#ifdef CONFIG_KMOD
@@ -165,7 +168,10 @@ static int nfnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) }else return -EINVAL ; -return nc->call (nfnl, skb, nlh, cda); + err = nc->call (nfnl, skb, nlh, cda); +if (err == -EAGAIN ) + goto replay; +return err; } }
Re: netfilter 01/03: restore lost
In reply to Patrick McHardyFrom: Patrick McHardy <[email protected]>
Date: Tue, 14 Oct 2008 16:48:46 +0200 (MEST)
Quoted 1 line
netfilter: restore lost #ifdef guarding defrag exception
Applied.
Re: netfilter 02/03: fix ebtables dependencies
In reply to Patrick McHardyFrom: Patrick McHardy <[email protected]>
Date: Tue, 14 Oct 2008 16:48:47 +0200 (MEST)
Quoted 1 line
netfilter: fix ebtables dependencies
Applied.
David Miller
maintainerRe: netfilter 03/03: ctnetlink: remove bogus module dependency between ctnetlink and nf_nat
In reply to Patrick McHardyFrom: Patrick McHardy <[email protected]>
Date: Tue, 14 Oct 2008 16:48:48 +0200 (MEST)
Quoted 1 line
netfilter: ctnetlink: remove bogus module dependency between ctnetlink and
nf_nat
Ok, I applied this too.
You've used up your "borderline patch" quota for this release, so please no more stuff like this :-)
Thanks!