Skip to contentSkip to conversation

netfilter 00/03: netfilter fixes

DISCUSSION Patrick McHardy 2 participants 5 messages Apr 16, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Hi Dave,

the following three patches fix two netfilter bugs introduced during the merge window and re-add support for a feature that accidentally got dropped with the SAME target removal:

- a missing list initialization of the nf_log logger lists

- a missing conversion to use the hlist_nulls list function in connection tracking helper unregistration

- support for persistent multi-range NAT mappings

Please apply or pull from:

git://git.kernel.org/pub/scm/linux/kernel/git/kaber/nf-2.6.git

Thanks!

 include/net/netfilter/nf_nat.h      |    1 +
 net/ipv4/netfilter/nf_nat_core.c    |    3 ++-
 net/netfilter/nf_conntrack_helper.c |    2 +-
 net/netfilter/nf_log.c              |    4 ++++
 4 files changed, 8 insertions(+), 2 deletions(-)

Eric Dumazet (1):
netfilter: nf_log regression fix

Patrick McHardy (2):
netfilter: nf_conntrack: fix crash when unloading helpers
netfilter: nf_nat: add support for persistent mappings

#1 lore raw

netfilter 01/03: nf_log regression fix

commit b6f0a3652ea9d2296fdc98c3b2c96603be611c4d

Author: Eric Dumazet <[email protected]>
Date:   Wed Apr 15 12:16:19 2009 +0200

netfilter: nf_log regression fix

commit ca735b3aaa945626ba65a3e51145bfe4ecd9e222 'netfilter: use a linked list of loggers'
introduced an array of list_head in "struct nf_logger", but forgot to initialize it in nf_log_register(). This resulted in oops when calling nf_log_unregister() at module unload time.

net/netfilter/nf_log.c +4 -0
index 8bb998f..beb3731 100644
@@ -36,10 +36,14 @@ static struct nf_logger *__find_logger(int pf, const char *str_logger)
 int nf_log_register(u_int8_t pf, struct nf_logger *logger)
 {
 	const struct nf_logger *llog;
+	int i;
 
 	if (pf >= ARRAY_SIZE(nf_loggers))
 		return -EINVAL;
 
+	for (i = 0; i < ARRAY_SIZE(logger->list); i++)
+		INIT_LIST_HEAD(&logger->list[i]);
+
 	mutex_lock(&nf_log_mutex);
 
 	if (pf == NFPROTO_UNSPEC) {
#2 lore raw

netfilter 02/03: nf_conntrack: fix crash when unloading helpers

In reply to Patrick McHardy

commit 38fb0afcd8761f8858e27135ed89a65117e2019c

Author: Patrick McHardy <[email protected]>
Date:   Wed Apr 15 12:45:08 2009 +0200

netfilter: nf_conntrack: fix crash when unloading helpers

Commit ea781f197d (netfilter: nf_conntrack: use SLAB_DESTROY_BY_RCU and) get rid of call_rcu() was missing one conversion to the hlist_nulls functions, causing a crash when unloading conntrack helper modules.

net/netfilter/nf_conntrack_helper.c +1 -1
index 30b8e90..0fa5a42 100644
@@ -176,7 +176,7 @@ static void __nf_conntrack_helper_unregister(struct nf_conntrack_helper *me,
 	}
 
 	/* Get rid of expecteds, set helpers to NULL. */
-	hlist_for_each_entry(h, nn, &net->ct.unconfirmed, hnnode)
+	hlist_nulls_for_each_entry(h, nn, &net->ct.unconfirmed, hnnode)
 		unhelp(h, me);
 	for (i = 0; i < nf_conntrack_htable_size; i++) {
 		hlist_nulls_for_each_entry(h, nn, &net->ct.hash[i], hnnode)
#3 lore raw

netfilter 03/03: nf_nat: add support for persistent mappings

In reply to Patrick McHardy

commit 98d500d66cb7940747b424b245fc6a51ecfbf005

Author: Patrick McHardy <[email protected]>
Date:   Thu Apr 16 18:33:01 2009 +0200

netfilter: nf_nat: add support for persistent mappings

The removal of the SAME target accidentally removed one feature that is not available from the normal NAT targets so far, having multi-range mappings that use the same mapping for each connection from a single client. The current behaviour is to choose the address from the range based on source and destination IP, which breaks when communicating with sites having multiple addresses that require all connections to originate from the same IP address.

Introduce a IP_NAT_RANGE_PERSISTENT option that controls whether the destination address is taken into account for selecting addresses.

http://bugzilla.kernel.org/show_bug.cgi?id=12954

include/net/netfilter/nf_nat.h +1 -0
index 9dc1039..8df0b7f 100644
@@ -18,6 +18,7 @@ enum nf_nat_manip_type
 #define IP_NAT_RANGE_MAP_IPS 1
 #define IP_NAT_RANGE_PROTO_SPECIFIED 2
 #define IP_NAT_RANGE_PROTO_RANDOM 4
+#define IP_NAT_RANGE_PERSISTENT 8
 
 /* NAT sequence number modifications */
 struct nf_nat_seq {
net/ipv4/netfilter/nf_nat_core.c +2 -1
index fe65187..3229e0a 100644
@@ -211,7 +211,8 @@ find_best_ips_proto(struct nf_conntrack_tuple *tuple,
 	minip = ntohl(range->min_ip);
 	maxip = ntohl(range->max_ip);
 	j = jhash_2words((__force u32)tuple->src.u3.ip,
-			 (__force u32)tuple->dst.u3.ip, 0);
+			 range->flags & IP_NAT_RANGE_PERSISTENT ?
+				(__force u32)tuple->dst.u3.ip : 0, 0);
 	j = ((u64)j * (maxip - minip + 1)) >> 32;
 	*var_ipp = htonl(minip + j);
 }
maintainer
#4 lore raw
In reply to Patrick McHardy

From: Patrick McHardy <[email protected]>
Date: Thu, 16 Apr 2009 19:16:22 +0200 (MEST)

Quoted 6 lines

the following three patches fix two netfilter bugs introduced during the merge window and re-add support for a feature that accidentally got dropped with the SAME target removal:

- a missing list initialization of the nf_log logger lists

Quoted 8 lines

- a missing conversion to use the hlist_nulls list function in connection tracking helper unregistration

- support for persistent multi-range NAT mappings

Please apply or pull from:

git://git.kernel.org/pub/scm/linux/kernel/git/kaber/nf-2.6.git

Pulled, thanks a lot!