Skip to contentSkip to conversation

: Netfilter patches

PATCH Applied Patrick McHardy 2 participants 20 messages May 10, 2007 – May 11, 2007

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

cover : Netfilter patches

Hi Dave,

following are a few netfilter patches, containing some cleanup of nf_conntrack, nf_nat and ip_tables, additionally there are two fixes to clear the private helper area when reassigning helpers and compat support for xt_conntrack.

Please apply, thanks.

 include/linux/netfilter/x_tables.h           |    8 +
 include/linux/netfilter_arp/arp_tables.h     |   41 +++++++
 include/linux/netfilter_ipv4/ip_tables.h     |   22 ++++
 include/linux/netfilter_ipv6/ip6_tables.h    |   22 ++++
 include/net/netfilter/nf_conntrack.h         |    7 -
 include/net/netfilter/nf_conntrack_l3proto.h |    3 
 include/net/netfilter/nf_nat_rule.h          |   11 --
 net/ipv4/netfilter/arptable_filter.c         |  140 ++++-----------------------
 net/ipv4/netfilter/iptable_filter.c          |   73 ++++----------
 net/ipv4/netfilter/iptable_mangle.c          |   99 +++++--------------
 net/ipv4/netfilter/iptable_raw.c             |   78 +++++----------
 net/ipv4/netfilter/nf_nat_rule.c             |   86 ++--------------
 net/ipv4/netfilter/nf_nat_standalone.c       |   11 --
 net/ipv6/netfilter/ip6table_filter.c         |   70 ++++---------
 net/ipv6/netfilter/ip6table_mangle.c         |   96 +++++-------------
 net/ipv6/netfilter/ip6table_raw.c            |   52 ----------
 net/netfilter/nf_conntrack_core.c            |   14 +-
 net/netfilter/nf_conntrack_netlink.c         |   40 ++++---
 net/netfilter/xt_conntrack.c                 |   54 ++++++++++
 19 files changed, 354 insertions(+), 573 deletions(-)

Patrick McHardy (4):
[NETFILTER]: Clean up table initialization
[NETFILTER]: iptable_{filter,mangle}: more descriptive "happy cracking" message [NETFILTER]: iptable_raw: ignore short packets sent by SOCK_RAW sockets [NETFILTER]: xt_conntrack: add compat support

Yasuyuki Kozakai (5):
[NETFILTER]: nf_nat: remove unused argument of function allocating binding [NETFILTER]: nf_conntrack: Removes duplicated declarations [NETFILTER]: nf_conntrack: Removes unused destroy operation of l3proto [NETFILTER]: ctnetlink: clear helper area and handle unchanged helper [NETFILTER]: nf_nat: Clears helper private area when NATing

#1 lore raw

PATCH 1/9 : Clean up table initialization

[NETFILTER]: Clean up table initialization

- move arp_tables initial table structure definitions to arp_tables.h similar to ip_tables and ip6_tables

- use C99 initializers

- use initializer macros where possible

---
commit acf2e14c5f3ff9b9ad1500c135a8d9be98d66436
tree c3d814e7e64652f2ec2541e174b9a210ac1f2459
parent a989705c4cf6e6c1a339c95f9daf658b4ba88ca8
author Patrick McHardy <[email protected]> Tue, 08 May 2007 11:06:17 +0200 committer Patrick McHardy <[email protected]> Tue, 08 May 2007 11:06:17 +0200

 include/linux/netfilter/x_tables.h        |    8 ++
 include/linux/netfilter_arp/arp_tables.h  |   41 ++++++++
 include/linux/netfilter_ipv4/ip_tables.h  |   22 +++++
 include/linux/netfilter_ipv6/ip6_tables.h |   22 +++++
 net/ipv4/netfilter/arptable_filter.c      |  140 +++++------------------------
 net/ipv4/netfilter/iptable_filter.c       |   70 +++++----------
 net/ipv4/netfilter/iptable_mangle.c       |   96 ++++++--------------
 net/ipv4/netfilter/iptable_raw.c          |   58 +-----------
 net/ipv4/netfilter/nf_nat_rule.c          |   73 ++-------------
 net/ipv6/netfilter/ip6table_filter.c      |   70 +++++----------
 net/ipv6/netfilter/ip6table_mangle.c      |   96 ++++++--------------
 net/ipv6/netfilter/ip6table_raw.c         |   52 +----------
 12 files changed, 238 insertions(+), 510 deletions(-)
include/linux/netfilter/x_tables.h +8 -0
index 022edfa..7e733a6 100644
@@ -54,6 +54,14 @@ struct xt_entry_target
 	unsigned char data[0];
 };
 
+#define XT_TARGET_INIT(__name, __size)					       \
+{									       \
+	.target.u.user = {						       \
+		.target_size	= XT_ALIGN(__size),			       \
+		.name		= __name,				       \
+	},								       \
+}
+
 struct xt_standard_target
 {
 	struct xt_entry_target target;
include/linux/netfilter_arp/arp_tables.h +41 -0

47 lines not on this page · raw message

include/linux/netfilter_ipv4/ip_tables.h +22 -0
index 9527296..2f46dd7 100644
@@ -295,6 +295,28 @@ struct ipt_error
 	struct ipt_error_target target;
 };
 
+#define IPT_ENTRY_INIT(__size)						       \
+{									       \
+	.target_offset	= sizeof(struct ipt_entry),			       \
+	.next_offset	= (__size),					       \
+}
+
+#define IPT_STANDARD_INIT(__verdict)					       \
+{									       \
+	.entry		= IPT_ENTRY_INIT(sizeof(struct ipt_standard)),	       \
+	.target		= XT_TARGET_INIT(IPT_STANDARD_TARGET,		       \
+					 sizeof(struct xt_standard_target)),   \
+	.target.verdict	= -(__verdict) - 1,				       \
+}
+
+#define IPT_ERROR_INIT							       \
+{									       \
+	.entry		= IPT_ENTRY_INIT(sizeof(struct ipt_error)),	       \
+	.target		= XT_TARGET_INIT(IPT_ERROR_TARGET,		       \
+					 sizeof(struct ipt_error_target)),     \
+	.target.errorname = "ERROR",					       \
+}
+
 extern unsigned int ipt_do_table(struct sk_buff **pskb,
 				 unsigned int hook,
 				 const struct net_device *in,
include/linux/netfilter_ipv6/ip6_tables.h +22 -0
index 61aa104..4686f83 100644
@@ -123,6 +123,28 @@ struct ip6t_error
 	struct ip6t_error_target target;
 };
 
+#define IP6T_ENTRY_INIT(__size)						       \
+{									       \
+	.target_offset	= sizeof(struct ip6t_entry),			       \
+	.next_offset	= (__size),					       \
+}
+
+#define IP6T_STANDARD_INIT(__verdict)					       \
+{									       \
+	.entry		= IP6T_ENTRY_INIT(sizeof(struct ip6t_standard)),       \
+	.target		= XT_TARGET_INIT(IP6T_STANDARD_TARGET,		       \
+					 sizeof(struct ip6t_standard_target)), \
+	.target.verdict	= -(__verdict) - 1,				       \
+}
+
+#define IP6T_ERROR_INIT							       \
+{									       \
+	.entry		= IP6T_ENTRY_INIT(sizeof(struct ip6t_error)),	       \
+	.target		= XT_TARGET_INIT(IP6T_ERROR_TARGET,		       \
+					 sizeof(struct ip6t_error_target)),    \
+	.target.errorname = "ERROR",					       \
+}
+
 /*
  * New IP firewall options for [gs]etsockopt at the RAW IP level.
  * Unlike BSD Linux inherits IP options so you don't have to use
net/ipv4/netfilter/arptable_filter.c +23 -117

151 lines not on this page · raw message

net/ipv4/netfilter/iptable_filter.c +23 -47

76 lines not on this page · raw message

net/ipv4/netfilter/iptable_mangle.c +29 -67

102 lines not on this page · raw message

net/ipv4/netfilter/iptable_raw.c +7 -51

69 lines not on this page · raw message

net/ipv4/netfilter/nf_nat_rule.c +8 -65

85 lines not on this page · raw message

net/ipv6/netfilter/ip6table_filter.c +23 -47

76 lines not on this page · raw message

net/ipv6/netfilter/ip6table_mangle.c +29 -67

102 lines not on this page · raw message

net/ipv6/netfilter/ip6table_raw.c +3 -49

59 lines not on this page · raw message

maintainer Applied
#2 lore raw

Re: [NETFILTER 01/09]: Clean up table initialization

From: Patrick McHardy <[email protected]>
Date: Thu, 10 May 2007 15:41:11 +0200 (MEST)

Quoted 10 lines

[NETFILTER]: Clean up table initialization

- move arp_tables initial table structure definitions to arp_tables.h similar to ip_tables and ip6_tables

- use C99 initializers

- use initializer macros where possible

Applied.

#3 lore raw

PATCH 2/9 : nf_nat: remove unused argument of function allocating binding

In reply to Patrick McHardy

[NETFILTER]: nf_nat: remove unused argument of function allocating binding

nf_nat_rule_find, alloc_null_binding and alloc_null_binding_confirmed do not use the argument 'info', which is actually ct->nat.info. If they are necessary to access it again, we can use the argument 'ct' instead.

---
commit f1103257fddbe3a55b4ae964741cefb5026c20ec
tree 32d30851ebdb14a2dfc5b7b10267b9700cf010d5
parent acf2e14c5f3ff9b9ad1500c135a8d9be98d66436
author Yasuyuki Kozakai <[email protected]> Tue, 08 May 2007 11:06:17 +0200 committer Patrick McHardy <[email protected]> Tue, 08 May 2007 11:06:17 +0200

 include/net/netfilter/nf_nat_rule.h    |   11 +++--------
 net/ipv4/netfilter/nf_nat_rule.c       |   13 ++++---------
 net/ipv4/netfilter/nf_nat_standalone.c |   11 +++--------
 3 files changed, 10 insertions(+), 25 deletions(-)
include/net/netfilter/nf_nat_rule.h +3 -8
index e765654..f974318 100644
@@ -10,16 +10,11 @@ extern int nf_nat_rule_find(struct sk_buff **pskb,
 			    unsigned int hooknum,
 			    const struct net_device *in,
 			    const struct net_device *out,
-			    struct nf_conn *ct,
-			    struct nf_nat_info *info);
+			    struct nf_conn *ct);
 
 extern unsigned int
-alloc_null_binding(struct nf_conn *ct,
-		   struct nf_nat_info *info,
-		   unsigned int hooknum);
+alloc_null_binding(struct nf_conn *ct, unsigned int hooknum);
 
 extern unsigned int
-alloc_null_binding_confirmed(struct nf_conn *ct,
-			     struct nf_nat_info *info,
-			     unsigned int hooknum);
+alloc_null_binding_confirmed(struct nf_conn *ct, unsigned int hooknum);
 #endif /* _NF_NAT_RULE_H */
net/ipv4/netfilter/nf_nat_rule.c +4 -9
index 07e99e3..6740736 100644
@@ -173,9 +173,7 @@ static int ipt_dnat_checkentry(const char *tablename,
 }
 
 inline unsigned int
-alloc_null_binding(struct nf_conn *ct,
-		   struct nf_nat_info *info,
-		   unsigned int hooknum)
+alloc_null_binding(struct nf_conn *ct, unsigned int hooknum)
 {
 	/* Force range to this IP; let proto decide mapping for
 	   per-proto parts (hence not IP_NAT_RANGE_PROTO_SPECIFIED).
@@ -194,9 +192,7 @@ alloc_null_binding(struct nf_conn *ct,
 }
 
 unsigned int
-alloc_null_binding_confirmed(struct nf_conn *ct,
-			     struct nf_nat_info *info,
-			     unsigned int hooknum)
+alloc_null_binding_confirmed(struct nf_conn *ct, unsigned int hooknum)
 {
 	__be32 ip
 		= (HOOK2MANIP(hooknum) == IP_NAT_MANIP_SRC
@@ -218,8 +214,7 @@ int nf_nat_rule_find(struct sk_buff **pskb,
 		     unsigned int hooknum,
 		     const struct net_device *in,
 		     const struct net_device *out,
-		     struct nf_conn *ct,
-		     struct nf_nat_info *info)
+		     struct nf_conn *ct)
 {
 	int ret;
 
@@ -228,7 +223,7 @@ int nf_nat_rule_find(struct sk_buff **pskb,
 	if (ret == NF_ACCEPT) {
 		if (!nf_nat_initialized(ct, HOOK2MANIP(hooknum)))
 			/* NUL mapping */
-			ret = alloc_null_binding(ct, info, hooknum);
+			ret = alloc_null_binding(ct, hooknum);
 	}
 	return ret;
 }
net/ipv4/netfilter/nf_nat_standalone.c +3 -8
index 64bbed2..55dac36 100644
@@ -80,7 +80,6 @@ nf_nat_fn(unsigned int hooknum,
 	struct nf_conn *ct;
 	enum ip_conntrack_info ctinfo;
 	struct nf_conn_nat *nat;
-	struct nf_nat_info *info;
 	/* maniptype == SRC for postrouting. */
 	enum nf_nat_manip_type maniptype = HOOK2MANIP(hooknum);
 
@@ -129,7 +128,6 @@ nf_nat_fn(unsigned int hooknum,
 		}
 		/* Fall thru... (Only ICMPs can be IP_CT_IS_REPLY) */
 	case IP_CT_NEW:
-		info = &nat->info;
 
 		/* Seen it before?  This can happen for loopback, retrans,
 		   or local packets.. */
@@ -138,14 +136,13 @@ nf_nat_fn(unsigned int hooknum,
 
 			if (unlikely(nf_ct_is_confirmed(ct)))
 				/* NAT module was loaded late */
-				ret = alloc_null_binding_confirmed(ct, info,
-								   hooknum);
+				ret = alloc_null_binding_confirmed(ct, hooknum);
 			else if (hooknum == NF_IP_LOCAL_IN)
 				/* LOCAL_IN hook doesn't have a chain!  */
-				ret = alloc_null_binding(ct, info, hooknum);
+				ret = alloc_null_binding(ct, hooknum);
 			else
 				ret = nf_nat_rule_find(pskb, hooknum, in, out,
-						       ct, info);
+						       ct);
 
 			if (ret != NF_ACCEPT) {
 				return ret;
@@ -160,10 +157,8 @@ nf_nat_fn(unsigned int hooknum,
 		/* ESTABLISHED */
 		NF_CT_ASSERT(ctinfo == IP_CT_ESTABLISHED ||
 			     ctinfo == (IP_CT_ESTABLISHED+IP_CT_IS_REPLY));
-		info = &nat->info;
 	}
 
-	NF_CT_ASSERT(info);
 	return nf_nat_packet(ct, ctinfo, hooknum, pskb);
 }
 
maintainer Applied
#4 lore raw

Re: [NETFILTER 02/09]: nf_nat: remove unused argument of function allocating binding

From: Patrick McHardy <[email protected]>
Date: Thu, 10 May 2007 15:41:12 +0200 (MEST)

Quoted 9 lines

[NETFILTER]: nf_nat: remove unused argument of function allocating binding

nf_nat_rule_find, alloc_null_binding and alloc_null_binding_confirmed do not use the argument 'info', which is actually ct->nat.info. If they are necessary to access it again, we can use the argument 'ct' instead.

Applied.

#5 lore raw

PATCH 3/9 : nf_conntrack: Removes duplicated declarations

In reply to Patrick McHardy

[NETFILTER]: nf_conntrack: Removes duplicated declarations

These are also in include/net/netfilter/nf_conntrack_helper.h

---
commit aeca1c226efa93ec47d21303d907d7ab18c30f0e
tree f35fccc4722bc6fe48e574e2c2596723bb01b673
parent f1103257fddbe3a55b4ae964741cefb5026c20ec
author Yasuyuki Kozakai <[email protected]> Tue, 08 May 2007 11:06:18 +0200 committer Patrick McHardy <[email protected]> Tue, 08 May 2007 11:06:18 +0200

 include/net/netfilter/nf_conntrack.h |    7 -------
 1 files changed, 0 insertions(+), 7 deletions(-)
include/net/netfilter/nf_conntrack.h +0 -7
index 1c6b8bd..4732432 100644
@@ -183,13 +183,6 @@ extern void nf_conntrack_hash_insert(struct nf_conn *ct);
 
 extern void nf_conntrack_flush(void);
 
-extern struct nf_conntrack_helper *
-nf_ct_helper_find_get( const struct nf_conntrack_tuple *tuple);
-extern void nf_ct_helper_put(struct nf_conntrack_helper *helper);
-
-extern struct nf_conntrack_helper *
-__nf_conntrack_helper_find_byname(const char *name);
-
 extern int nf_ct_invert_tuplepr(struct nf_conntrack_tuple *inverse,
 				const struct nf_conntrack_tuple *orig);
 
#7 lore raw

PATCH 4/9 : nf_conntrack: Removes unused destroy operation of l3proto

In reply to Patrick McHardy

[NETFILTER]: nf_conntrack: Removes unused destroy operation of l3proto

---
commit f1ab39bebc088ba296db8e047b21700b4a77d51c
tree d3276fe947a35054a48f9ba00ec7a31e2d375432
parent aeca1c226efa93ec47d21303d907d7ab18c30f0e
author Yasuyuki Kozakai <[email protected]> Tue, 08 May 2007 11:06:18 +0200 committer Patrick McHardy <[email protected]> Tue, 08 May 2007 11:06:18 +0200

 include/net/netfilter/nf_conntrack_l3proto.h |    3 ---
 net/netfilter/nf_conntrack_core.c            |    5 -----
 2 files changed, 0 insertions(+), 8 deletions(-)
include/net/netfilter/nf_conntrack_l3proto.h +0 -3
index f32f714..96a58d8 100644
@@ -56,9 +56,6 @@ struct nf_conntrack_l3proto
 	 */
 	int (*new)(struct nf_conn *conntrack, const struct sk_buff *skb);
 
-	/* Called when a conntrack entry is destroyed */
-	void (*destroy)(struct nf_conn *conntrack);
-
 	/*
 	 * Called before tracking. 
 	 *	*dataoff: offset of protocol header (TCP, UDP,...) in *pskb
net/netfilter/nf_conntrack_core.c +0 -5
index e132c8a..94000a4 100644
@@ -299,7 +299,6 @@ destroy_conntrack(struct nf_conntrack *nfct)
 {
 	struct nf_conn *ct = (struct nf_conn *)nfct;
 	struct nf_conn_help *help = nfct_help(ct);
-	struct nf_conntrack_l3proto *l3proto;
 	struct nf_conntrack_l4proto *l4proto;
 	typeof(nf_conntrack_destroyed) destroyed;
 
@@ -317,10 +316,6 @@ destroy_conntrack(struct nf_conntrack *nfct)
 	 * destroy_conntrack() MUST NOT be called with a write lock
 	 * to nf_conntrack_lock!!! -HW */
 	rcu_read_lock();
-	l3proto = __nf_ct_l3proto_find(ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.l3num);
-	if (l3proto && l3proto->destroy)
-		l3proto->destroy(ct);
-
 	l4proto = __nf_ct_l4proto_find(ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.l3num,
 				       ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.protonum);
 	if (l4proto && l4proto->destroy)
#9 lore raw

PATCH 5/9 : ctnetlink: clear helper area and handle unchanged helper

In reply to Patrick McHardy

[NETFILTER]: ctnetlink: clear helper area and handle unchanged helper

This patch
- Clears private area for helper even if no helper is assigned to conntrack. It might be used by old helper.
- Unchanges if the same helper as the used one is specified.
- Does not find helper if no helper is specified. And it does not require private area for helper in that case.

---
commit 9655305aa47e326950ad24fc072ff19aaf5691f9
tree f8c4bc7c4772b99427327af7bf93007f82e8c69f
parent f1ab39bebc088ba296db8e047b21700b4a77d51c
author Yasuyuki Kozakai <[email protected]> Tue, 08 May 2007 11:06:18 +0200 committer Patrick McHardy <[email protected]> Tue, 08 May 2007 11:06:18 +0200

 net/netfilter/nf_conntrack_netlink.c |   40 +++++++++++++++++++---------------
 1 files changed, 22 insertions(+), 18 deletions(-)
net/netfilter/nf_conntrack_netlink.c +22 -18
index aa1a97e..d6d39e2 100644
@@ -830,11 +830,6 @@ ctnetlink_change_helper(struct nf_conn *ct, struct nfattr *cda[])
 	char *helpname;
 	int err;
 
-	if (!help) {
-		/* FIXME: we need to reallocate and rehash */
-		return -EBUSY;
-	}
-
 	/* don't change helper of sibling connections */
 	if (ct->master)
 		return -EINVAL;
@@ -843,25 +838,34 @@ ctnetlink_change_helper(struct nf_conn *ct, struct nfattr *cda[])
 	if (err < 0)
 		return err;
 
-	helper = __nf_conntrack_helper_find_byname(helpname);
-	if (!helper) {
-		if (!strcmp(helpname, ""))
-			helper = NULL;
-		else
-			return -EINVAL;
-	}
-
-	if (help->helper) {
-		if (!helper) {
+	if (!strcmp(helpname, "")) {
+		if (help && help->helper) {
 			/* we had a helper before ... */
 			nf_ct_remove_expectations(ct);
 			help->helper = NULL;
-		} else {
-			/* need to zero data of old helper */
-			memset(&help->help, 0, sizeof(help->help));
 		}
+
+		return 0;
 	}
 
+	if (!help) {
+		/* FIXME: we need to reallocate and rehash */
+		return -EBUSY;
+	}
+
+	helper = __nf_conntrack_helper_find_byname(helpname);
+	if (helper == NULL)
+		return -EINVAL;
+
+	if (help->helper == helper)
+		return 0;
+
+	if (help->helper)
+		/* we had a helper before ... */
+		nf_ct_remove_expectations(ct);
+
+	/* need to zero data of old helper */
+	memset(&help->help, 0, sizeof(help->help));
 	help->helper = helper;
 
 	return 0;
maintainer Applied
#10 lore raw

Re: [NETFILTER 05/09]: ctnetlink: clear helper area and handle unchanged helper

From: Patrick McHardy <[email protected]>
Date: Thu, 10 May 2007 15:41:16 +0200 (MEST)

Quoted 11 lines

[NETFILTER]: ctnetlink: clear helper area and handle unchanged helper

This patch
- Clears private area for helper even if no helper is assigned to conntrack. It might be used by old helper.
- Unchanges if the same helper as the used one is specified.
- Does not find helper if no helper is specified. And it does not require private area for helper in that case.

Applied.

#11 lore raw

PATCH 6/9 : nf_nat: Clears helper private area when NATing

In reply to Patrick McHardy

[NETFILTER]: nf_nat: Clears helper private area when NATing

Some helpers (eg. ftp) assume that private area in conntrack is filled with zero. It should be cleared when helper is changed.

---
commit 204674154410105c5b614101779698b439c2d864
tree c1d5f9835776353a1c53b7313f880ae4a6d8b2f1
parent 9655305aa47e326950ad24fc072ff19aaf5691f9
author Yasuyuki Kozakai <[email protected]> Tue, 08 May 2007 11:06:19 +0200 committer Patrick McHardy <[email protected]> Tue, 08 May 2007 11:06:19 +0200

 net/netfilter/nf_conntrack_core.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
net/netfilter/nf_conntrack_core.c +7 -2
index 94000a4..e8b5c2d 100644
@@ -888,8 +888,13 @@ void nf_conntrack_alter_reply(struct nf_conn *ct,
 	NF_CT_DUMP_TUPLE(newreply);
 
 	ct->tuplehash[IP_CT_DIR_REPLY].tuple = *newreply;
-	if (!ct->master && help && help->expecting == 0)
-		help->helper = __nf_ct_helper_find(newreply);
+	if (!ct->master && help && help->expecting == 0) {
+		struct nf_conntrack_helper *helper;
+		helper = __nf_ct_helper_find(newreply);
+		if (helper)
+			memset(&help->help, 0, sizeof(help->help));
+		help->helper = helper;
+	}
 	write_unlock_bh(&nf_conntrack_lock);
 }
 EXPORT_SYMBOL_GPL(nf_conntrack_alter_reply);
maintainer Applied
#12 lore raw

Re: [NETFILTER 06/09]: nf_nat: Clears helper private area when NATing

From: Patrick McHardy <[email protected]>
Date: Thu, 10 May 2007 15:41:18 +0200 (MEST)

Quoted 7 lines

[NETFILTER]: nf_nat: Clears helper private area when NATing

Some helpers (eg. ftp) assume that private area in conntrack is filled with zero. It should be cleared when helper is changed.

Applied.

#13 lore raw

PATCH 7/9 : iptable_{filter, mangle}: more descriptive "happy cracking" message

In reply to Patrick McHardy

[NETFILTER]: iptable_{filter,mangle}: more descriptive "happy cracking" message

---
commit 2a5f3d9533016d5f7914b75ea5f7a5fe98872f24
tree e20bd2440ccf6814b349fb00cee0941d63b31d61
parent 204674154410105c5b614101779698b439c2d864
author Patrick McHardy <[email protected]> Thu, 10 May 2007 15:30:22 +0200 committer Patrick McHardy <[email protected]> Thu, 10 May 2007 15:30:22 +0200

 net/ipv4/netfilter/iptable_filter.c |    3 ++-
 net/ipv4/netfilter/iptable_mangle.c |    3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
net/ipv4/netfilter/iptable_filter.c +2 -1
index ea14979..4f51c1d 100644
@@ -81,7 +81,8 @@ ipt_local_out_hook(unsigned int hook,
 	if ((*pskb)->len < sizeof(struct iphdr)
 	    || ip_hdrlen(*pskb) < sizeof(struct iphdr)) {
 		if (net_ratelimit())
-			printk("ipt_hook: happy cracking.\n");
+			printk("iptable_filter: ignoring short SOCK_RAW "
+			       "packet.\n");
 		return NF_ACCEPT;
 	}
 
net/ipv4/netfilter/iptable_mangle.c +2 -1
index c3827ba..902446f 100644
@@ -100,7 +100,8 @@ ipt_local_hook(unsigned int hook,
 	if ((*pskb)->len < sizeof(struct iphdr)
 	    || ip_hdrlen(*pskb) < sizeof(struct iphdr)) {
 		if (net_ratelimit())
-			printk("ipt_hook: happy cracking.\n");
+			printk("iptable_mangle: ignoring short SOCK_RAW "
+			       "packet.\n");
 		return NF_ACCEPT;
 	}
 
maintainer
#14 lore raw

Re: [NETFILTER 07/09]: iptable_{filter,mangle}: more descriptive "happy cracking" message

From: Patrick McHardy <[email protected]>
Date: Thu, 10 May 2007 15:41:19 +0200 (MEST)

Quoted 3 lines

[NETFILTER]: iptable_{filter,mangle}: more descriptive "happy cracking" message

In a way I'm very sad to see this message go away, but such is "progress", so applied ;-)

#15 lore raw

Re: [NETFILTER 07/09]: iptable_{filter,mangle}: more descriptive "happy cracking" message

Quoted 11 lines · David Miller

From: Patrick McHardy <[email protected]>
Date: Thu, 10 May 2007 15:41:19 +0200 (MEST)

Quoted 3 lines

[NETFILTER]: iptable_{filter,mangle}: more descriptive "happy cracking" message

In a way I'm very sad to see this message go away, but such is "progress", so applied ;-)

Me too, but I'd rather change it than explain it again. We still have a few of Rusty's funny messages and commentaries left :)

#16 lore raw

PATCH 8/9 : iptable_raw: ignore short packets sent by SOCK_RAW sockets

In reply to Patrick McHardy

[NETFILTER]: iptable_raw: ignore short packets sent by SOCK_RAW sockets

iptables matches and targets expect packets to have at least a full IP header and a valid header length. Ignore packets sent through raw sockets for which this isn't true as in the other tables.

---
commit e319b2005352790a24e1a91dc1af4b2f8643a876
tree 20b707b1bb83996c701f78745f18c75d3e06a3d0
parent 2a5f3d9533016d5f7914b75ea5f7a5fe98872f24
author Patrick McHardy <[email protected]> Thu, 10 May 2007 15:38:16 +0200 committer Patrick McHardy <[email protected]> Thu, 10 May 2007 15:38:16 +0200

 net/ipv4/netfilter/iptable_raw.c |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)
net/ipv4/netfilter/iptable_raw.c +20 -1
index f7d28fd..d6e5033 100644
@@ -5,6 +5,7 @@
  */
 #include <linux/module.h>
 #include <linux/netfilter_ipv4/ip_tables.h>
+#include <net/ip.h>
 
 #define RAW_VALID_HOOKS ((1 << NF_IP_PRE_ROUTING) | (1 << NF_IP_LOCAL_OUT))
 
@@ -54,6 +55,24 @@ ipt_hook(unsigned int hook,
 	return ipt_do_table(pskb, hook, in, out, &packet_raw);
 }
 
+static unsigned int
+ipt_local_hook(unsigned int hook,
+	       struct sk_buff **pskb,
+	       const struct net_device *in,
+	       const struct net_device *out,
+	       int (*okfn)(struct sk_buff *))
+{
+	/* root is playing with raw sockets. */
+	if ((*pskb)->len < sizeof(struct iphdr) ||
+	    ip_hdrlen(*pskb) < sizeof(struct iphdr)) {
+		if (net_ratelimit())
+			printk("iptable_raw: ignoring short SOCK_RAW"
+			       "packet.\n");
+		return NF_ACCEPT;
+	}
+	return ipt_do_table(pskb, hook, in, out, &packet_raw);
+}
+
 /* 'raw' is the very first table. */
 static struct nf_hook_ops ipt_ops[] = {
 	{
@@ -64,7 +83,7 @@ static struct nf_hook_ops ipt_ops[] = {
 		.owner = THIS_MODULE,
 	},
 	{
-		.hook = ipt_hook,
+		.hook = ipt_local_hook,
 		.pf = PF_INET,
 		.hooknum = NF_IP_LOCAL_OUT,
 		.priority = NF_IP_PRI_RAW,
maintainer Applied
#17 lore raw

Re: [NETFILTER 08/09]: iptable_raw: ignore short packets sent by SOCK_RAW sockets

From: Patrick McHardy <[email protected]>
Date: Thu, 10 May 2007 15:41:20 +0200 (MEST)

Quoted 7 lines

[NETFILTER]: iptable_raw: ignore short packets sent by SOCK_RAW sockets

iptables matches and targets expect packets to have at least a full IP header and a valid header length. Ignore packets sent through raw sockets for which this isn't true as in the other tables.

Applied.

#18 lore raw

PATCH 9/9 : xt_conntrack: add compat support

In reply to Patrick McHardy

[NETFILTER]: xt_conntrack: add compat support

---
commit 18a31ce74f45310a1133fadd17f36b879fd0221b
tree 2b0e1102cbb2625a350309348ac0b15a7b54db5d
parent e319b2005352790a24e1a91dc1af4b2f8643a876
author Patrick McHardy <[email protected]> Thu, 10 May 2007 15:39:08 +0200 committer Patrick McHardy <[email protected]> Thu, 10 May 2007 15:39:08 +0200

 net/netfilter/xt_conntrack.c |   54 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 54 insertions(+), 0 deletions(-)
net/netfilter/xt_conntrack.c +54 -0
index f4ea8fe..189ded5 100644
@@ -134,12 +134,66 @@ static void destroy(const struct xt_match *match, void *matchinfo)
 	nf_ct_l3proto_module_put(match->family);
 }
 
+#ifdef CONFIG_COMPAT
+struct compat_xt_conntrack_info
+{
+	compat_uint_t			statemask;
+	compat_uint_t			statusmask;
+	struct ip_conntrack_old_tuple	tuple[IP_CT_DIR_MAX];
+	struct in_addr			sipmsk[IP_CT_DIR_MAX];
+	struct in_addr			dipmsk[IP_CT_DIR_MAX];
+	compat_ulong_t			expires_min;
+	compat_ulong_t			expires_max;
+	u_int8_t			flags;
+	u_int8_t			invflags;
+};
+
+static void compat_from_user(void *dst, void *src)
+{
+	struct compat_xt_conntrack_info *cm = src;
+	struct xt_conntrack_info m = {
+		.statemask	= cm->statemask,
+		.statusmask	= cm->statusmask,
+		.expires_min	= cm->expires_min,
+		.expires_max	= cm->expires_max,
+		.flags		= cm->flags,
+		.invflags	= cm->invflags,
+	};
+	memcpy(m.tuple, cm->tuple, sizeof(m.tuple));
+	memcpy(m.sipmsk, cm->sipmsk, sizeof(m.sipmsk));
+	memcpy(m.dipmsk, cm->dipmsk, sizeof(m.dipmsk));
+	memcpy(dst, &m, sizeof(m));
+}
+
+static int compat_to_user(void __user *dst, void *src)
+{
+	struct xt_conntrack_info *m = src;
+	struct compat_xt_conntrack_info cm = {
+		.statemask	= m->statemask,
+		.statusmask	= m->statusmask,
+		.expires_min	= m->expires_min,
+		.expires_max	= m->expires_max,
+		.flags		= m->flags,
+		.invflags	= m->invflags,
+	};
+	memcpy(cm.tuple, m->tuple, sizeof(cm.tuple));
+	memcpy(cm.sipmsk, m->sipmsk, sizeof(cm.sipmsk));
+	memcpy(cm.dipmsk, m->dipmsk, sizeof(cm.dipmsk));
+	return copy_to_user(dst, &cm, sizeof(cm)) ? -EFAULT : 0;
+}
+#endif
+
 static struct xt_match conntrack_match = {
 	.name		= "conntrack",
 	.match		= match,
 	.checkentry	= checkentry,
 	.destroy	= destroy,
 	.matchsize	= sizeof(struct xt_conntrack_info),
+#ifdef CONFIG_COMPAT
+	.compatsize	= sizeof(struct compat_xt_conntrack_info),
+	.compat_from_user = compat_from_user,
+	.compat_to_user	= compat_to_user,
+#endif
 	.family		= AF_INET,
 	.me		= THIS_MODULE,
 };