Skip to contentSkip to conversation

: Netfilter Update part II

PATCH Applied Patrick McHardy 3 participants 19 messages Jul 14, 2007 – Jul 16, 2007 1 message not in the archive

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

cover : Netfilter Update part II

Hi Dave,

following is a second small netfilter update with patches that missed the first one, containing a new match for limiting the number of connections by a host, some cleanup by Yasuyuki and UDP-Lite conntrack support. NAT support is still missing, I'll probably add that in 2.6.24.

Please apply, thanks.

 include/linux/netfilter/xt_connlimit.h         |   17 ++
 include/net/netfilter/ipv4/nf_conntrack_ipv4.h |    2 +
 include/net/netfilter/ipv6/nf_conntrack_ipv6.h |    2 +-
 include/net/netfilter/nf_conntrack.h           |    4 +
 include/net/netfilter/nf_conntrack_l3proto.h   |    8 +-
 net/bridge/netfilter/ebtables.c                |    4 +-
 net/ipv4/netfilter/arp_tables.c                |    2 +-
 net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c |   25 ++-
 net/ipv4/netfilter/nf_conntrack_proto_icmp.c   |   57 +----
 net/ipv6/netfilter/ip6_tables.c                |    2 +-
 net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c |   31 ++-
 net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c |   46 +---
 net/netfilter/Kconfig                          |   17 ++
 net/netfilter/Makefile                         |    2 +
 net/netfilter/nf_conntrack_core.c              |   37 +++-
 net/netfilter/nf_conntrack_l3proto_generic.c   |    9 +-
 net/netfilter/nf_conntrack_proto_generic.c     |    2 +-
 net/netfilter/nf_conntrack_proto_gre.c         |    2 +-
 net/netfilter/nf_conntrack_proto_sctp.c        |    4 +-
 net/netfilter/nf_conntrack_proto_tcp.c         |    4 +-
 net/netfilter/nf_conntrack_proto_udp.c         |    4 +-
 net/netfilter/nf_conntrack_proto_udplite.c     |  266 ++++++++++++++++++++
 net/netfilter/xt_connlimit.c                   |  313 ++++++++++++++++++++++++
 23 files changed, 730 insertions(+), 130 deletions(-)
 create mode 100644 include/linux/netfilter/xt_connlimit.h
 create mode 100644 net/netfilter/nf_conntrack_proto_udplite.c
 create mode 100644 net/netfilter/xt_connlimit.c

Jan Engelhardt (1):
[NETFILTER]: x_tables: add connlimit match

Patrick McHardy (3):
[NETFILTER]: Lower *tables printk severity [NETFILTER]: nf_conntrack: mark protocols __read_mostly [NETFILTER]: nf_conntrack: UDPLITE support

Yasuyuki Kozakai (4):
[NETFILTER]: nf_conntrack: Increment error count on parsing IPv4 header [NETFILTER]: nf_conntrack: make l3proto->prepare() generic and renames it [NETFILTER]: nf_conntrack: Introduces nf_ct_get_tuplepr and uses it [NETFILTER]: nf_conntrack: Don't track locally generated special ICMP error

#1 lore raw

PATCH 1/8 : nf_conntrack: Increment error count on parsing IPv4 header

[NETFILTER]: nf_conntrack: Increment error count on parsing IPv4 header

---
commit 95f7e72287ad5133bfefdf16cba3f6a1afb1ddb1
tree 1afb502056db9c764bbaf70db92f04e51e41d769
parent d84fbb3afb83c70385ccd341c2c4ed3b795c3963
author Yasuyuki Kozakai <[email protected]> Sat, 14 Jul 2007 17:02:08 +0200 committer Patrick McHardy <[email protected]> Sat, 14 Jul 2007 17:02:08 +0200

 net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c |    2 --
 net/netfilter/nf_conntrack_core.c              |    2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)
net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c +0 -2
index 89e20ab..b5c4bb5 100644
@@ -131,8 +131,6 @@ ipv6_prepare(struct sk_buff **pskb, unsigned int hooknum, unsigned int *dataoff,
 	 */
 	if ((protoff < 0) || (protoff > (*pskb)->len)) {
 		pr_debug("ip6_conntrack_core: can't find proto in pkt\n");
-		NF_CT_STAT_INC_ATOMIC(error);
-		NF_CT_STAT_INC_ATOMIC(invalid);
 		return -NF_ACCEPT;
 	}
 
net/netfilter/nf_conntrack_core.c +2 -0
index 3d14110..b730413 100644
@@ -625,6 +625,8 @@ nf_conntrack_in(int pf, unsigned int hooknum, struct sk_buff **pskb)
 
 	if ((ret = l3proto->prepare(pskb, hooknum, &dataoff, &protonum)) <= 0) {
 		pr_debug("not prepared to track yet or error occured\n");
+		NF_CT_STAT_INC_ATOMIC(error);
+		NF_CT_STAT_INC_ATOMIC(invalid);
 		return -ret;
 	}
 
#3 lore raw

PATCH 2/8 : nf_conntrack: make l3proto->prepare() generic and renames it

In reply to Patrick McHardy

[NETFILTER]: nf_conntrack: make l3proto->prepare() generic and renames it

The icmp[v6] l4proto modules parse headers in ICMP[v6] error to get tuple. But they have to find the offset to transport protocol header before that. Their processings are almost same as prepare() of l3proto modules. This makes prepare() more generic to simplify icmp[v6] l4proto module later.

---
commit 967124a1cd396030f714bc5dfb8c809d3429ee44
tree c4913f1f7e63c643ee717b833864bb4c43d4c82f
parent 95f7e72287ad5133bfefdf16cba3f6a1afb1ddb1
author Yasuyuki Kozakai <[email protected]> Sat, 14 Jul 2007 17:02:12 +0200 committer Patrick McHardy <[email protected]> Sat, 14 Jul 2007 17:02:12 +0200

 include/net/netfilter/ipv6/nf_conntrack_ipv6.h |    2 +-
 include/net/netfilter/nf_conntrack_l3proto.h   |    6 +++--
 net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c |   23 ++++++++++++--------
 net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c |   27 ++++++++++++++----------
 net/netfilter/nf_conntrack_core.c              |    5 +++-
 net/netfilter/nf_conntrack_l3proto_generic.c   |    7 +++---
 6 files changed, 40 insertions(+), 30 deletions(-)
include/net/netfilter/ipv6/nf_conntrack_ipv6.h +1 -1
index b4b6049..5a89659 100644
@@ -7,7 +7,7 @@ extern struct nf_conntrack_l4proto nf_conntrack_l4proto_tcp6;
 extern struct nf_conntrack_l4proto nf_conntrack_l4proto_udp6;
 extern struct nf_conntrack_l4proto nf_conntrack_l4proto_icmpv6;
 
-extern int nf_ct_ipv6_skip_exthdr(struct sk_buff *skb, int start,
+extern int nf_ct_ipv6_skip_exthdr(const struct sk_buff *skb, int start,
 				  u8 *nexthdrp, int len);
 
 extern int nf_ct_frag6_init(void);
include/net/netfilter/nf_conntrack_l3proto.h +3 -3
index 890752d..e3708a6 100644
@@ -58,11 +58,11 @@ struct nf_conntrack_l3proto
 
 	/*
 	 * Called before tracking. 
-	 *	*dataoff: offset of protocol header (TCP, UDP,...) in *pskb
+	 *	*dataoff: offset of protocol header (TCP, UDP,...) in skb
 	 *	*protonum: protocol number
 	 */
-	int (*prepare)(struct sk_buff **pskb, unsigned int hooknum,
-		       unsigned int *dataoff, u_int8_t *protonum);
+	int (*get_l4proto)(const struct sk_buff *skb, unsigned int nhoff,
+			   unsigned int *dataoff, u_int8_t *protonum);
 
 	int (*tuple_to_nfattr)(struct sk_buff *skb,
 			       const struct nf_conntrack_tuple *t);
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c +14 -9
index 3c56299..ee29f4e 100644
@@ -78,21 +78,26 @@ nf_ct_ipv4_gather_frags(struct sk_buff *skb, u_int32_t user)
 	return skb;
 }
 
-static int
-ipv4_prepare(struct sk_buff **pskb, unsigned int hooknum, unsigned int *dataoff,
-	     u_int8_t *protonum)
+static int ipv4_get_l4proto(const struct sk_buff *skb, unsigned int nhoff,
+			    unsigned int *dataoff, u_int8_t *protonum)
 {
+	struct iphdr _iph, *iph;
+
+	iph = skb_header_pointer(skb, nhoff, sizeof(_iph), &_iph);
+	if (iph == NULL)
+		return -NF_DROP;
+
 	/* Never happen */
-	if (ip_hdr(*pskb)->frag_off & htons(IP_OFFSET)) {
+	if (iph->frag_off & htons(IP_OFFSET)) {
 		if (net_ratelimit()) {
-			printk(KERN_ERR "ipv4_prepare: Frag of proto %u (hook=%u)\n",
-			ip_hdr(*pskb)->protocol, hooknum);
+			printk(KERN_ERR "ipv4_get_l4proto: Frag of proto %u\n",
+			iph->protocol);
 		}
 		return -NF_DROP;
 	}
 
-	*dataoff = skb_network_offset(*pskb) + ip_hdrlen(*pskb);
-	*protonum = ip_hdr(*pskb)->protocol;
+	*dataoff = nhoff + (iph->ihl << 2);
+	*protonum = iph->protocol;
 
 	return NF_ACCEPT;
 }
@@ -407,7 +412,7 @@ struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv4 = {
 	.invert_tuple	 = ipv4_invert_tuple,
 	.print_tuple	 = ipv4_print_tuple,
 	.print_conntrack = ipv4_print_conntrack,
-	.prepare	 = ipv4_prepare,
+	.get_l4proto	 = ipv4_get_l4proto,
 #if defined(CONFIG_NF_CT_NETLINK) || defined(CONFIG_NF_CT_NETLINK_MODULE)
 	.tuple_to_nfattr = ipv4_tuple_to_nfattr,
 	.nfattr_to_tuple = ipv4_nfattr_to_tuple,
net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c +16 -11
index b5c4bb5..9b7eaaa 100644
@@ -86,7 +86,7 @@ static int ipv6_print_conntrack(struct seq_file *s,
  *        - Note also special handling of AUTH header. Thanks to IPsec wizards.
  */
 
-int nf_ct_ipv6_skip_exthdr(struct sk_buff *skb, int start, u8 *nexthdrp,
+int nf_ct_ipv6_skip_exthdr(const struct sk_buff *skb, int start, u8 *nexthdrp,
 			   int len)
 {
 	u8 nexthdr = *nexthdrp;
@@ -117,19 +117,24 @@ int nf_ct_ipv6_skip_exthdr(struct sk_buff *skb, int start, u8 *nexthdrp,
 	return start;
 }
 
-static int
-ipv6_prepare(struct sk_buff **pskb, unsigned int hooknum, unsigned int *dataoff,
-	     u_int8_t *protonum)
+static int ipv6_get_l4proto(const struct sk_buff *skb, unsigned int nhoff,
+			    unsigned int *dataoff, u_int8_t *protonum)
 {
-	unsigned int extoff = (u8 *)(ipv6_hdr(*pskb) + 1) - (*pskb)->data;
-	unsigned char pnum = ipv6_hdr(*pskb)->nexthdr;
-	int protoff = nf_ct_ipv6_skip_exthdr(*pskb, extoff, &pnum,
-					     (*pskb)->len - extoff);
+	unsigned int extoff = nhoff + sizeof(struct ipv6hdr);
+	unsigned char pnum;
+	int protoff;
+
+	if (skb_copy_bits(skb, nhoff + offsetof(struct ipv6hdr, nexthdr),
+			  &pnum, sizeof(pnum)) != 0) {
+		pr_debug("ip6_conntrack_core: can't get nexthdr\n");
+		return -NF_ACCEPT;
+	}
+	protoff = nf_ct_ipv6_skip_exthdr(skb, extoff, &pnum, skb->len - extoff);
 	/*
-	 * (protoff == (*pskb)->len) mean that the packet doesn't have no data
+	 * (protoff == skb->len) mean that the packet doesn't have no data
 	 * except of IPv6 & ext headers. but it's tracked anyway. - YK
 	 */
-	if ((protoff < 0) || (protoff > (*pskb)->len)) {
+	if ((protoff < 0) || (protoff > skb->len)) {
 		pr_debug("ip6_conntrack_core: can't find proto in pkt\n");
 		return -NF_ACCEPT;
 	}
@@ -375,7 +380,7 @@ struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv6 = {
 	.invert_tuple		= ipv6_invert_tuple,
 	.print_tuple		= ipv6_print_tuple,
 	.print_conntrack	= ipv6_print_conntrack,
-	.prepare		= ipv6_prepare,
+	.get_l4proto		= ipv6_get_l4proto,
 #if defined(CONFIG_NF_CT_NETLINK) || defined(CONFIG_NF_CT_NETLINK_MODULE)
 	.tuple_to_nfattr	= ipv6_tuple_to_nfattr,
 	.nfattr_to_tuple	= ipv6_nfattr_to_tuple,
net/netfilter/nf_conntrack_core.c +3 -2
index b730413..5b194e3 100644
@@ -622,8 +622,9 @@ nf_conntrack_in(int pf, unsigned int hooknum, struct sk_buff **pskb)
 
 	/* rcu_read_lock()ed by nf_hook_slow */
 	l3proto = __nf_ct_l3proto_find((u_int16_t)pf);
-
-	if ((ret = l3proto->prepare(pskb, hooknum, &dataoff, &protonum)) <= 0) {
+	ret = l3proto->get_l4proto(*pskb, skb_network_offset(*pskb),
+				   &dataoff, &protonum);
+	if (ret <= 0) {
 		pr_debug("not prepared to track yet or error occured\n");
 		NF_CT_STAT_INC_ATOMIC(error);
 		NF_CT_STAT_INC_ATOMIC(invalid);
net/netfilter/nf_conntrack_l3proto_generic.c +3 -4
index b1bfa20..0691642 100644
@@ -61,9 +61,8 @@ static int generic_print_conntrack(struct seq_file *s,
 	return 0;
 }
 
-static int
-generic_prepare(struct sk_buff **pskb, unsigned int hooknum,
-		unsigned int *dataoff, u_int8_t *protonum)
+static int generic_get_l4proto(const struct sk_buff *skb, unsigned int nhoff,
+			       unsigned int *dataoff, u_int8_t *protonum)
 {
 	/* Never track !!! */
 	return -NF_ACCEPT;
@@ -77,6 +76,6 @@ struct nf_conntrack_l3proto nf_conntrack_l3proto_generic = {
 	.invert_tuple	 = generic_invert_tuple,
 	.print_tuple	 = generic_print_tuple,
 	.print_conntrack = generic_print_conntrack,
-	.prepare	 = generic_prepare,
+	.get_l4proto	 = generic_get_l4proto,
 };
 EXPORT_SYMBOL_GPL(nf_conntrack_l3proto_generic);
maintainer Applied
#4 lore raw

Re: [NETFILTER 02/08]: nf_conntrack: make l3proto->prepare() generic and renames it

From: Patrick McHardy <[email protected]>
Date: Sat, 14 Jul 2007 17:12:36 +0200 (MEST)

Quoted 10 lines

[NETFILTER]: nf_conntrack: make l3proto->prepare() generic and renames it

The icmp[v6] l4proto modules parse headers in ICMP[v6] error to get tuple. But they have to find the offset to transport protocol header before that. Their processings are almost same as prepare() of l3proto modules. This makes prepare() more generic to simplify icmp[v6] l4proto module later.

Applied.

#5 lore raw

PATCH 3/8 : nf_conntrack: Introduces nf_ct_get_tuplepr and uses it

In reply to Patrick McHardy

[NETFILTER]: nf_conntrack: Introduces nf_ct_get_tuplepr and uses it

nf_ct_get_tuple() requires the offset to transport header and that bothers callers such as icmp[v6] l4proto modules. This introduces new function to simplify them.

---
commit dabf3efb72da4003b4e22a8159e9ad3007502683
tree 4c6765bd334e0f0bc482947aa457baff1114d532
parent 967124a1cd396030f714bc5dfb8c809d3429ee44
author Yasuyuki Kozakai <[email protected]> Sat, 14 Jul 2007 17:02:14 +0200 committer Patrick McHardy <[email protected]> Sat, 14 Jul 2007 17:02:14 +0200

 include/net/netfilter/nf_conntrack.h           |    4 ++
 net/ipv4/netfilter/nf_conntrack_proto_icmp.c   |   32 ++++--------------
 net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c |   42 +++++-------------------
 net/netfilter/nf_conntrack_core.c              |   30 +++++++++++++++++
 4 files changed, 49 insertions(+), 59 deletions(-)
include/net/netfilter/nf_conntrack.h +4 -0
index d4f02eb..810020e 100644
@@ -186,6 +186,10 @@ 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);
 
net/ipv4/netfilter/nf_conntrack_proto_icmp.c +7 -25
index 0fe8fb0..b8b7999 100644
@@ -136,40 +136,22 @@ icmp_error_message(struct sk_buff *skb,
 		 unsigned int hooknum)
 {
 	struct nf_conntrack_tuple innertuple, origtuple;
-	struct {
-		struct icmphdr icmp;
-		struct iphdr ip;
-	} _in, *inside;
 	struct nf_conntrack_l4proto *innerproto;
 	struct nf_conntrack_tuple_hash *h;
-	int dataoff;
 
 	NF_CT_ASSERT(skb->nfct == NULL);
 
-	/* Not enough header? */
-	inside = skb_header_pointer(skb, ip_hdrlen(skb), sizeof(_in), &_in);
-	if (inside == NULL)
-		return -NF_ACCEPT;
-
-	/* Ignore ICMP's containing fragments (shouldn't happen) */
-	if (inside->ip.frag_off & htons(IP_OFFSET)) {
-		pr_debug("icmp_error_message: fragment of proto %u\n",
-			 inside->ip.protocol);
+	/* Are they talking about one of our connections? */
+	if (!nf_ct_get_tuplepr(skb,
+			       skb_network_offset(skb) + ip_hdrlen(skb)
+						       + sizeof(struct icmphdr),
+			       PF_INET, &origtuple)) {
+		pr_debug("icmp_error_message: failed to get tuple\n");
 		return -NF_ACCEPT;
 	}
 
 	/* rcu_read_lock()ed by nf_hook_slow */
-	innerproto = __nf_ct_l4proto_find(PF_INET, inside->ip.protocol);
-
-	dataoff = ip_hdrlen(skb) + sizeof(inside->icmp);
-	/* Are they talking about one of our connections? */
-	if (!nf_ct_get_tuple(skb, dataoff, dataoff + inside->ip.ihl*4, PF_INET,
-			     inside->ip.protocol, &origtuple,
-			     &nf_conntrack_l3proto_ipv4, innerproto)) {
-		pr_debug("icmp_error_message: ! get_tuple p=%u",
-			 inside->ip.protocol);
-		return -NF_ACCEPT;
-	}
+	innerproto = __nf_ct_l4proto_find(PF_INET, origtuple.dst.protonum);
 
 	/* Ordinarily, we'd expect the inverted tupleproto, but it's
 	   been preserved inside the ICMP. */
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +8 -34

57 lines not on this page · raw message

net/netfilter/nf_conntrack_core.c +30 -0
index 5b194e3..8cce814 100644
@@ -113,6 +113,36 @@ 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)
+{
+	struct nf_conntrack_l3proto *l3proto;
+	struct nf_conntrack_l4proto *l4proto;
+	unsigned int protoff;
+	u_int8_t protonum;
+	int ret;
+
+	rcu_read_lock();
+
+	l3proto = __nf_ct_l3proto_find(l3num);
+	ret = l3proto->get_l4proto(skb, nhoff, &protoff, &protonum);
+	if (ret != NF_ACCEPT) {
+		rcu_read_unlock();
+		return 0;
+	}
+
+	l4proto = __nf_ct_l4proto_find(l3num, protonum);
+
+	ret = nf_ct_get_tuple(skb, nhoff, protoff, l3num, protonum, tuple,
+			      l3proto, l4proto);
+
+	rcu_read_unlock();
+	return ret;
+}
+EXPORT_SYMBOL_GPL(nf_ct_get_tuplepr);
+
 int
 nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse,
 		   const struct nf_conntrack_tuple *orig,
#6 lore raw

PATCH 4/8 : nf_conntrack: Don't track locally generated special ICMP error

In reply to Patrick McHardy

[NETFILTER]: nf_conntrack: Don't track locally generated special ICMP error

The conntrack assigned to locally generated ICMP error is usually the one assigned to the original packet which has caused the error. But if the original packet is handled as invalid by nf_conntrack, no conntrack is assigned to the original packet. Then nf_ct_attach() cannot assign any conntrack to the ICMP error packet. In that case the current nf_conntrack_icmp assigns appropriate conntrack to it. But the current code mistakes the direction of the packet. As a result, NAT code mistakes the address to be mangled.

To fix the bug, this changes nf_conntrack_icmp not to assign conntrack to such ICMP error. Actually no address is necessary to be mangled in this case.

Spotted by Jordan Russell.

---
commit 28b86df4d02014ae5ce0be0e82c074f15ea0dabf
tree 4f1d74fa6059740eb380260300f87e39c4e911ac
parent dabf3efb72da4003b4e22a8159e9ad3007502683
author Yasuyuki Kozakai <[email protected]> Sat, 14 Jul 2007 17:02:19 +0200 committer Patrick McHardy <[email protected]> Sat, 14 Jul 2007 17:02:19 +0200

 net/ipv4/netfilter/nf_conntrack_proto_icmp.c |   22 +++++-----------------
 1 files changed, 5 insertions(+), 17 deletions(-)
net/ipv4/netfilter/nf_conntrack_proto_icmp.c +5 -17
index b8b7999..f965733 100644
@@ -165,25 +165,13 @@ icmp_error_message(struct sk_buff *skb,
 
 	h = nf_conntrack_find_get(&innertuple);
 	if (!h) {
-		/* Locally generated ICMPs will match inverted if they
-		   haven't been SNAT'ed yet */
-		/* FIXME: NAT code has to handle half-done double NAT --RR */
-		if (hooknum == NF_IP_LOCAL_OUT)
-			h = nf_conntrack_find_get(&origtuple);
-
-		if (!h) {
-			pr_debug("icmp_error_message: no match\n");
-			return -NF_ACCEPT;
-		}
-
-		/* Reverse direction from that found */
-		if (NF_CT_DIRECTION(h) == IP_CT_DIR_REPLY)
-			*ctinfo += IP_CT_IS_REPLY;
-	} else {
-		if (NF_CT_DIRECTION(h) == IP_CT_DIR_REPLY)
-			*ctinfo += IP_CT_IS_REPLY;
+		pr_debug("icmp_error_message: no match\n");
+		return -NF_ACCEPT;
 	}
 
+	if (NF_CT_DIRECTION(h) == IP_CT_DIR_REPLY)
+		*ctinfo += IP_CT_IS_REPLY;
+
 	/* Update skb to refer to this connection */
 	skb->nfct = &nf_ct_tuplehash_to_ctrack(h)->ct_general;
 	skb->nfctinfo = *ctinfo;
maintainer Applied
#7 lore raw

Re: [NETFILTER 04/08]: nf_conntrack: Don't track locally generated special ICMP error

From: Patrick McHardy <[email protected]>
Date: Sat, 14 Jul 2007 17:12:39 +0200 (MEST)

Quoted 11 lines

[NETFILTER]: nf_conntrack: Don't track locally generated special ICMP error

The conntrack assigned to locally generated ICMP error is usually the one assigned to the original packet which has caused the error. But if the original packet is handled as invalid by nf_conntrack, no conntrack is assigned to the original packet. Then nf_ct_attach() cannot assign any conntrack to the ICMP error packet. In that case the current nf_conntrack_icmp assigns appropriate conntrack to it. But the current code mistakes the direction of the packet. As a result, NAT code mistakes the address to be mangled.

Quoted 8 lines

To fix the bug, this changes nf_conntrack_icmp not to assign conntrack to such ICMP error. Actually no address is necessary to be mangled in this case.

Spotted by Jordan Russell.

Applied.

#8 lore raw

PATCH 5/8 : Lower *tables printk severity

In reply to Patrick McHardy

[NETFILTER]: Lower *tables printk severity

Lower ip6tables, arptables and ebtables printk severity similar to Dan Aloni's patch for iptables.

---
commit f1cdf0338ecef77b6c1999ae177b4fd21134e625
tree e4ae3f9367502508a48d852fe5492da39ed8cc85
parent 28b86df4d02014ae5ce0be0e82c074f15ea0dabf
author Patrick McHardy <[email protected]> Sat, 14 Jul 2007 17:02:23 +0200 committer Patrick McHardy <[email protected]> Sat, 14 Jul 2007 17:02:23 +0200

 net/bridge/netfilter/ebtables.c |    4 ++--
 net/ipv4/netfilter/arp_tables.c |    2 +-
 net/ipv6/netfilter/ip6_tables.c |    2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
net/bridge/netfilter/ebtables.c +2 -2
index ac9984f..4169a2a 100644
@@ -1525,14 +1525,14 @@ static int __init ebtables_init(void)
 	if ((ret = nf_register_sockopt(&ebt_sockopts)) < 0)
 		return ret;
 
-	printk(KERN_NOTICE "Ebtables v2.0 registered\n");
+	printk(KERN_INFO "Ebtables v2.0 registered\n");
 	return 0;
 }
 
 static void __exit ebtables_fini(void)
 {
 	nf_unregister_sockopt(&ebt_sockopts);
-	printk(KERN_NOTICE "Ebtables v2.0 unregistered\n");
+	printk(KERN_INFO "Ebtables v2.0 unregistered\n");
 }
 
 EXPORT_SYMBOL(ebt_register_table);
net/ipv4/netfilter/arp_tables.c +1 -1
index e981232..d1149ab 100644
@@ -1184,7 +1184,7 @@ static int __init arp_tables_init(void)
 	if (ret < 0)
 		goto err4;
 
-	printk("arp_tables: (C) 2002 David S. Miller\n");
+	printk(KERN_INFO "arp_tables: (C) 2002 David S. Miller\n");
 	return 0;
 
 err4:
net/ipv6/netfilter/ip6_tables.c +1 -1
index 254c769..aeda617 100644
@@ -1497,7 +1497,7 @@ static int __init ip6_tables_init(void)
 	if (ret < 0)
 		goto err5;
 
-	printk("ip6_tables: (C) 2000-2006 Netfilter Core Team\n");
+	printk(KERN_INFO "ip6_tables: (C) 2000-2006 Netfilter Core Team\n");
 	return 0;
 
 err5:
maintainer Applied
#9 lore raw

Re: [NETFILTER 05/08]: Lower *tables printk severity

From: Patrick McHardy <[email protected]>
Date: Sat, 14 Jul 2007 17:12:40 +0200 (MEST)

Quoted 6 lines

[NETFILTER]: Lower *tables printk severity

Lower ip6tables, arptables and ebtables printk severity similar to Dan Aloni's patch for iptables.

Applied.

There are probably other missing KERN_* cases scattered around the rest of netfilter.

#10 lore raw

PATCH 6/8 : x_tables: add connlimit match

In reply to Patrick McHardy

[NETFILTER]: x_tables: add connlimit match

ipt_connlimit has been sitting in POM-NG for a long time. Here is a new shiny xt_connlimit with:

* xtables'ified
* will request the layer3 module
(previously it hotdropped every packet when it was not loaded)
* fixed: there was a deadlock in case of an OOM condition
* support for any layer4 protocol (e.g. UDP/SCTP)
* using jhash, as suggested by Eric Dumazet
* ipv6 support

---
commit ce0ae6ad80f3673eaaa2fb1cab9771939c7e84c6
tree 4078537dc92a3d24c9e42f9b4651c72fc4079fa6
parent f1cdf0338ecef77b6c1999ae177b4fd21134e625
author Jan Engelhardt <[email protected]> Sat, 14 Jul 2007 17:02:26 +0200 committer Patrick McHardy <[email protected]> Sat, 14 Jul 2007 17:05:25 +0200

 include/linux/netfilter/xt_connlimit.h |   17 ++
 net/netfilter/Kconfig                  |    7 +
 net/netfilter/Makefile                 |    1 
 net/netfilter/xt_connlimit.c           |  313 ++++++++++++++++++++++++++++++++
 4 files changed, 338 insertions(+), 0 deletions(-)
include/linux/netfilter/xt_connlimit.h new file +17 -0
new file mode 100644
index 0000000..90ae8b4
@@ -0,0 +1,17 @@
+#ifndef _XT_CONNLIMIT_H
+#define _XT_CONNLIMIT_H
+
+struct xt_connlimit_data;
+
+struct xt_connlimit_info {
+	union {
+		u_int32_t v4_mask;
+		u_int32_t v6_mask[4];
+	};
+	unsigned int limit, inverse;
+
+	/* this needs to be at the end */
+	struct xt_connlimit_data *data __attribute__((aligned(8)));
+};
+
+#endif /* _XT_CONNLIMIT_H */
net/netfilter/Kconfig +7 -0
index df5e8da..9415b9a 100644
@@ -423,6 +423,13 @@ config NETFILTER_XT_MATCH_CONNBYTES
 	  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_CONNLIMIT
+	tristate '"connlimit" match support"'
+	depends on NETFILTER_XTABLES
+	---help---
+	  This match allows you to match against the number of parallel
+	  connections to a server per client IP address (or address block).
+
 config NETFILTER_XT_MATCH_CONNMARK
 	tristate  '"connmark" connection mark match support'
 	depends on NETFILTER_XTABLES
net/netfilter/Makefile +1 -0
index 58b4245..3e4a16a 100644
@@ -52,6 +52,7 @@ obj-$(CONFIG_NETFILTER_XT_TARGET_CONNSECMARK) += xt_CONNSECMARK.o
 # matches
 obj-$(CONFIG_NETFILTER_XT_MATCH_COMMENT) += xt_comment.o
 obj-$(CONFIG_NETFILTER_XT_MATCH_CONNBYTES) += xt_connbytes.o
+obj-$(CONFIG_NETFILTER_XT_MATCH_CONNLIMIT) += xt_connlimit.o
 obj-$(CONFIG_NETFILTER_XT_MATCH_CONNMARK) += xt_connmark.o
 obj-$(CONFIG_NETFILTER_XT_MATCH_CONNTRACK) += xt_conntrack.o
 obj-$(CONFIG_NETFILTER_XT_MATCH_DCCP) += xt_dccp.o
net/netfilter/xt_connlimit.c new file +313 -0

313 lines not on this page · raw message

maintainer Applied
#11 lore raw

Re: [NETFILTER 06/08]: x_tables: add connlimit match

From: Patrick McHardy <[email protected]>
Date: Sat, 14 Jul 2007 17:12:42 +0200 (MEST)

Quoted 13 lines

[NETFILTER]: x_tables: add connlimit match

ipt_connlimit has been sitting in POM-NG for a long time. Here is a new shiny xt_connlimit with:

* xtables'ified
* will request the layer3 module
(previously it hotdropped every packet when it was not loaded)
* fixed: there was a deadlock in case of an OOM condition
* support for any layer4 protocol (e.g. UDP/SCTP)
* using jhash, as suggested by Eric Dumazet
* ipv6 support

Quoted 2 lines

Applied, nice work guys.

#12 lore raw

PATCH 7/8 : nf_conntrack: mark protocols __read_mostly

In reply to Patrick McHardy

[NETFILTER]: nf_conntrack: mark protocols __read_mostly

Also remove two unnecessary EXPORT_SYMBOLs and move the nf_conntrack_l3proto_ipv4 declaration to the correct file.

---
commit 48b2bed5b1229eb77b3df402e70c9c7e8360212d
tree 12da18400ae69862c1c31ad6d84cf847a781b2c1
parent ce0ae6ad80f3673eaaa2fb1cab9771939c7e84c6
author Patrick McHardy <[email protected]> Sat, 14 Jul 2007 17:02:30 +0200 committer Patrick McHardy <[email protected]> Sat, 14 Jul 2007 17:05:35 +0200

 include/net/netfilter/ipv4/nf_conntrack_ipv4.h |    2 ++
 include/net/netfilter/nf_conntrack_l3proto.h   |    2 --
 net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c |    2 +-
 net/ipv4/netfilter/nf_conntrack_proto_icmp.c   |    3 +--
 net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c |    2 +-
 net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c |    4 +---
 net/netfilter/nf_conntrack_l3proto_generic.c   |    2 +-
 net/netfilter/nf_conntrack_proto_generic.c     |    2 +-
 net/netfilter/nf_conntrack_proto_gre.c         |    2 +-
 net/netfilter/nf_conntrack_proto_sctp.c        |    4 ++--
 net/netfilter/nf_conntrack_proto_tcp.c         |    4 ++--
 net/netfilter/nf_conntrack_proto_udp.c         |    4 ++--
 12 files changed, 15 insertions(+), 18 deletions(-)
include/net/netfilter/ipv4/nf_conntrack_ipv4.h +2 -0
index 3ed4e14..7a67160 100644
@@ -12,6 +12,8 @@
 /* Returns new sk_buff, or NULL */
 struct sk_buff *nf_ct_ipv4_ct_gather_frags(struct sk_buff *skb);
 
+extern struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv4;
+
 extern struct nf_conntrack_l4proto nf_conntrack_l4proto_tcp4;
 extern struct nf_conntrack_l4proto nf_conntrack_l4proto_udp4;
 extern struct nf_conntrack_l4proto nf_conntrack_l4proto_icmp;
include/net/netfilter/nf_conntrack_l3proto.h +0 -2
index e3708a6..3c58a2c 100644
@@ -89,8 +89,6 @@ extern struct nf_conntrack_l3proto *nf_ct_l3proto_find_get(u_int16_t l3proto);
 extern void nf_ct_l3proto_put(struct nf_conntrack_l3proto *p);
 
 /* Existing built-in protocols */
-extern struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv4;
-extern struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv6;
 extern struct nf_conntrack_l3proto nf_conntrack_l3proto_generic;
 
 static inline struct nf_conntrack_l3proto *
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c +1 -1
index ee29f4e..64552af 100644
@@ -405,7 +405,7 @@ static struct nf_sockopt_ops so_getorigdst = {
 	.get		= &getorigdst,
 };
 
-struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv4 = {
+struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv4 __read_mostly = {
 	.l3proto	 = PF_INET,
 	.name		 = "ipv4",
 	.pkt_to_tuple	 = ipv4_pkt_to_tuple,
net/ipv4/netfilter/nf_conntrack_proto_icmp.c +1 -2
index f965733..6593fd2 100644
@@ -312,7 +312,7 @@ static struct ctl_table icmp_compat_sysctl_table[] = {
 #endif /* CONFIG_NF_CONNTRACK_PROC_COMPAT */
 #endif /* CONFIG_SYSCTL */
 
-struct nf_conntrack_l4proto nf_conntrack_l4proto_icmp =
+struct nf_conntrack_l4proto nf_conntrack_l4proto_icmp __read_mostly =
 {
 	.l3proto		= PF_INET,
 	.l4proto		= IPPROTO_ICMP,
@@ -338,4 +338,3 @@ struct nf_conntrack_l4proto nf_conntrack_l4proto_icmp =
 #endif
 #endif
 };
-EXPORT_SYMBOL_GPL(nf_conntrack_l4proto_icmp);
net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c +1 -1
index 9b7eaaa..36df221 100644
@@ -373,7 +373,7 @@ static int ipv6_nfattr_to_tuple(struct nfattr *tb[],
 }
 #endif
 
-struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv6 = {
+struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv6 __read_mostly = {
 	.l3proto		= PF_INET6,
 	.name			= "ipv6",
 	.pkt_to_tuple		= ipv6_pkt_to_tuple,
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +1 -3
index 0fca7e8..ab154fb 100644
@@ -276,7 +276,7 @@ static struct ctl_table icmpv6_sysctl_table[] = {
 };
 #endif /* CONFIG_SYSCTL */
 
-struct nf_conntrack_l4proto nf_conntrack_l4proto_icmpv6 =
+struct nf_conntrack_l4proto nf_conntrack_l4proto_icmpv6 __read_mostly =
 {
 	.l3proto		= PF_INET6,
 	.l4proto		= IPPROTO_ICMPV6,
@@ -297,5 +297,3 @@ struct nf_conntrack_l4proto nf_conntrack_l4proto_icmpv6 =
 	.ctl_table		= icmpv6_sysctl_table,
 #endif
 };
-
-EXPORT_SYMBOL(nf_conntrack_l4proto_icmpv6);
net/netfilter/nf_conntrack_l3proto_generic.c +1 -1
index 0691642..991c52c 100644
@@ -69,7 +69,7 @@ static int generic_get_l4proto(const struct sk_buff *skb, unsigned int nhoff,
 }
 
 
-struct nf_conntrack_l3proto nf_conntrack_l3proto_generic = {
+struct nf_conntrack_l3proto nf_conntrack_l3proto_generic __read_mostly = {
 	.l3proto	 = PF_UNSPEC,
 	.name		 = "unknown",
 	.pkt_to_tuple	 = generic_pkt_to_tuple,
net/netfilter/nf_conntrack_proto_generic.c +1 -1
index 6faf1be..d8b5018 100644
@@ -98,7 +98,7 @@ static struct ctl_table generic_compat_sysctl_table[] = {
 #endif /* CONFIG_NF_CONNTRACK_PROC_COMPAT */
 #endif /* CONFIG_SYSCTL */
 
-struct nf_conntrack_l4proto nf_conntrack_l4proto_generic =
+struct nf_conntrack_l4proto nf_conntrack_l4proto_generic __read_mostly =
 {
 	.l3proto		= PF_UNSPEC,
 	.l4proto		= 0,
net/netfilter/nf_conntrack_proto_gre.c +1 -1
index 771c4c2..bdbead8 100644
@@ -261,7 +261,7 @@ static void gre_destroy(struct nf_conn *ct)
 }
 
 /* protocol helper struct */
-static struct nf_conntrack_l4proto nf_conntrack_l4proto_gre4 = {
+static struct nf_conntrack_l4proto nf_conntrack_l4proto_gre4 __read_mostly = {
 	.l3proto	 = AF_INET,
 	.l4proto	 = IPPROTO_GRE,
 	.name		 = "gre",
net/netfilter/nf_conntrack_proto_sctp.c +2 -2
index debfe61..04192ac 100644
@@ -601,7 +601,7 @@ static struct ctl_table sctp_compat_sysctl_table[] = {
 #endif /* CONFIG_NF_CONNTRACK_PROC_COMPAT */
 #endif
 
-struct nf_conntrack_l4proto nf_conntrack_l4proto_sctp4 = {
+static struct nf_conntrack_l4proto nf_conntrack_l4proto_sctp4 __read_mostly = {
 	.l3proto		= PF_INET,
 	.l4proto 		= IPPROTO_SCTP,
 	.name 			= "sctp",
@@ -622,7 +622,7 @@ struct nf_conntrack_l4proto nf_conntrack_l4proto_sctp4 = {
 #endif
 };
 
-struct nf_conntrack_l4proto nf_conntrack_l4proto_sctp6 = {
+static struct nf_conntrack_l4proto nf_conntrack_l4proto_sctp6 __read_mostly = {
 	.l3proto		= PF_INET6,
 	.l4proto 		= IPPROTO_SCTP,
 	.name 			= "sctp",
net/netfilter/nf_conntrack_proto_tcp.c +2 -2
index 1c8206e..87ad3cc 100644
@@ -1372,7 +1372,7 @@ static struct ctl_table tcp_compat_sysctl_table[] = {
 #endif /* CONFIG_NF_CONNTRACK_PROC_COMPAT */
 #endif /* CONFIG_SYSCTL */
 
-struct nf_conntrack_l4proto nf_conntrack_l4proto_tcp4 =
+struct nf_conntrack_l4proto nf_conntrack_l4proto_tcp4 __read_mostly =
 {
 	.l3proto		= PF_INET,
 	.l4proto 		= IPPROTO_TCP,
@@ -1401,7 +1401,7 @@ struct nf_conntrack_l4proto nf_conntrack_l4proto_tcp4 =
 };
 EXPORT_SYMBOL_GPL(nf_conntrack_l4proto_tcp4);
 
-struct nf_conntrack_l4proto nf_conntrack_l4proto_tcp6 =
+struct nf_conntrack_l4proto nf_conntrack_l4proto_tcp6 __read_mostly =
 {
 	.l3proto		= PF_INET6,
 	.l4proto 		= IPPROTO_TCP,
net/netfilter/nf_conntrack_proto_udp.c +2 -2
index 3620ecc..13d94a0 100644
@@ -191,7 +191,7 @@ static struct ctl_table udp_compat_sysctl_table[] = {
 #endif /* CONFIG_NF_CONNTRACK_PROC_COMPAT */
 #endif /* CONFIG_SYSCTL */
 
-struct nf_conntrack_l4proto nf_conntrack_l4proto_udp4 =
+struct nf_conntrack_l4proto nf_conntrack_l4proto_udp4 __read_mostly =
 {
 	.l3proto		= PF_INET,
 	.l4proto		= IPPROTO_UDP,
@@ -218,7 +218,7 @@ struct nf_conntrack_l4proto nf_conntrack_l4proto_udp4 =
 };
 EXPORT_SYMBOL_GPL(nf_conntrack_l4proto_udp4);
 
-struct nf_conntrack_l4proto nf_conntrack_l4proto_udp6 =
+struct nf_conntrack_l4proto nf_conntrack_l4proto_udp6 __read_mostly =
 {
 	.l3proto		= PF_INET6,
 	.l4proto		= IPPROTO_UDP,
maintainer Applied
#13 lore raw

Re: [NETFILTER 07/08]: nf_conntrack: mark protocols __read_mostly

From: Patrick McHardy <[email protected]>
Date: Sat, 14 Jul 2007 17:12:43 +0200 (MEST)

Quoted 6 lines

[NETFILTER]: nf_conntrack: mark protocols __read_mostly

Also remove two unnecessary EXPORT_SYMBOLs and move the nf_conntrack_l3proto_ipv4 declaration to the correct file.

Applied.

#14 lore raw

PATCH 8/8 : nf_conntrack: UDPLITE support

In reply to Patrick McHardy

[NETFILTER]: nf_conntrack: UDPLITE support

---
commit 15e277fed17d039cf1866e2232578d50dee24cba
tree 73162bbea0ce866a151ad12fab92c3de8dfc115a
parent 48b2bed5b1229eb77b3df402e70c9c7e8360212d
author Patrick McHardy <[email protected]> Sat, 14 Jul 2007 17:02:32 +0200 committer Patrick McHardy <[email protected]> Sat, 14 Jul 2007 17:05:35 +0200

 net/netfilter/Kconfig                      |   10 +
 net/netfilter/Makefile                     |    1 
 net/netfilter/nf_conntrack_proto_udplite.c |  266 ++++++++++++++++++++++++++++
 3 files changed, 277 insertions(+), 0 deletions(-)
net/netfilter/Kconfig +10 -0
index 9415b9a..3ac39f1 100644
@@ -102,6 +102,16 @@ config NF_CT_PROTO_SCTP
 	  If you want to compile it as a module, say M here and read
 	  <file:Documentation/kbuild/modules.txt>.  If unsure, say `N'.
 
+config NF_CT_PROTO_UDPLITE
+	tristate 'UDP-Lite protocol connection tracking support (EXPERIMENTAL)'
+	depends on EXPERIMENTAL && NF_CONNTRACK
+	help
+	  With this option enabled, the layer 3 independent connection
+	  tracking code will be able to do state tracking on UDP-Lite
+	  connections.
+
+	  To compile it as a module, choose M here.  If unsure, say N.
+
 config NF_CONNTRACK_AMANDA
 	tristate "Amanda backup protocol support"
 	depends on NF_CONNTRACK
net/netfilter/Makefile +1 -0
index 3e4a16a..0c054bf 100644
@@ -16,6 +16,7 @@ obj-$(CONFIG_NF_CONNTRACK) += nf_conntrack.o
 # SCTP protocol connection tracking
 obj-$(CONFIG_NF_CT_PROTO_GRE) += nf_conntrack_proto_gre.o
 obj-$(CONFIG_NF_CT_PROTO_SCTP) += nf_conntrack_proto_sctp.o
+obj-$(CONFIG_NF_CT_PROTO_UDPLITE) += nf_conntrack_proto_udplite.o
 
 # netlink interface for nf_conntrack
 obj-$(CONFIG_NF_CT_NETLINK) += nf_conntrack_netlink.o
net/netfilter/nf_conntrack_proto_udplite.c new file +266 -0

266 lines not on this page · raw message

#15 lore raw

Re: [NETFILTER 08/08]: nf_conntrack: UDPLITE support

From: Patrick McHardy <[email protected]>
Date: Sat, 14 Jul 2007 17:12:44 +0200 (MEST)

Quoted 1 line

[NETFILTER]: nf_conntrack: UDPLITE support

Maybe you predict this question :) Why do you think that new module is needed instead of reusing codes in nf_conntrack_proto_udp.c ?

-- Yasuyuki Kozakai

A message that is not in the archive (sent off-list or not yet received): [email protected]

#17 lore raw

Re: [NETFILTER 08/08]: nf_conntrack: UDPLITE support

Quoted 9 lines · Yasuyuki KOZAKAI

From: Patrick McHardy <[email protected]>
Date: Sat, 14 Jul 2007 17:12:44 +0200 (MEST)

Quoted 1 line

[NETFILTER]: nf_conntrack: UDPLITE support

Maybe you predict this question :) Why do you think that new module is needed instead of reusing codes in nf_conntrack_proto_udp.c ?

I did :) Reusing code for the conntrack helper didn't seem to buy much, the only two functions that actually do anything besides copying header values are too different to merge (checksumming/ packet handling). It also needs seperate sysctls, which is responsible for another 20%-30% of the code. So it comes down to saving two or three completely trivial functions, which is IMO not even worth exporting them.

For the NAT helpers it makes a lot more sense. The port selection logic, the in_range check, the manip_pkt function for UDP/TCP and the nf_conntrack_netlink functions could all be generalized and moved to a common helper helper :) This is the main reason why I didn't include a NAT helper yet, I have some unfinished work to do all that.

#18 lore raw

Re: [NETFILTER 08/08]: nf_conntrack: UDPLITE support

From: Patrick McHardy <[email protected]>

Quoted 15 lines
Quoted 5 lines
Quoted 1 line

[NETFILTER]: nf_conntrack: UDPLITE support

Maybe you predict this question :) Why do you think that new module is needed instead of reusing codes in nf_conntrack_proto_udp.c ?

I did :) Reusing code for the conntrack helper didn't seem to buy much, the only two functions that actually do anything besides copying header values are too different to merge (checksumming/ packet handling). It also needs seperate sysctls, which is responsible for another 20%-30% of the code. So it comes down to saving two or three completely trivial functions, which is IMO not even worth exporting them.

Quoted 6 lines

For the NAT helpers it makes a lot more sense. The port selection logic, the in_range check, the manip_pkt function for UDP/TCP and the nf_conntrack_netlink functions could all be generalized and moved to a common helper helper :) This is the main reason why I didn't include a NAT helper yet, I have some unfinished work to do all that.

That is nice idea. Thanks for explanation.

-- Yasuyuki Kozakai