Skip to contentSkip to conversation

netfilter 00/29: Netfilter Update

DISCUSSION Patrick McHardy 6 participants 46 messages Nov 27, 2008 – Nov 28, 2008

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

Hi Dave,

the following patches contain part 1 of the netfilter updates for 2.6.29. The highlights are:

- netns support for ebtables, ipt_addrtype and some related cleanups from Alexey Dobriyan

- ctnetlink updates from Pablo: automatic helper module loading, proper event generation for actions performed through ctnetlink, minor cleanups

- switching of xt_NFLOG to directly use nfnetlink_log as backend instead of the first loaded logging module, which was a constant source of confusion for users. From Eric Leblond. Also from Eric are two patches to support rerouting based on packet marks in nfnetlink_queue.

- Misc cleanups and minor fixes from myself, Andy Whitcroft, Simon Arlot and Ingo Molnar.

There's a trivial merge conflict in net/netfilter/nf_conntrack_netlink.c, so the patches won't apply directly. Please pull from

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

Thanks!

 include/linux/netfilter_bridge/ebtables.h    |    3 +-
 include/linux/netfilter_ipv4/ipt_policy.h    |    2 +
 include/linux/netfilter_ipv6/ip6t_policy.h   |    2 +
 include/net/netfilter/nf_conntrack.h         |    5 +-
 include/net/netfilter/nf_conntrack_ecache.h  |   57 +++++++-
 include/net/netfilter/nf_conntrack_expect.h  |    2 +
 include/net/netfilter/nf_conntrack_helper.h  |    5 +-
 include/net/netfilter/nf_conntrack_l4proto.h |    2 +-
 include/net/netfilter/nfnetlink_log.h        |   14 ++
 include/net/netns/x_tables.h                 |    5 +
 net/bridge/br_netfilter.c                    |    2 +-
 net/bridge/netfilter/ebtable_broute.c        |   26 +++-
 net/bridge/netfilter/ebtable_filter.c        |   41 +++++-
 net/bridge/netfilter/ebtable_nat.c           |   38 ++++--
 net/bridge/netfilter/ebtables.c              |   52 +++++---
 net/ipv4/netfilter.c                         |    3 +
 net/ipv4/netfilter/arptable_filter.c         |   12 +--
 net/ipv4/netfilter/ipt_addrtype.c            |   16 ++-
 net/ipv4/netfilter/nf_nat_rule.c             |   23 ---
 net/ipv6/netfilter.c                         |    5 +-
 net/ipv6/netfilter/ip6table_filter.c         |   17 +--
 net/netfilter/nf_conntrack_amanda.c          |    1 +
 net/netfilter/nf_conntrack_core.c            |   61 ++++-----
 net/netfilter/nf_conntrack_ecache.c          |   14 ++-
 net/netfilter/nf_conntrack_expect.c          |   43 +++++-
 net/netfilter/nf_conntrack_ftp.c             |    9 +-
 net/netfilter/nf_conntrack_h323_main.c       |    1 +
 net/netfilter/nf_conntrack_helper.c          |   32 ++++-
 net/netfilter/nf_conntrack_irc.c             |    1 +
 net/netfilter/nf_conntrack_netbios_ns.c      |    1 +
 net/netfilter/nf_conntrack_netlink.c         |  200 ++++++++++++++++++++------
 net/netfilter/nf_conntrack_pptp.c            |    1 +
 net/netfilter/nf_conntrack_proto_gre.c       |    2 +-
 net/netfilter/nf_conntrack_proto_sctp.c      |    2 +-
 net/netfilter/nf_conntrack_sane.c            |    1 +
 net/netfilter/nf_conntrack_sip.c             |    1 +
 net/netfilter/nf_conntrack_tftp.c            |    1 +
 net/netfilter/nfnetlink_log.c                |    4 +-
 net/netfilter/xt_NFLOG.c                     |    5 +-
 net/netfilter/xt_recent.c                    |   22 ++--
 40 files changed, 514 insertions(+), 220 deletions(-)
 create mode 100644 include/net/netfilter/nfnetlink_log.h

Alexey Dobriyan (12):
netfilter: netns-aware ipt_addrtype
netfilter: arptable_filter: merge forward hook
netfilter: netns ebtables: part 1
netfilter: netns ebtables: part 2
netfilter: netns ebtables: more cleanup during ebt_unregister_table()
netfilter: netns ebtables: ebtable_broute in netns
netfilter: netns ebtables: ebtable_filter in netns
netfilter: netns ebtables: ebtable_nat in netns
netfilter: netns ebtables: br_nf_pre_routing_finish() fixup
netfilter: xt_recent: don't save proc dirs
netfilter: ip6table_filter: merge LOCAL_IN and FORWARD hooks
netfilter: nf_conntrack_proto_gre: spread __exit

Andy Whitcroft (1):
netfilter: ip{,6}t_policy.h should include xp_policy.h

Eric Leblond (3):
netfilter: xt_NFLOG: don't call nf_log_packet in NFLOG module.
netfilter: nfmark routing in OUTPUT, mangle, NFQUEUE
netfilter: nfmark IPV6 routing in OUTPUT, mangle, NFQUEUE

Ingo Molnar (2):
netfilter: fix warning in net/netfilter/nf_conntrack_proto_tcp.c
netfilter: fix warning in net/netfilter/nf_conntrack_ftp.c

Pablo Neira Ayuso (6):
netfilter: ctnetlink: use nf_conntrack_get instead of atomic_inc
netfilter: ctnetlink: use EOPNOTSUPP instead of EINVAL if the conntrack has no helper
netfilter: ctnetlink: get rid of module refcounting in ctnetlink
netfilter: nf_conntrack: connection tracking helper name persistent aliases
netfilter: ctnetlink: helper modules load-on-demand support
netfilter: ctnetlink: deliver events for conntracks changed from userspace

Patrick McHardy (4):
netfilter: nfnetlink_log: fix warning and prototype mismatch
netfilter: nf_conntrack: fix warning and prototype mismatch
netfilter: nf_conntrack_proto_sctp: avoid bogus warning
netfilter: nf_conntrack_ftp: change "partial ..." message to pr_debug()

Simon Arlott (1):
netfilter: nf_nat: remove warn_if_extra_mangle

#1 lore raw

netfilter 01/29: xt_NFLOG: don't call nf_log_packet in NFLOG module.

commit 5f7340eff8f68f41b7e5c7ad47ec4cd1ea1afb40

Author: Eric Leblond <[email protected]>
Date:   Tue Nov 4 14:21:08 2008 +0100

netfilter: xt_NFLOG: don't call nf_log_packet in NFLOG module.

This patch modifies xt_NFLOG to suppress the call to nf_log_packet() function. The call of this wrapper in xt_NFLOG was causing NFLOG to use the first initialized module. Thus, if ipt_ULOG is loaded before nfnetlink_log all NFLOG rules are treated as plain LOG rules.

include/net/netfilter/nfnetlink_log.h new file +14 -0
new file mode 100644
index 0000000..9b67f94
@@ -0,0 +1,14 @@
+#ifndef _KER_NFNETLINK_LOG_H
+#define _KER_NFNETLINK_LOG_H
+
+void
+nfulnl_log_packet(unsigned int pf,
+		  unsigned int hooknum,
+		  const struct sk_buff *skb,
+		  const struct net_device *in,
+		  const struct net_device *out,
+		  const struct nf_loginfo *li_user,
+		  const char *prefix);
+
+#endif /* _KER_NFNETLINK_LOG_H */
+
net/netfilter/nfnetlink_log.c +2 -1
index 41e0105..a51892b 100644
@@ -533,7 +533,7 @@ static struct nf_loginfo default_loginfo = {
 };
 
 /* log handler for internal netfilter logging api */
-static void
+void
 nfulnl_log_packet(u_int8_t pf,
 		  unsigned int hooknum,
 		  const struct sk_buff *skb,
@@ -648,6 +648,7 @@ alloc_failure:
 	/* FIXME: statistics */
 	goto unlock_and_release;
 }
+EXPORT_SYMBOL_GPL(nfulnl_log_packet);
 
 static int
 nfulnl_rcv_nl_event(struct notifier_block *this,
net/netfilter/xt_NFLOG.c +3 -2
index 50e3a52..a57c5cf 100644
@@ -13,6 +13,7 @@
 #include <linux/netfilter/x_tables.h>
 #include <linux/netfilter/xt_NFLOG.h>
 #include <net/netfilter/nf_log.h>
+#include <net/netfilter/nfnetlink_log.h>
 
 MODULE_AUTHOR("Patrick McHardy <[email protected]>");
 MODULE_DESCRIPTION("Xtables: packet logging to netlink using NFLOG");
@@ -31,8 +32,8 @@ nflog_tg(struct sk_buff *skb, const struct xt_target_param *par)
 	li.u.ulog.group	     = info->group;
 	li.u.ulog.qthreshold = info->threshold;
 
-	nf_log_packet(par->family, par->hooknum, skb, par->in,
-	              par->out, &li, "%s", info->prefix);
+	nfulnl_log_packet(par->family, par->hooknum, skb, par->in,
+			  par->out, &li, info->prefix);
 	return XT_CONTINUE;
 }
 
#2 lore raw

netfilter 02/29: netns-aware ipt_addrtype

In reply to Patrick McHardy

commit d4ec52bae739409b2372fea30dba0e7a8d6b9181

Author: Alexey Dobriyan <[email protected]>
Date:   Tue Nov 4 14:21:48 2008 +0100

netfilter: netns-aware ipt_addrtype

net/ipv4/netfilter/ipt_addrtype.c +9 -7
index 88762f0..3b216be 100644
@@ -23,24 +23,25 @@ MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Patrick McHardy <[email protected]>");
 MODULE_DESCRIPTION("Xtables: address type match for IPv4");
 
-static inline bool match_type(const struct net_device *dev, __be32 addr,
-			      u_int16_t mask)
+static inline bool match_type(struct net *net, const struct net_device *dev,
+			      __be32 addr, u_int16_t mask)
 {
-	return !!(mask & (1 << inet_dev_addr_type(&init_net, dev, addr)));
+	return !!(mask & (1 << inet_dev_addr_type(net, dev, addr)));
 }
 
 static bool
 addrtype_mt_v0(const struct sk_buff *skb, const struct xt_match_param *par)
 {
+	struct net *net = dev_net(par->in ? par->in : par->out);
 	const struct ipt_addrtype_info *info = par->matchinfo;
 	const struct iphdr *iph = ip_hdr(skb);
 	bool ret = true;
 
 	if (info->source)
-		ret &= match_type(NULL, iph->saddr, info->source) ^
+		ret &= match_type(net, NULL, iph->saddr, info->source) ^
 		       info->invert_source;
 	if (info->dest)
-		ret &= match_type(NULL, iph->daddr, info->dest) ^
+		ret &= match_type(net, NULL, iph->daddr, info->dest) ^
 		       info->invert_dest;
 
 	return ret;
@@ -49,6 +50,7 @@ addrtype_mt_v0(const struct sk_buff *skb, const struct xt_match_param *par)
 static bool
 addrtype_mt_v1(const struct sk_buff *skb, const struct xt_match_param *par)
 {
+	struct net *net = dev_net(par->in ? par->in : par->out);
 	const struct ipt_addrtype_info_v1 *info = par->matchinfo;
 	const struct iphdr *iph = ip_hdr(skb);
 	const struct net_device *dev = NULL;
@@ -60,10 +62,10 @@ addrtype_mt_v1(const struct sk_buff *skb, const struct xt_match_param *par)
 		dev = par->out;
 
 	if (info->source)
-		ret &= match_type(dev, iph->saddr, info->source) ^
+		ret &= match_type(net, dev, iph->saddr, info->source) ^
 		       (info->flags & IPT_ADDRTYPE_INVERT_SOURCE);
 	if (ret && info->dest)
-		ret &= match_type(dev, iph->daddr, info->dest) ^
+		ret &= match_type(net, dev, iph->daddr, info->dest) ^
 		       !!(info->flags & IPT_ADDRTYPE_INVERT_DEST);
 	return ret;
 }
#3 lore raw

netfilter 03/29: arptable_filter: merge forward hook

In reply to Patrick McHardy

commit 19223f26d97077da8cf25251458afe00cae20cbb

Author: Alexey Dobriyan <[email protected]>
Date:   Tue Nov 4 14:22:13 2008 +0100

netfilter: arptable_filter: merge forward hook

It's identical to NF_ARP_IN hook.

net/ipv4/netfilter/arptable_filter.c +1 -11
index bee3d11..e091187 100644
@@ -75,16 +75,6 @@ static unsigned int arpt_out_hook(unsigned int hook,
 			     dev_net(out)->ipv4.arptable_filter);
 }
 
-static unsigned int arpt_forward_hook(unsigned int hook,
-				      struct sk_buff *skb,
-				      const struct net_device *in,
-				      const struct net_device *out,
-				      int (*okfn)(struct sk_buff *))
-{
-	return arpt_do_table(skb, hook, in, out,
-			     dev_net(in)->ipv4.arptable_filter);
-}
-
 static struct nf_hook_ops arpt_ops[] __read_mostly = {
 	{
 		.hook		= arpt_in_hook,
@@ -101,7 +91,7 @@ static struct nf_hook_ops arpt_ops[] __read_mostly = {
 		.priority	= NF_IP_PRI_FILTER,
 	},
 	{
-		.hook		= arpt_forward_hook,
+		.hook		= arpt_in_hook,
 		.owner		= THIS_MODULE,
 		.pf		= NFPROTO_ARP,
 		.hooknum	= NF_ARP_FORWARD,
#4 lore raw

netfilter 04/29: netns ebtables: part 1

In reply to Patrick McHardy

commit 511061e2dd1b84bb21bb97c9216a19606c29ac02

Author: Alexey Dobriyan <[email protected]>
Date:   Tue Nov 4 14:22:55 2008 +0100

netfilter: netns ebtables: part 1

* propagate netns from userspace, register table in passed netns
* remporarily register every ebt_table in init_net

P. S.: one needs to add ".netns_ok = 1" to igmp_protocol to test with ebtables(8) in netns.

include/linux/netfilter_bridge/ebtables.h +1 -1
index d45e29c..624e788 100644
@@ -300,7 +300,7 @@ struct ebt_table
 
 #define EBT_ALIGN(s) (((s) + (__alignof__(struct ebt_replace)-1)) & \
 		     ~(__alignof__(struct ebt_replace)-1))
-extern int ebt_register_table(struct ebt_table *table);
+extern int ebt_register_table(struct net *net, struct ebt_table *table);
 extern void ebt_unregister_table(struct ebt_table *table);
 extern unsigned int ebt_do_table(unsigned int hook, struct sk_buff *skb,
    const struct net_device *in, const struct net_device *out,
net/bridge/netfilter/ebtable_broute.c +1 -1
index 246626b..1731ce8 100644
@@ -66,7 +66,7 @@ static int __init ebtable_broute_init(void)
 {
 	int ret;
 
-	ret = ebt_register_table(&broute_table);
+	ret = ebt_register_table(&init_net, &broute_table);
 	if (ret < 0)
 		return ret;
 	/* see br_input.c */
net/bridge/netfilter/ebtable_filter.c +1 -1
index 1a58af5..af8953c 100644
@@ -95,7 +95,7 @@ static int __init ebtable_filter_init(void)
 {
 	int ret;
 
-	ret = ebt_register_table(&frame_filter);
+	ret = ebt_register_table(&init_net, &frame_filter);
 	if (ret < 0)
 		return ret;
 	ret = nf_register_hooks(ebt_ops_filter, ARRAY_SIZE(ebt_ops_filter));
net/bridge/netfilter/ebtable_nat.c +1 -1
index f60c1e7..bafe160 100644
@@ -102,7 +102,7 @@ static int __init ebtable_nat_init(void)
 {
 	int ret;
 
-	ret = ebt_register_table(&frame_nat);
+	ret = ebt_register_table(&init_net, &frame_nat);
 	if (ret < 0)
 		return ret;
 	ret = nf_register_hooks(ebt_ops_nat, ARRAY_SIZE(ebt_ops_nat));
net/bridge/netfilter/ebtables.c +14 -13
index 0fa208e..c1a82b2 100644
@@ -55,7 +55,6 @@
 
 
 static DEFINE_MUTEX(ebt_mutex);
-static LIST_HEAD(ebt_tables);
 
 static struct xt_target ebt_standard_target = {
 	.name       = "standard",
@@ -315,9 +314,11 @@ find_inlist_lock(struct list_head *head, const char *name, const char *prefix,
 }
 
 static inline struct ebt_table *
-find_table_lock(const char *name, int *error, struct mutex *mutex)
+find_table_lock(struct net *net, const char *name, int *error,
+		struct mutex *mutex)
 {
-	return find_inlist_lock(&ebt_tables, name, "ebtable_", error, mutex);
+	return find_inlist_lock(&net->xt.tables[NFPROTO_BRIDGE], name,
+				"ebtable_", error, mutex);
 }
 
 static inline int
@@ -944,7 +945,7 @@ static void get_counters(struct ebt_counter *oldcounters,
 }
 
 /* replace the table */
-static int do_replace(void __user *user, unsigned int len)
+static int do_replace(struct net *net, void __user *user, unsigned int len)
 {
 	int ret, i, countersize;
 	struct ebt_table_info *newinfo;
@@ -1016,7 +1017,7 @@ static int do_replace(void __user *user, unsigned int len)
 	if (ret != 0)
 		goto free_counterstmp;
 
-	t = find_table_lock(tmp.name, &ret, &ebt_mutex);
+	t = find_table_lock(net, tmp.name, &ret, &ebt_mutex);
 	if (!t) {
 		ret = -ENOENT;
 		goto free_iterate;
@@ -1097,7 +1098,7 @@ free_newinfo:
 	return ret;
 }
 
-int ebt_register_table(struct ebt_table *table)
+int ebt_register_table(struct net *net, struct ebt_table *table)
 {
 	struct ebt_table_info *newinfo;
 	struct ebt_table *t;
@@ -1157,7 +1158,7 @@ int ebt_register_table(struct ebt_table *table)
 	if (ret != 0)
 		goto free_chainstack;
 
-	list_for_each_entry(t, &ebt_tables, list) {
+	list_for_each_entry(t, &net->xt.tables[NFPROTO_BRIDGE], list) {
 		if (strcmp(t->name, table->name) == 0) {
 			ret = -EEXIST;
 			BUGPRINT("Table name already exists\n");
@@ -1170,7 +1171,7 @@ int ebt_register_table(struct ebt_table *table)
 		ret = -ENOENT;
 		goto free_unlock;
 	}
-	list_add(&table->list, &ebt_tables);
+	list_add(&table->list, &net->xt.tables[NFPROTO_BRIDGE]);
 	mutex_unlock(&ebt_mutex);
 	return 0;
 free_unlock:
@@ -1208,7 +1209,7 @@ void ebt_unregister_table(struct ebt_table *table)
 }
 
 /* userspace just supplied us with counters */
-static int update_counters(void __user *user, unsigned int len)
+static int update_counters(struct net *net, void __user *user, unsigned int len)
 {
 	int i, ret;
 	struct ebt_counter *tmp;
@@ -1228,7 +1229,7 @@ static int update_counters(void __user *user, unsigned int len)
 		return -ENOMEM;
 	}
 
-	t = find_table_lock(hlp.name, &ret, &ebt_mutex);
+	t = find_table_lock(net, hlp.name, &ret, &ebt_mutex);
 	if (!t)
 		goto free_tmp;
 
@@ -1386,10 +1387,10 @@ static int do_ebt_set_ctl(struct sock *sk,
 
 	switch(cmd) {
 	case EBT_SO_SET_ENTRIES:
-		ret = do_replace(user, len);
+		ret = do_replace(sock_net(sk), user, len);
 		break;
 	case EBT_SO_SET_COUNTERS:
-		ret = update_counters(user, len);
+		ret = update_counters(sock_net(sk), user, len);
 		break;
 	default:
 		ret = -EINVAL;
@@ -1406,7 +1407,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
 	if (copy_from_user(&tmp, user, sizeof(tmp)))
 		return -EFAULT;
 
-	t = find_table_lock(tmp.name, &ret, &ebt_mutex);
+	t = find_table_lock(sock_net(sk), tmp.name, &ret, &ebt_mutex);
 	if (!t)
 		return ret;
 
#5 lore raw

netfilter 05/29: netns ebtables: part 2

In reply to Patrick McHardy

commit 6beceee5aa2cb94c4ae9f0784c7d3135d343f5b5

Author: Alexey Dobriyan <[email protected]>
Date:   Tue Nov 4 14:27:15 2008 +0100

netfilter: netns ebtables: part 2

* return ebt_table from ebt_register_table(), module code will save it into per-netns data for unregistration
* duplicate ebt_table at the very beginning of registration -- it's added into list, so one ebt_table wouldn't end up in many lists (and each netns has different one)
* introduce underscored tables in individial modules, this is temporary to not break bisection.

include/linux/netfilter_bridge/ebtables.h +2 -1
index 624e788..e40ddb9 100644
@@ -300,7 +300,8 @@ struct ebt_table
 
 #define EBT_ALIGN(s) (((s) + (__alignof__(struct ebt_replace)-1)) & \
 		     ~(__alignof__(struct ebt_replace)-1))
-extern int ebt_register_table(struct net *net, struct ebt_table *table);
+extern struct ebt_table *ebt_register_table(struct net *net,
+					    struct ebt_table *table);
 extern void ebt_unregister_table(struct ebt_table *table);
 extern unsigned int ebt_do_table(unsigned int hook, struct sk_buff *skb,
    const struct net_device *in, const struct net_device *out,
net/bridge/netfilter/ebtable_broute.c +9 -10
index 1731ce8..3277d68 100644
@@ -41,22 +41,23 @@ static int check(const struct ebt_table_info *info, unsigned int valid_hooks)
 	return 0;
 }
 
-static struct ebt_table broute_table =
+static struct ebt_table __broute_table =
 {
 	.name		= "broute",
 	.table		= &initial_table,
 	.valid_hooks	= 1 << NF_BR_BROUTING,
-	.lock		= __RW_LOCK_UNLOCKED(broute_table.lock),
+	.lock		= __RW_LOCK_UNLOCKED(__broute_table.lock),
 	.check		= check,
 	.me		= THIS_MODULE,
 };
+static struct ebt_table *broute_table;
 
 static int ebt_broute(struct sk_buff *skb)
 {
 	int ret;
 
 	ret = ebt_do_table(NF_BR_BROUTING, skb, skb->dev, NULL,
-	   &broute_table);
+	   broute_table);
 	if (ret == NF_DROP)
 		return 1; /* route it */
 	return 0; /* bridge it */
@@ -64,21 +65,19 @@ static int ebt_broute(struct sk_buff *skb)
 
 static int __init ebtable_broute_init(void)
 {
-	int ret;
-
-	ret = ebt_register_table(&init_net, &broute_table);
-	if (ret < 0)
-		return ret;
+	broute_table = ebt_register_table(&init_net, &__broute_table);
+	if (IS_ERR(broute_table))
+		return PTR_ERR(broute_table);
 	/* see br_input.c */
 	rcu_assign_pointer(br_should_route_hook, ebt_broute);
-	return ret;
+	return 0;
 }
 
 static void __exit ebtable_broute_fini(void)
 {
 	rcu_assign_pointer(br_should_route_hook, NULL);
 	synchronize_net();
-	ebt_unregister_table(&broute_table);
+	ebt_unregister_table(broute_table);
 }
 
 module_init(ebtable_broute_init);
net/bridge/netfilter/ebtable_filter.c +9 -8
index af8953c..596564c 100644
@@ -50,21 +50,22 @@ static int check(const struct ebt_table_info *info, unsigned int valid_hooks)
 	return 0;
 }
 
-static struct ebt_table frame_filter =
+static struct ebt_table __frame_filter =
 {
 	.name		= "filter",
 	.table		= &initial_table,
 	.valid_hooks	= FILTER_VALID_HOOKS,
-	.lock		= __RW_LOCK_UNLOCKED(frame_filter.lock),
+	.lock		= __RW_LOCK_UNLOCKED(__frame_filter.lock),
 	.check		= check,
 	.me		= THIS_MODULE,
 };
+static struct ebt_table *frame_filter;
 
 static unsigned int
 ebt_hook(unsigned int hook, struct sk_buff *skb, const struct net_device *in,
    const struct net_device *out, int (*okfn)(struct sk_buff *))
 {
-	return ebt_do_table(hook, skb, in, out, &frame_filter);
+	return ebt_do_table(hook, skb, in, out, frame_filter);
 }
 
 static struct nf_hook_ops ebt_ops_filter[] __read_mostly = {
@@ -95,19 +96,19 @@ static int __init ebtable_filter_init(void)
 {
 	int ret;
 
-	ret = ebt_register_table(&init_net, &frame_filter);
-	if (ret < 0)
-		return ret;
+	frame_filter = ebt_register_table(&init_net, &__frame_filter);
+	if (IS_ERR(frame_filter))
+		return PTR_ERR(frame_filter);
 	ret = nf_register_hooks(ebt_ops_filter, ARRAY_SIZE(ebt_ops_filter));
 	if (ret < 0)
-		ebt_unregister_table(&frame_filter);
+		ebt_unregister_table(frame_filter);
 	return ret;
 }
 
 static void __exit ebtable_filter_fini(void)
 {
 	nf_unregister_hooks(ebt_ops_filter, ARRAY_SIZE(ebt_ops_filter));
-	ebt_unregister_table(&frame_filter);
+	ebt_unregister_table(frame_filter);
 }
 
 module_init(ebtable_filter_init);
net/bridge/netfilter/ebtable_nat.c +10 -9
index bafe160..0d8fc5b 100644
@@ -50,28 +50,29 @@ static int check(const struct ebt_table_info *info, unsigned int valid_hooks)
 	return 0;
 }
 
-static struct ebt_table frame_nat =
+static struct ebt_table __frame_nat =
 {
 	.name		= "nat",
 	.table		= &initial_table,
 	.valid_hooks	= NAT_VALID_HOOKS,
-	.lock		= __RW_LOCK_UNLOCKED(frame_nat.lock),
+	.lock		= __RW_LOCK_UNLOCKED(__frame_nat.lock),
 	.check		= check,
 	.me		= THIS_MODULE,
 };
+static struct ebt_table *frame_nat;
 
 static unsigned int
 ebt_nat_dst(unsigned int hook, struct sk_buff *skb, const struct net_device *in
    , const struct net_device *out, int (*okfn)(struct sk_buff *))
 {
-	return ebt_do_table(hook, skb, in, out, &frame_nat);
+	return ebt_do_table(hook, skb, in, out, frame_nat);
 }
 
 static unsigned int
 ebt_nat_src(unsigned int hook, struct sk_buff *skb, const struct net_device *in
    , const struct net_device *out, int (*okfn)(struct sk_buff *))
 {
-	return ebt_do_table(hook, skb, in, out, &frame_nat);
+	return ebt_do_table(hook, skb, in, out, frame_nat);
 }
 
 static struct nf_hook_ops ebt_ops_nat[] __read_mostly = {
@@ -102,19 +103,19 @@ static int __init ebtable_nat_init(void)
 {
 	int ret;
 
-	ret = ebt_register_table(&init_net, &frame_nat);
-	if (ret < 0)
-		return ret;
+	frame_nat = ebt_register_table(&init_net, &__frame_nat);
+	if (IS_ERR(frame_nat))
+		return PTR_ERR(frame_nat);
 	ret = nf_register_hooks(ebt_ops_nat, ARRAY_SIZE(ebt_ops_nat));
 	if (ret < 0)
-		ebt_unregister_table(&frame_nat);
+		ebt_unregister_table(frame_nat);
 	return ret;
 }
 
 static void __exit ebtable_nat_fini(void)
 {
 	nf_unregister_hooks(ebt_ops_nat, ARRAY_SIZE(ebt_ops_nat));
-	ebt_unregister_table(&frame_nat);
+	ebt_unregister_table(frame_nat);
 }
 
 module_init(ebtable_nat_init);
net/bridge/netfilter/ebtables.c +17 -6
index c1a82b2..82e1752 100644
@@ -1098,7 +1098,7 @@ free_newinfo:
 	return ret;
 }
 
-int ebt_register_table(struct net *net, struct ebt_table *table)
+struct ebt_table *ebt_register_table(struct net *net, struct ebt_table *table)
 {
 	struct ebt_table_info *newinfo;
 	struct ebt_table *t;
@@ -1110,14 +1110,21 @@ int ebt_register_table(struct net *net, struct ebt_table *table)
 	    repl->entries_size == 0 ||
 	    repl->counters || table->private) {
 		BUGPRINT("Bad table data for ebt_register_table!!!\n");
-		return -EINVAL;
+		return ERR_PTR(-EINVAL);
+	}
+
+	/* Don't add one table to multiple lists. */
+	table = kmemdup(table, sizeof(struct ebt_table), GFP_KERNEL);
+	if (!table) {
+		ret = -ENOMEM;
+		goto out;
 	}
 
 	countersize = COUNTER_OFFSET(repl->nentries) * nr_cpu_ids;
 	newinfo = vmalloc(sizeof(*newinfo) + countersize);
 	ret = -ENOMEM;
 	if (!newinfo)
-		return -ENOMEM;
+		goto free_table;
 
 	p = vmalloc(repl->entries_size);
 	if (!p)
@@ -1149,7 +1156,7 @@ int ebt_register_table(struct net *net, struct ebt_table *table)
 
 	if (table->check && table->check(newinfo, table->valid_hooks)) {
 		BUGPRINT("The table doesn't like its own initial data, lol\n");
-		return -EINVAL;
+		return ERR_PTR(-EINVAL);
 	}
 
 	table->private = newinfo;
@@ -1173,7 +1180,7 @@ int ebt_register_table(struct net *net, struct ebt_table *table)
 	}
 	list_add(&table->list, &net->xt.tables[NFPROTO_BRIDGE]);
 	mutex_unlock(&ebt_mutex);
-	return 0;
+	return table;
 free_unlock:
 	mutex_unlock(&ebt_mutex);
 free_chainstack:
@@ -1185,7 +1192,10 @@ free_chainstack:
 	vfree(newinfo->entries);
 free_newinfo:
 	vfree(newinfo);
-	return ret;
+free_table:
+	kfree(table);
+out:
+	return ERR_PTR(ret);
 }
 
 void ebt_unregister_table(struct ebt_table *table)
@@ -1206,6 +1216,7 @@ void ebt_unregister_table(struct ebt_table *table)
 		vfree(table->private->chainstack);
 	}
 	vfree(table->private);
+	kfree(table);
 }
 
 /* userspace just supplied us with counters */
#6 lore raw

netfilter 06/29: netns ebtables: more cleanup during ebt_unregister_table()

In reply to Patrick McHardy

commit dbcdf85a2e3d2aa584dafd10b5a1f42764e673e7

Author: Alexey Dobriyan <[email protected]>
Date:   Tue Nov 4 14:28:04 2008 +0100

netfilter: netns ebtables: more cleanup during ebt_unregister_table()

Now that ebt_unregister_table() can be called during netns stop, and module pinning scheme can't prevent netns stop, do table cleanup by hand.

net/bridge/netfilter/ebtables.c +4 -0
index 82e1752..fa108c4 100644
@@ -1209,6 +1209,10 @@ void ebt_unregister_table(struct ebt_table *table)
 	mutex_lock(&ebt_mutex);
 	list_del(&table->list);
 	mutex_unlock(&ebt_mutex);
+	EBT_ENTRY_ITERATE(table->private->entries, table->private->entries_size,
+			  ebt_cleanup_entry, NULL);
+	if (table->private->nentries)
+		module_put(table->me);
 	vfree(table->private->entries);
 	if (table->private->chainstack) {
 		for_each_possible_cpu(i)
#7 lore raw

netfilter 07/29: netns ebtables: ebtable_broute in netns

In reply to Patrick McHardy

commit 8157e6d16af86e4a8d31a035db7be02a8a171c26

Author: Alexey Dobriyan <[email protected]>
Date:   Tue Nov 4 14:29:03 2008 +0100

netfilter: netns ebtables: ebtable_broute in netns

include/net/netns/x_tables.h +3 -0
index b809397..055e684 100644
@@ -4,7 +4,10 @@
 #include <linux/list.h>
 #include <linux/netfilter.h>
 
+struct ebt_table;
+
 struct netns_xt {
 	struct list_head tables[NFPROTO_NUMPROTO];
+	struct ebt_table *broute_table;
 };
 #endif
net/bridge/netfilter/ebtable_broute.c +27 -8
index 3277d68..8604dfc 100644
@@ -41,33 +41,52 @@ static int check(const struct ebt_table_info *info, unsigned int valid_hooks)
 	return 0;
 }
 
-static struct ebt_table __broute_table =
+static struct ebt_table broute_table =
 {
 	.name		= "broute",
 	.table		= &initial_table,
 	.valid_hooks	= 1 << NF_BR_BROUTING,
-	.lock		= __RW_LOCK_UNLOCKED(__broute_table.lock),
+	.lock		= __RW_LOCK_UNLOCKED(broute_table.lock),
 	.check		= check,
 	.me		= THIS_MODULE,
 };
-static struct ebt_table *broute_table;
 
 static int ebt_broute(struct sk_buff *skb)
 {
 	int ret;
 
 	ret = ebt_do_table(NF_BR_BROUTING, skb, skb->dev, NULL,
-	   broute_table);
+			   dev_net(skb->dev)->xt.broute_table);
 	if (ret == NF_DROP)
 		return 1; /* route it */
 	return 0; /* bridge it */
 }
 
+static int __net_init broute_net_init(struct net *net)
+{
+	net->xt.broute_table = ebt_register_table(net, &broute_table);
+	if (IS_ERR(net->xt.broute_table))
+		return PTR_ERR(net->xt.broute_table);
+	return 0;
+}
+
+static void __net_exit broute_net_exit(struct net *net)
+{
+	ebt_unregister_table(net->xt.broute_table);
+}
+
+static struct pernet_operations broute_net_ops = {
+	.init = broute_net_init,
+	.exit = broute_net_exit,
+};
+
 static int __init ebtable_broute_init(void)
 {
-	broute_table = ebt_register_table(&init_net, &__broute_table);
-	if (IS_ERR(broute_table))
-		return PTR_ERR(broute_table);
+	int ret;
+
+	ret = register_pernet_subsys(&broute_net_ops);
+	if (ret < 0)
+		return ret;
 	/* see br_input.c */
 	rcu_assign_pointer(br_should_route_hook, ebt_broute);
 	return 0;
@@ -77,7 +96,7 @@ static void __exit ebtable_broute_fini(void)
 {
 	rcu_assign_pointer(br_should_route_hook, NULL);
 	synchronize_net();
-	ebt_unregister_table(broute_table);
+	unregister_pernet_subsys(&broute_net_ops);
 }
 
 module_init(ebtable_broute_init);
#11 lore raw

netfilter 08/29: netns ebtables: ebtable_filter in netns

In reply to Patrick McHardy

commit 4aad10938d4e4e8364b664cd5420c3bfeb9b679b

Author: Alexey Dobriyan <[email protected]>
Date:   Tue Nov 4 14:29:58 2008 +0100

netfilter: netns ebtables: ebtable_filter in netns

include/net/netns/x_tables.h +1 -0
index 055e684..d258e16 100644
@@ -9,5 +9,6 @@ struct ebt_table;
 struct netns_xt {
 	struct list_head tables[NFPROTO_NUMPROTO];
 	struct ebt_table *broute_table;
+	struct ebt_table *frame_filter;
 };
 #endif
net/bridge/netfilter/ebtable_filter.c +37 -13

101 lines not on this page · raw message

#12 lore raw

netfilter 09/29: netns ebtables: ebtable_nat in netns

In reply to Patrick McHardy

commit b71b30a626fd0e43c825a05036e7a2c3f377a563

Author: Alexey Dobriyan <[email protected]>
Date:   Tue Nov 4 14:30:46 2008 +0100

netfilter: netns ebtables: ebtable_nat in netns

include/net/netns/x_tables.h +1 -0
index d258e16..9554a64 100644
@@ -10,5 +10,6 @@ struct netns_xt {
 	struct list_head tables[NFPROTO_NUMPROTO];
 	struct ebt_table *broute_table;
 	struct ebt_table *frame_filter;
+	struct ebt_table *frame_nat;
 };
 #endif
net/bridge/netfilter/ebtable_nat.c +32 -15

103 lines not on this page · raw message

#13 lore raw

netfilter 10/29: netns ebtables: br_nf_pre_routing_finish() fixup

In reply to Patrick McHardy

commit 249b62035ca247b9cedbefa1acf6bdc53b96e678

Author: Alexey Dobriyan <[email protected]>
Date:   Tue Nov 4 14:31:29 2008 +0100

netfilter: netns ebtables: br_nf_pre_routing_finish() fixup

net/bridge/br_netfilter.c +1 -1
index db6176d..bf9d6af 100644
@@ -357,7 +357,7 @@ static int br_nf_pre_routing_finish(struct sk_buff *skb)
 			if (err != -EHOSTUNREACH || !in_dev || IN_DEV_FORWARD(in_dev))
 				goto free_skb;
 
-			if (!ip_route_output_key(&init_net, &rt, &fl)) {
+			if (!ip_route_output_key(dev_net(dev), &rt, &fl)) {
 				/* - Bridged-and-DNAT'ed traffic doesn't
 				 *   require ip_forwarding. */
 				if (((struct dst_entry *)rt)->dev == dev) {
#14 lore raw

netfilter 11/29: nf_nat: remove warn_if_extra_mangle

In reply to Patrick McHardy

commit 6e3354c1e9946fa585de40e93ad917ec7abd006e

Author: Simon Arlott <[email protected]>
Date:   Tue Nov 4 14:35:39 2008 +0100

netfilter: nf_nat: remove warn_if_extra_mangle

In net/ipv4/netfilter/nf_nat_rule.c, the function warn_if_extra_mangle was added in commit 5b1158e909ecbe1a052203e0d8df15633f829930 (2006-12-02). I have a DNAT target in the OUTPUT chain than changes connections with dst 2.0.0.1 to another address which I'll substitute with 66.102.9.99 below.

On every boot I get the following message:
[ 146.252505] NAT: no longer support implicit source local NAT [ 146.252517] NAT: packet src 66.102.9.99 -> dst 2.0.0.1

As far as I can tell from reading the function doing this, it should warn if the source IP for the route to 66.102.9.99 is different from 2.0.0.1 but that is not the case. It doesn't make sense to check the DNAT target against the local route source.

Either the function should be changed to correctly check the route, or it should be removed entirely as it's been nearly 2 years since it was added.

net/ipv4/netfilter/nf_nat_rule.c +0 -23
index a4f1c34..cf95469 100644
@@ -86,24 +86,6 @@ ipt_snat_target(struct sk_buff *skb, const struct xt_target_param *par)
 	return nf_nat_setup_info(ct, &mr->range[0], IP_NAT_MANIP_SRC);
 }
 
-/* Before 2.6.11 we did implicit source NAT if required. Warn about change. */
-static void warn_if_extra_mangle(struct net *net, __be32 dstip, __be32 srcip)
-{
-	static int warned = 0;
-	struct flowi fl = { .nl_u = { .ip4_u = { .daddr = dstip } } };
-	struct rtable *rt;
-
-	if (ip_route_output_key(net, &rt, &fl) != 0)
-		return;
-
-	if (rt->rt_src != srcip && !warned) {
-		printk("NAT: no longer support implicit source local NAT\n");
-		printk("NAT: packet src %pI4 -> dst %pI4\n", &srcip, &dstip);
-		warned = 1;
-	}
-	ip_rt_put(rt);
-}
-
 static unsigned int
 ipt_dnat_target(struct sk_buff *skb, const struct xt_target_param *par)
 {
@@ -119,11 +101,6 @@ ipt_dnat_target(struct sk_buff *skb, const struct xt_target_param *par)
 	/* Connection must be valid and new. */
 	NF_CT_ASSERT(ct && (ctinfo == IP_CT_NEW || ctinfo == IP_CT_RELATED));
 
-	if (par->hooknum == NF_INET_LOCAL_OUT &&
-	    mr->range[0].flags & IP_NAT_RANGE_MAP_IPS)
-		warn_if_extra_mangle(dev_net(par->out), ip_hdr(skb)->daddr,
-				     mr->range[0].min_ip);
-
 	return nf_nat_setup_info(ct, &mr->range[0], IP_NAT_MANIP_DST);
 }
 
#16 lore raw

netfilter 12/29: ctnetlink: use nf_conntrack_get instead of atomic_inc

In reply to Patrick McHardy

commit 238ede8160443a32379fd8f9eb88d00456a09bb4

Author: Pablo Neira Ayuso <[email protected]>
Date:   Mon Nov 17 15:53:33 2008 +0100

netfilter: ctnetlink: use nf_conntrack_get instead of atomic_inc

Use nf_conntrack_get instead of the direct call to atomic_inc.

net/netfilter/nf_conntrack_netlink.c +1 -1
index a040d46..80a3f13 100644
@@ -1209,7 +1209,7 @@ ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,
 				goto out_unlock;
 			}
 			master_ct = nf_ct_tuplehash_to_ctrack(master_h);
-			atomic_inc(&master_ct->ct_general.use);
+			nf_conntrack_get(&master_ct->ct_general);
 		}
 
 		spin_unlock_bh(&nf_conntrack_lock);
#17 lore raw

netfilter 13/29: ctnetlink: use EOPNOTSUPP instead of EINVAL if the conntrack has no helper

In reply to Patrick McHardy

commit bfe2967735e0e0f650bf698a5683db2b6cf4cfd7

Author: Pablo Neira Ayuso <[email protected]>
Date:   Mon Nov 17 15:55:48 2008 +0100

netfilter: ctnetlink: use EOPNOTSUPP instead of EINVAL if the conntrack has no helper

This patch changes the return value if the conntrack has no helper assigned. Instead of EINVAL, which is reserved for malformed messages, it returns EOPNOTSUPP.

net/netfilter/nf_conntrack_netlink.c +1 -1
index 80a3f13..d87a939 100644
@@ -1652,7 +1652,7 @@ ctnetlink_create_expect(struct nlattr *cda[], u_int8_t u3)
 
 	if (!help || !help->helper) {
 		/* such conntrack hasn't got any helper, abort */
-		err = -EINVAL;
+		err = -EOPNOTSUPP;
 		goto out;
 	}
 
#18 lore raw

netfilter 14/29: ctnetlink: get rid of module refcounting in ctnetlink

In reply to Patrick McHardy

commit 528a3a6f67d4fbe708b9f306be194e78b29e8d7a

Author: Pablo Neira Ayuso <[email protected]>
Date:   Mon Nov 17 16:00:40 2008 +0100

netfilter: ctnetlink: get rid of module refcounting in ctnetlink

This patch replaces the unnecessary module refcounting with the read-side locks. With this patch, all the dump and fill_info function are called under the RCU read lock.

Based on a patch from Fabian Hugelshofer.

net/netfilter/nf_conntrack_netlink.c +18 -20
index d87a939..49a04fa 100644
@@ -105,16 +105,14 @@ ctnetlink_dump_tuples(struct sk_buff *skb,
 	struct nf_conntrack_l3proto *l3proto;
 	struct nf_conntrack_l4proto *l4proto;
 
-	l3proto = nf_ct_l3proto_find_get(tuple->src.l3num);
+	l3proto = __nf_ct_l3proto_find(tuple->src.l3num);
 	ret = ctnetlink_dump_tuples_ip(skb, tuple, l3proto);
-	nf_ct_l3proto_put(l3proto);
 
 	if (unlikely(ret < 0))
 		return ret;
 
-	l4proto = nf_ct_l4proto_find_get(tuple->src.l3num, tuple->dst.protonum);
+	l4proto = __nf_ct_l4proto_find(tuple->src.l3num, tuple->dst.protonum);
 	ret = ctnetlink_dump_tuples_proto(skb, tuple, l4proto);
-	nf_ct_l4proto_put(l4proto);
 
 	return ret;
 }
@@ -151,11 +149,9 @@ ctnetlink_dump_protoinfo(struct sk_buff *skb, const struct nf_conn *ct)
 	struct nlattr *nest_proto;
 	int ret;
 
-	l4proto = nf_ct_l4proto_find_get(nf_ct_l3num(ct), nf_ct_protonum(ct));
-	if (!l4proto->to_nlattr) {
-		nf_ct_l4proto_put(l4proto);
+	l4proto = __nf_ct_l4proto_find(nf_ct_l3num(ct), nf_ct_protonum(ct));
+	if (!l4proto->to_nlattr)
 		return 0;
-	}
 
 	nest_proto = nla_nest_start(skb, CTA_PROTOINFO | NLA_F_NESTED);
 	if (!nest_proto)
@@ -163,14 +159,11 @@ ctnetlink_dump_protoinfo(struct sk_buff *skb, const struct nf_conn *ct)
 
 	ret = l4proto->to_nlattr(skb, nest_proto, ct);
 
-	nf_ct_l4proto_put(l4proto);
-
 	nla_nest_end(skb, nest_proto);
 
 	return ret;
 
 nla_put_failure:
-	nf_ct_l4proto_put(l4proto);
 	return -1;
 }
 
@@ -184,7 +177,6 @@ ctnetlink_dump_helpinfo(struct sk_buff *skb, const struct nf_conn *ct)
 	if (!help)
 		return 0;
 
-	rcu_read_lock();
 	helper = rcu_dereference(help->helper);
 	if (!helper)
 		goto out;
@@ -199,11 +191,9 @@ ctnetlink_dump_helpinfo(struct sk_buff *skb, const struct nf_conn *ct)
 
 	nla_nest_end(skb, nest_helper);
 out:
-	rcu_read_unlock();
 	return 0;
 
 nla_put_failure:
-	rcu_read_unlock();
 	return -1;
 }
 
@@ -461,6 +451,7 @@ static int ctnetlink_conntrack_event(struct notifier_block *this,
 	nfmsg->version	= NFNETLINK_V0;
 	nfmsg->res_id	= 0;
 
+	rcu_read_lock();
 	nest_parms = nla_nest_start(skb, CTA_TUPLE_ORIG | NLA_F_NESTED);
 	if (!nest_parms)
 		goto nla_put_failure;
@@ -517,13 +508,15 @@ static int ctnetlink_conntrack_event(struct notifier_block *this,
 	    && ctnetlink_dump_mark(skb, ct) < 0)
 		goto nla_put_failure;
 #endif
+	rcu_read_unlock();
 
 	nlh->nlmsg_len = skb->tail - b;
 	nfnetlink_send(skb, 0, group, 0);
 	return NOTIFY_DONE;
 
-nlmsg_failure:
 nla_put_failure:
+	rcu_read_unlock();
+nlmsg_failure:
 	kfree_skb(skb);
 	return NOTIFY_DONE;
 }
@@ -795,8 +788,10 @@ ctnetlink_get_conntrack(struct sock *ctnl, struct sk_buff *skb,
 		return -ENOMEM;
 	}
 
+	rcu_read_lock();
 	err = ctnetlink_fill_info(skb2, NETLINK_CB(skb).pid, nlh->nlmsg_seq,
 				  IPCTNL_MSG_CT_NEW, 1, ct);
+	rcu_read_unlock();
 	nf_ct_put(ct);
 	if (err <= 0)
 		goto free;
@@ -1292,16 +1287,14 @@ ctnetlink_exp_dump_mask(struct sk_buff *skb,
 	if (!nest_parms)
 		goto nla_put_failure;
 
-	l3proto = nf_ct_l3proto_find_get(tuple->src.l3num);
+	l3proto = __nf_ct_l3proto_find(tuple->src.l3num);
 	ret = ctnetlink_dump_tuples_ip(skb, &m, l3proto);
-	nf_ct_l3proto_put(l3proto);
 
 	if (unlikely(ret < 0))
 		goto nla_put_failure;
 
-	l4proto = nf_ct_l4proto_find_get(tuple->src.l3num, tuple->dst.protonum);
+	l4proto = __nf_ct_l4proto_find(tuple->src.l3num, tuple->dst.protonum);
 	ret = ctnetlink_dump_tuples_proto(skb, &m, l4proto);
-	nf_ct_l4proto_put(l4proto);
 	if (unlikely(ret < 0))
 		goto nla_put_failure;
 
@@ -1408,15 +1401,18 @@ static int ctnetlink_expect_event(struct notifier_block *this,
 	nfmsg->version	    = NFNETLINK_V0;
 	nfmsg->res_id	    = 0;
 
+	rcu_read_lock();
 	if (ctnetlink_exp_dump_expect(skb, exp) < 0)
 		goto nla_put_failure;
+	rcu_read_unlock();
 
 	nlh->nlmsg_len = skb->tail - b;
 	nfnetlink_send(skb, 0, NFNLGRP_CONNTRACK_EXP_NEW, 0);
 	return NOTIFY_DONE;
 
-nlmsg_failure:
 nla_put_failure:
+	rcu_read_unlock();
+nlmsg_failure:
 	kfree_skb(skb);
 	return NOTIFY_DONE;
 }
@@ -1520,9 +1516,11 @@ ctnetlink_get_expect(struct sock *ctnl, struct sk_buff *skb,
 	if (!skb2)
 		goto out;
 
+	rcu_read_lock();
 	err = ctnetlink_exp_fill_info(skb2, NETLINK_CB(skb).pid,
 				      nlh->nlmsg_seq, IPCTNL_MSG_EXP_NEW,
 				      1, exp);
+	rcu_read_unlock();
 	if (err <= 0)
 		goto free;
 
#19 lore raw

netfilter 15/29: nf_conntrack: connection tracking helper name persistent aliases

In reply to Patrick McHardy

commit 4dc06f9633444f426ef9960c53426f2d2ded64ac

Author: Pablo Neira Ayuso <[email protected]>
Date:   Mon Nov 17 16:01:42 2008 +0100

netfilter: nf_conntrack: connection tracking helper name persistent aliases

This patch adds the macro MODULE_ALIAS_NFCT_HELPER that defines a way to provide generic and persistent aliases for the connection tracking helpers.

This next patch requires this patch.

include/net/netfilter/nf_conntrack.h +3 -0
index b76a868..f11255e 100644
@@ -298,5 +298,8 @@ do {							\
 	local_bh_enable();				\
 } while (0)
 
+#define MODULE_ALIAS_NFCT_HELPER(helper) \
+        MODULE_ALIAS("nfct-helper-" helper)
+
 #endif /* __KERNEL__ */
 #endif /* _NF_CONNTRACK_H */
net/netfilter/nf_conntrack_amanda.c +1 -0
index 38aedee..4f8fcf4 100644
@@ -30,6 +30,7 @@ MODULE_AUTHOR("Brian J. Murrell <[email protected]>");
 MODULE_DESCRIPTION("Amanda connection tracking module");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS("ip_conntrack_amanda");
+MODULE_ALIAS_NFCT_HELPER("amanda");
 
 module_param(master_timeout, uint, 0600);
 MODULE_PARM_DESC(master_timeout, "timeout for the master connection");
net/netfilter/nf_conntrack_ftp.c +1 -0
index 6295009..703a437 100644
@@ -29,6 +29,7 @@ MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Rusty Russell <[email protected]>");
 MODULE_DESCRIPTION("ftp connection tracking helper");
 MODULE_ALIAS("ip_conntrack_ftp");
+MODULE_ALIAS_NFCT_HELPER("ftp");
 
 /* This is slow, but it's simple. --RR */
 static char *ftp_buffer;
net/netfilter/nf_conntrack_h323_main.c +1 -0
index 99bc803..687bd63 100644
@@ -1827,3 +1827,4 @@ MODULE_AUTHOR("Jing Min Zhao <[email protected]>");
 MODULE_DESCRIPTION("H.323 connection tracking helper");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS("ip_conntrack_h323");
+MODULE_ALIAS_NFCT_HELPER("h323");
net/netfilter/nf_conntrack_irc.c +1 -0
index 4d681a0..409c8be 100644
@@ -41,6 +41,7 @@ MODULE_AUTHOR("Harald Welte <[email protected]>");
 MODULE_DESCRIPTION("IRC (DCC) connection tracking helper");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS("ip_conntrack_irc");
+MODULE_ALIAS_NFCT_HELPER("irc");
 
 module_param_array(ports, ushort, &ports_c, 0400);
 MODULE_PARM_DESC(ports, "port numbers of IRC servers");
net/netfilter/nf_conntrack_netbios_ns.c +1 -0
index 08404e6..5af4273 100644
@@ -37,6 +37,7 @@ MODULE_AUTHOR("Patrick McHardy <[email protected]>");
 MODULE_DESCRIPTION("NetBIOS name service broadcast connection tracking helper");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS("ip_conntrack_netbios_ns");
+MODULE_ALIAS_NFCT_HELPER("netbios_ns");
 
 static unsigned int timeout __read_mostly = 3;
 module_param(timeout, uint, 0400);
net/netfilter/nf_conntrack_pptp.c +1 -0
index 1bc3001..9e169ef 100644
@@ -37,6 +37,7 @@ MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Harald Welte <[email protected]>");
 MODULE_DESCRIPTION("Netfilter connection tracking helper module for PPTP");
 MODULE_ALIAS("ip_conntrack_pptp");
+MODULE_ALIAS_NFCT_HELPER("pptp");
 
 static DEFINE_SPINLOCK(nf_pptp_lock);
 
net/netfilter/nf_conntrack_sane.c +1 -0
index a94294b..dcfecbb 100644
@@ -30,6 +30,7 @@
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Michal Schmidt <[email protected]>");
 MODULE_DESCRIPTION("SANE connection tracking helper");
+MODULE_ALIAS_NFCT_HELPER("sane");
 
 static char *sane_buffer;
 
net/netfilter/nf_conntrack_sip.c +1 -0
index 6813f1c..4b57216 100644
@@ -28,6 +28,7 @@ MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Christian Hentschel <[email protected]>");
 MODULE_DESCRIPTION("SIP connection tracking helper");
 MODULE_ALIAS("ip_conntrack_sip");
+MODULE_ALIAS_NFCT_HELPER("sip");
 
 #define MAX_PORTS	8
 static unsigned short ports[MAX_PORTS];
net/netfilter/nf_conntrack_tftp.c +1 -0
index f57f6e7..46e646b 100644
@@ -22,6 +22,7 @@ MODULE_AUTHOR("Magnus Boden <[email protected]>");
 MODULE_DESCRIPTION("TFTP connection tracking helper");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS("ip_conntrack_tftp");
+MODULE_ALIAS_NFCT_HELPER("tftp");
 
 #define MAX_PORTS 8
 static unsigned short ports[MAX_PORTS];
#27 lore raw

netfilter 16/29: ctnetlink: helper modules load-on-demand support

In reply to Patrick McHardy

commit 226c0c0ef2abdf91b8d9cce1aaf7d4635a5e5926

Author: Pablo Neira Ayuso <[email protected]>
Date:   Tue Nov 18 11:54:05 2008 +0100

netfilter: ctnetlink: helper modules load-on-demand support

This patch adds module loading for helpers via ctnetlink.

* Creation path: We support explicit and implicit helper assignation. For the explicit case, we try to load the module. If the module is correctly loaded and the helper is present, we return EAGAIN to re-start the creation. Otherwise, we return EOPNOTSUPP.
* Update path: release the spin lock, load the module and check. If it is present, then return EAGAIN to re-start the update.

This patch provides a refactorized function to lookup-and-set the connection tracking helper. The function removes the exported symbol __nf_ct_helper_find as it has not clients anymore.

include/net/netfilter/nf_conntrack_helper.h +2 -3
index f8060ab..66d65a7 100644
@@ -39,9 +39,6 @@ struct nf_conntrack_helper
 };
 
 extern struct nf_conntrack_helper *
-__nf_ct_helper_find(const struct nf_conntrack_tuple *tuple);
-
-extern struct nf_conntrack_helper *
 __nf_conntrack_helper_find_byname(const char *name);
 
 extern int nf_conntrack_helper_register(struct nf_conntrack_helper *);
@@ -49,6 +46,8 @@ extern void nf_conntrack_helper_unregister(struct nf_conntrack_helper *);
 
 extern struct nf_conn_help *nf_ct_helper_ext_add(struct nf_conn *ct, gfp_t gfp);
 
+extern int __nf_ct_try_assign_helper(struct nf_conn *ct, gfp_t flags);
+
 static inline struct nf_conn_help *nfct_help(const struct nf_conn *ct)
 {
 	return nf_ct_ext_find(ct, NF_CT_EXT_HELPER);
net/netfilter/nf_conntrack_core.c +2 -26
index 622d7c6..1e649fb 100644
@@ -588,14 +588,7 @@ init_conntrack(struct net *net,
 		nf_conntrack_get(&ct->master->ct_general);
 		NF_CT_STAT_INC(net, expect_new);
 	} else {
-		struct nf_conntrack_helper *helper;
-
-		helper = __nf_ct_helper_find(&repl_tuple);
-		if (helper) {
-			help = nf_ct_helper_ext_add(ct, GFP_ATOMIC);
-			if (help)
-				rcu_assign_pointer(help->helper, helper);
-		}
+		__nf_ct_try_assign_helper(ct, GFP_ATOMIC);
 		NF_CT_STAT_INC(net, new);
 	}
 
@@ -772,7 +765,6 @@ void nf_conntrack_alter_reply(struct nf_conn *ct,
 			      const struct nf_conntrack_tuple *newreply)
 {
 	struct nf_conn_help *help = nfct_help(ct);
-	struct nf_conntrack_helper *helper;
 
 	/* Should be unconfirmed, so not in hash table yet */
 	NF_CT_ASSERT(!nf_ct_is_confirmed(ct));
@@ -785,23 +777,7 @@ void nf_conntrack_alter_reply(struct nf_conn *ct,
 		return;
 
 	rcu_read_lock();
-	helper = __nf_ct_helper_find(newreply);
-	if (helper == NULL) {
-		if (help)
-			rcu_assign_pointer(help->helper, NULL);
-		goto out;
-	}
-
-	if (help == NULL) {
-		help = nf_ct_helper_ext_add(ct, GFP_ATOMIC);
-		if (help == NULL)
-			goto out;
-	} else {
-		memset(&help->help, 0, sizeof(help->help));
-	}
-
-	rcu_assign_pointer(help->helper, helper);
-out:
+	__nf_ct_try_assign_helper(ct, GFP_ATOMIC);
 	rcu_read_unlock();
 }
 EXPORT_SYMBOL_GPL(nf_conntrack_alter_reply);
net/netfilter/nf_conntrack_helper.c +30 -2
index 9c06b9f..9e4b74b 100644
@@ -44,7 +44,7 @@ static unsigned int helper_hash(const struct nf_conntrack_tuple *tuple)
 		(__force __u16)tuple->src.u.all) % nf_ct_helper_hsize;
 }
 
-struct nf_conntrack_helper *
+static struct nf_conntrack_helper *
 __nf_ct_helper_find(const struct nf_conntrack_tuple *tuple)
 {
 	struct nf_conntrack_helper *helper;
@@ -62,7 +62,6 @@ __nf_ct_helper_find(const struct nf_conntrack_tuple *tuple)
 	}
 	return NULL;
 }
-EXPORT_SYMBOL_GPL(__nf_ct_helper_find);
 
 struct nf_conntrack_helper *
 __nf_conntrack_helper_find_byname(const char *name)
@@ -94,6 +93,35 @@ struct nf_conn_help *nf_ct_helper_ext_add(struct nf_conn *ct, gfp_t gfp)
 }
 EXPORT_SYMBOL_GPL(nf_ct_helper_ext_add);
 
+int __nf_ct_try_assign_helper(struct nf_conn *ct, gfp_t flags)
+{
+	int ret = 0;
+	struct nf_conntrack_helper *helper;
+	struct nf_conn_help *help = nfct_help(ct);
+
+	helper = __nf_ct_helper_find(&ct->tuplehash[IP_CT_DIR_REPLY].tuple);
+	if (helper == NULL) {
+		if (help)
+			rcu_assign_pointer(help->helper, NULL);
+		goto out;
+	}
+
+	if (help == NULL) {
+		help = nf_ct_helper_ext_add(ct, flags);
+		if (help == NULL) {
+			ret = -ENOMEM;
+			goto out;
+		}
+	} else {
+		memset(&help->help, 0, sizeof(help->help));
+	}
+
+	rcu_assign_pointer(help->helper, helper);
+out:
+	return ret;
+}
+EXPORT_SYMBOL_GPL(__nf_ct_try_assign_helper);
+
 static inline int unhelp(struct nf_conntrack_tuple_hash *i,
 			 const struct nf_conntrack_helper *me)
 {
net/netfilter/nf_conntrack_netlink.c +61 -9

92 lines not on this page · raw message

#28 lore raw

netfilter 17/29: ctnetlink: deliver events for conntracks changed from userspace

In reply to Patrick McHardy

commit 19abb7b090a6bce88d4e9b2914a0367f4f684432

Author: Pablo Neira Ayuso <[email protected]>
Date:   Tue Nov 18 11:56:20 2008 +0100

netfilter: ctnetlink: deliver events for conntracks changed from userspace

As for now, the creation and update of conntracks via ctnetlink do not propagate an event to userspace. This can result in inconsistent situations if several userspace processes modify the connection tracking table by means of ctnetlink at the same time. Specifically, using the conntrack command line tool and conntrackd at the same time can trigger unconsistencies.

This patch also modifies the event cache infrastructure to pass the process PID and the ECHO flag to nfnetlink_send() to report back to userspace if the process that triggered the change needs so. Based on a suggestion from Patrick McHardy.

include/net/netfilter/nf_conntrack.h +1 -1
index f11255e..2e0c536 100644
@@ -199,7 +199,7 @@ __nf_conntrack_find(struct net *net, const struct nf_conntrack_tuple *tuple);
 
 extern void nf_conntrack_hash_insert(struct nf_conn *ct);
 
-extern void nf_conntrack_flush(struct net *net);
+extern void nf_conntrack_flush(struct net *net, u32 pid, int report);
 
 extern bool nf_ct_get_tuplepr(const struct sk_buff *skb,
 			      unsigned int nhoff, u_int16_t l3num,
include/net/netfilter/nf_conntrack_ecache.h +53 -4

90 lines not on this page · raw message

include/net/netfilter/nf_conntrack_expect.h +2 -0
index 37a7fc1..ab17a15 100644
@@ -100,6 +100,8 @@ void nf_ct_expect_init(struct nf_conntrack_expect *, unsigned int, u_int8_t,
 		       u_int8_t, const __be16 *, const __be16 *);
 void nf_ct_expect_put(struct nf_conntrack_expect *exp);
 int nf_ct_expect_related(struct nf_conntrack_expect *expect);
+int nf_ct_expect_related_report(struct nf_conntrack_expect *expect,
+				u32 pid, int report);
 
 #endif /*_NF_CONNTRACK_EXPECT_H*/
 
net/netfilter/nf_conntrack_core.c +21 -4
index 1e649fb..dc3fea0 100644
@@ -181,7 +181,8 @@ destroy_conntrack(struct nf_conntrack *nfct)
 	NF_CT_ASSERT(atomic_read(&nfct->use) == 0);
 	NF_CT_ASSERT(!timer_pending(&ct->timeout));
 
-	nf_conntrack_event(IPCT_DESTROY, ct);
+	if (!test_bit(IPS_DYING_BIT, &ct->status))
+		nf_conntrack_event(IPCT_DESTROY, ct);
 	set_bit(IPS_DYING_BIT, &ct->status);
 
 	/* To make sure we don't get any weird locking issues here:
@@ -972,8 +973,20 @@ void nf_ct_iterate_cleanup(struct net *net,
 }
 EXPORT_SYMBOL_GPL(nf_ct_iterate_cleanup);
 
+struct __nf_ct_flush_report {
+	u32 pid;
+	int report;
+};
+
 static int kill_all(struct nf_conn *i, void *data)
 {
+	struct __nf_ct_flush_report *fr = (struct __nf_ct_flush_report *)data;
+
+	/* get_next_corpse sets the dying bit for us */
+	nf_conntrack_event_report(IPCT_DESTROY,
+				  i,
+				  fr->pid,
+				  fr->report);
 	return 1;
 }
 
@@ -987,9 +1000,13 @@ void nf_ct_free_hashtable(struct hlist_head *hash, int vmalloced, unsigned int s
 }
 EXPORT_SYMBOL_GPL(nf_ct_free_hashtable);
 
-void nf_conntrack_flush(struct net *net)
+void nf_conntrack_flush(struct net *net, u32 pid, int report)
 {
-	nf_ct_iterate_cleanup(net, kill_all, NULL);
+	struct __nf_ct_flush_report fr = {
+		.pid 	= pid,
+		.report = report,
+	};
+	nf_ct_iterate_cleanup(net, kill_all, &fr);
 }
 EXPORT_SYMBOL_GPL(nf_conntrack_flush);
 
@@ -1005,7 +1022,7 @@ static void nf_conntrack_cleanup_net(struct net *net)
 	nf_ct_event_cache_flush(net);
 	nf_conntrack_ecache_fini(net);
  i_see_dead_people:
-	nf_conntrack_flush(net);
+	nf_conntrack_flush(net, 0, 0);
 	if (atomic_read(&net->ct.count) != 0) {
 		schedule();
 		goto i_see_dead_people;
net/netfilter/nf_conntrack_ecache.c +11 -3
index a5f5e2e..dee4190 100644
@@ -35,9 +35,17 @@ static inline void
 __nf_ct_deliver_cached_events(struct nf_conntrack_ecache *ecache)
 {
 	if (nf_ct_is_confirmed(ecache->ct) && !nf_ct_is_dying(ecache->ct)
-	    && ecache->events)
-		atomic_notifier_call_chain(&nf_conntrack_chain, ecache->events,
-				    ecache->ct);
+	    && ecache->events) {
+		struct nf_ct_event item = {
+			.ct 	= ecache->ct,
+			.pid	= 0,
+			.report	= 0
+		};
+
+		atomic_notifier_call_chain(&nf_conntrack_chain,
+					   ecache->events,
+					   &item);
+	}
 
 	ecache->events = 0;
 	nf_ct_put(ecache->ct);
net/netfilter/nf_conntrack_expect.c +36 -7

72 lines not on this page · raw message

net/netfilter/nf_conntrack_netlink.c +73 -15

191 lines not on this page · raw message

#29 lore raw

netfilter 18/29: nfnetlink_log: fix warning and prototype mismatch

In reply to Patrick McHardy

commit d9e150071d18b5c87ba7a097af4063a5ad0c6a0c

Author: Patrick McHardy <[email protected]>
Date:   Tue Nov 18 12:16:52 2008 +0100

netfilter: nfnetlink_log: fix warning and prototype mismatch

net/netfilter/nfnetlink_log.c:537:1: warning: symbol 'nfulnl_log_packet' was not declared. Should it be static?

Including the proper header also revealed an incorrect prototype.

include/net/netfilter/nfnetlink_log.h +1 -1
index 9b67f94..b0569ff 100644
@@ -2,7 +2,7 @@
 #define _KER_NFNETLINK_LOG_H
 
 void
-nfulnl_log_packet(unsigned int pf,
+nfulnl_log_packet(u_int8_t pf,
 		  unsigned int hooknum,
 		  const struct sk_buff *skb,
 		  const struct net_device *in,
net/netfilter/nfnetlink_log.c +1 -0
index a51892b..2770b4e 100644
@@ -30,6 +30,7 @@
 #include <linux/random.h>
 #include <net/sock.h>
 #include <net/netfilter/nf_log.h>
+#include <net/netfilter/nfnetlink_log.h>
 
 #include <asm/atomic.h>
 
#30 lore raw

netfilter 19/29: nf_conntrack: fix warning and prototype mismatch

In reply to Patrick McHardy

commit e17b666a468285409ab9f6caff9df16936d27d71

Author: Patrick McHardy <[email protected]>
Date:   Tue Nov 18 12:24:17 2008 +0100

netfilter: nf_conntrack: fix warning and prototype mismatch

net/netfilter/nf_conntrack_core.c:46:1: warning: symbol 'nfnetlink_parse_nat_setup_hook' was not declared. Should it be static?

Including the proper header also revealed an incorrect prototype.

net/netfilter/nf_conntrack_core.c +4 -4
index dc3fea0..73419de 100644
@@ -39,13 +39,13 @@
 #include <net/netfilter/nf_conntrack_extend.h>
 #include <net/netfilter/nf_conntrack_acct.h>
 #include <net/netfilter/nf_nat.h>
+#include <net/netfilter/nf_nat_core.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;
+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);
#31 lore raw

netfilter 20/29: xt_recent: don't save proc dirs

In reply to Patrick McHardy

commit b0ceb560a4119f187dc50da655be389cb54ae4f9

Author: Alexey Dobriyan <[email protected]>
Date:   Thu Nov 20 09:57:01 2008 +0100

netfilter: xt_recent: don't save proc dirs

Not needed, since creation and removal are done by name.

net/netfilter/xt_recent.c +11 -11
index 3c3dd22..fe80b61 100644
@@ -72,9 +72,6 @@ struct recent_entry {
 struct recent_table {
 	struct list_head	list;
 	char			name[XT_RECENT_NAME_LEN];
-#ifdef CONFIG_PROC_FS
-	struct proc_dir_entry	*proc_old, *proc;
-#endif
 	unsigned int		refcnt;
 	unsigned int		entries;
 	struct list_head	lru_list;
@@ -284,6 +281,9 @@ static bool recent_mt_check(const struct xt_mtchk_param *par)
 {
 	const struct xt_recent_mtinfo *info = par->matchinfo;
 	struct recent_table *t;
+#ifdef CONFIG_PROC_FS
+	struct proc_dir_entry *pde;
+#endif
 	unsigned i;
 	bool ret = false;
 
@@ -318,25 +318,25 @@ static bool recent_mt_check(const struct xt_mtchk_param *par)
 	for (i = 0; i < ip_list_hash_size; i++)
 		INIT_LIST_HEAD(&t->iphash[i]);
 #ifdef CONFIG_PROC_FS
-	t->proc = proc_create_data(t->name, ip_list_perms, recent_proc_dir,
+	pde = proc_create_data(t->name, ip_list_perms, recent_proc_dir,
 		  &recent_mt_fops, t);
-	if (t->proc == NULL) {
+	if (pde == NULL) {
 		kfree(t);
 		goto out;
 	}
+	pde->uid = ip_list_uid;
+	pde->gid = ip_list_gid;
 #ifdef CONFIG_NETFILTER_XT_MATCH_RECENT_PROC_COMPAT
-	t->proc_old = proc_create_data(t->name, ip_list_perms, proc_old_dir,
+	pde = proc_create_data(t->name, ip_list_perms, proc_old_dir,
 		      &recent_old_fops, t);
-	if (t->proc_old == NULL) {
+	if (pde == NULL) {
 		remove_proc_entry(t->name, proc_old_dir);
 		kfree(t);
 		goto out;
 	}
-	t->proc_old->uid   = ip_list_uid;
-	t->proc_old->gid   = ip_list_gid;
+	pde->uid = ip_list_uid;
+	pde->gid = ip_list_gid;
 #endif
-	t->proc->uid       = ip_list_uid;
-	t->proc->gid       = ip_list_gid;
 #endif
 	spin_lock_bh(&recent_lock);
 	list_add_tail(&t->list, &tables);
#32 lore raw

netfilter 21/29: ip6table_filter: merge LOCAL_IN and FORWARD hooks

In reply to Patrick McHardy

commit 61d3015808d877eb4ea225b5924feb128b0c1bc7

Author: Alexey Dobriyan <[email protected]>
Date:   Thu Nov 20 09:58:08 2008 +0100

netfilter: ip6table_filter: merge LOCAL_IN and FORWARD hooks

net/ipv6/netfilter/ip6table_filter.c +3 -14
index b110a8a..40d2e36 100644
@@ -61,7 +61,7 @@ static struct xt_table packet_filter = {
 
 /* The work comes in here from netfilter.c. */
 static unsigned int
-ip6t_local_in_hook(unsigned int hook,
+ip6t_in_hook(unsigned int hook,
 		   struct sk_buff *skb,
 		   const struct net_device *in,
 		   const struct net_device *out,
@@ -72,17 +72,6 @@ ip6t_local_in_hook(unsigned int hook,
 }
 
 static unsigned int
-ip6t_forward_hook(unsigned int hook,
-		  struct sk_buff *skb,
-		  const struct net_device *in,
-		  const struct net_device *out,
-		  int (*okfn)(struct sk_buff *))
-{
-	return ip6t_do_table(skb, hook, in, out,
-			     dev_net(in)->ipv6.ip6table_filter);
-}
-
-static unsigned int
 ip6t_local_out_hook(unsigned int hook,
 		   struct sk_buff *skb,
 		   const struct net_device *in,
@@ -105,14 +94,14 @@ ip6t_local_out_hook(unsigned int hook,
 
 static struct nf_hook_ops ip6t_ops[] __read_mostly = {
 	{
-		.hook		= ip6t_local_in_hook,
+		.hook		= ip6t_in_hook,
 		.owner		= THIS_MODULE,
 		.pf		= PF_INET6,
 		.hooknum	= NF_INET_LOCAL_IN,
 		.priority	= NF_IP6_PRI_FILTER,
 	},
 	{
-		.hook		= ip6t_forward_hook,
+		.hook		= ip6t_in_hook,
 		.owner		= THIS_MODULE,
 		.pf		= PF_INET6,
 		.hooknum	= NF_INET_FORWARD,
#33 lore raw

netfilter 22/29: nf_conntrack_proto_gre: spread __exit

In reply to Patrick McHardy

commit 56bc0f9603e45cf13db51e554e1541e289a7f8e9

Author: Alexey Dobriyan <[email protected]>
Date:   Thu Nov 20 10:01:37 2008 +0100

netfilter: nf_conntrack_proto_gre: spread __exit

net/netfilter/nf_conntrack_proto_gre.c +1 -1
index 4ab62ad..1b279f9 100644
@@ -341,7 +341,7 @@ static int __init nf_ct_proto_gre_init(void)
 	return rv;
 }
 
-static void nf_ct_proto_gre_fini(void)
+static void __exit nf_ct_proto_gre_fini(void)
 {
 	nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_gre4);
 	unregister_pernet_gen_subsys(proto_gre_net_id, &proto_gre_net_ops);
#34 lore raw

netfilter 23/29: ip{,6}t_policy.h should include xp_policy.h

In reply to Patrick McHardy

commit 018a7bf1e55000dd792194238c9043918d24d3dd

Author: Andy Whitcroft <[email protected]>
Date:   Thu Nov 20 15:59:56 2008 +0100

netfilter: ip{,6}t_policy.h should include xp_policy.h

It seems that all of the include/netfilter_{ipv4,ipv6}/{ipt,ip6t}_*.h which share constants include the corresponding include/netfilter/xp_*.h files. Neither ipt_policy.h not ip6t_policy.h do. Make these consistant with the norm.

include/linux/netfilter_ipv4/ipt_policy.h +2 -0
index b9478a2..1037fb2 100644
@@ -1,6 +1,8 @@
 #ifndef _IPT_POLICY_H
 #define _IPT_POLICY_H
 
+#include <linux/netfilter/xt_policy.h>
+
 #define IPT_POLICY_MAX_ELEM		XT_POLICY_MAX_ELEM
 
 /* ipt_policy_flags */
include/linux/netfilter_ipv6/ip6t_policy.h +2 -0
index 6bab316..b1c449d 100644
@@ -1,6 +1,8 @@
 #ifndef _IP6T_POLICY_H
 #define _IP6T_POLICY_H
 
+#include <linux/netfilter/xt_policy.h>
+
 #define IP6T_POLICY_MAX_ELEM		XT_POLICY_MAX_ELEM
 
 /* ip6t_policy_flags */
#38 lore raw

netfilter 24/29: nf_conntrack_proto_sctp: avoid bogus warning

In reply to Patrick McHardy

commit 328bd8997dbb7184d5389e45c642af44ae6e9043

Author: Patrick McHardy <[email protected]>
Date:   Mon Nov 24 13:44:55 2008 +0100

netfilter: nf_conntrack_proto_sctp: avoid bogus warning

net/netfilter/nf_conntrack_proto_sctp.c: In function 'sctp_packet':
net/netfilter/nf_conntrack_proto_sctp.c:376: warning: array subscript is above array bounds

gcc doesn't realize that do_basic_checks() guarantees that there is at least one valid chunk and thus new_state is never SCTP_CONNTRACK_MAX after the loop. Initialize to SCTP_CONNTRACK_NONE to avoid the warning.

Based on patch by Wu Fengguang <[email protected]>

net/netfilter/nf_conntrack_proto_sctp.c +1 -1
index c2bd457..74e0379 100644
@@ -317,7 +317,7 @@ static int sctp_packet(struct nf_conn *ct,
 		goto out;
 	}
 
-	old_state = new_state = SCTP_CONNTRACK_MAX;
+	old_state = new_state = SCTP_CONNTRACK_NONE;
 	write_lock_bh(&sctp_lock);
 	for_each_sctp_chunk (skb, sch, _sch, offset, dataoff, count) {
 		/* Special cases of Verification tag check (Sec 8.5.1) */
#39 lore raw

netfilter 25/29: nf_conntrack_ftp: change "partial ..." message to pr_debug()

In reply to Patrick McHardy

commit 4813eadf6b17caa7fcce67ac2f929a3dd5178fa2

Author: Patrick McHardy <[email protected]>
Date:   Mon Nov 24 18:34:48 2008 +0100

netfilter: nf_conntrack_ftp: change "partial ..." message to pr_debug()

The message triggers when sending non-FTP data on port 21 or with certain clients that use multiple syscalls to send the command.

Change to pr_debug() since users have been complaining.

net/netfilter/nf_conntrack_ftp.c +2 -4
index 703a437..867cad6 100644
@@ -428,10 +428,8 @@ static int help(struct sk_buff *skb,
 		   connection tracking, not packet filtering.
 		   However, it is necessary for accurate tracking in
 		   this case. */
-		if (net_ratelimit())
-			printk("conntrack_ftp: partial %s %u+%u\n",
-			       search[dir][i].pattern,
-			       ntohl(th->seq), datalen);
+		pr_debug("conntrack_ftp: partial %s %u+%u\n",
+			 search[dir][i].pattern,  ntohl(th->seq), datalen);
 		ret = NF_DROP;
 		goto out;
 	} else if (found == 0) { /* No match */
#40 lore raw

netfilter 26/29: nfmark routing in OUTPUT, mangle, NFQUEUE

In reply to Patrick McHardy

commit 5f145e44ae09f629d25536b2947a91e9c01bddcb

Author: Eric Leblond <[email protected]>
Date:   Tue Nov 25 12:15:16 2008 +0100

netfilter: nfmark routing in OUTPUT, mangle, NFQUEUE

This patch let nfmark to be evaluated for routing decision for OUTPUT packet, in mangle table, when process paquet in NFQUEUE Until now, only change (in NFQUEUE process) on fields src_addr, dest_addr and tos could make netfilter to reevalute the routing.

From: Laurent Licour <[email protected]>

net/ipv4/netfilter.c +3 -0
index 6efdb70..7c145d7 100644
@@ -125,6 +125,7 @@ struct ip_rt_info {
 	__be32 daddr;
 	__be32 saddr;
 	u_int8_t tos;
+	u_int32_t mark;
 };
 
 static void nf_ip_saveroute(const struct sk_buff *skb,
@@ -138,6 +139,7 @@ static void nf_ip_saveroute(const struct sk_buff *skb,
 		rt_info->tos = iph->tos;
 		rt_info->daddr = iph->daddr;
 		rt_info->saddr = iph->saddr;
+		rt_info->mark = skb->mark;
 	}
 }
 
@@ -150,6 +152,7 @@ static int nf_ip_reroute(struct sk_buff *skb,
 		const struct iphdr *iph = ip_hdr(skb);
 
 		if (!(iph->tos == rt_info->tos
+		      && skb->mark == rt_info->mark
 		      && iph->daddr == rt_info->daddr
 		      && iph->saddr == rt_info->saddr))
 			return ip_route_me_harder(skb, RTN_UNSPEC);
#41 lore raw

netfilter 27/29: nfmark IPV6 routing in OUTPUT, mangle, NFQUEUE

In reply to Patrick McHardy

commit 9f40ac713c49fb6ca655550b620edc85c445d743

Author: Eric Leblond <[email protected]>
Date:   Tue Nov 25 12:18:11 2008 +0100

netfilter: nfmark IPV6 routing in OUTPUT, mangle, NFQUEUE

This patch let nfmark to be evaluated for routing decision for OUTPUT packet, in mangle table, when process paquet in NFQUEUE. This patch is an IPv6 port of Laurent Licour IPv4 one.

net/ipv6/netfilter.c +4 -1
index fd5b3a4..0b88c56 100644
@@ -56,6 +56,7 @@ EXPORT_SYMBOL(ip6_route_me_harder);
 struct ip6_rt_info {
 	struct in6_addr daddr;
 	struct in6_addr saddr;
+	u_int32_t mark;
 };
 
 static void nf_ip6_saveroute(const struct sk_buff *skb,
@@ -68,6 +69,7 @@ static void nf_ip6_saveroute(const struct sk_buff *skb,
 
 		rt_info->daddr = iph->daddr;
 		rt_info->saddr = iph->saddr;
+		rt_info->mark = skb->mark;
 	}
 }
 
@@ -79,7 +81,8 @@ static int nf_ip6_reroute(struct sk_buff *skb,
 	if (entry->hook == NF_INET_LOCAL_OUT) {
 		struct ipv6hdr *iph = ipv6_hdr(skb);
 		if (!ipv6_addr_equal(&iph->daddr, &rt_info->daddr) ||
-		    !ipv6_addr_equal(&iph->saddr, &rt_info->saddr))
+		    !ipv6_addr_equal(&iph->saddr, &rt_info->saddr) ||
+		    skb->mark != rt_info->mark)
 			return ip6_route_me_harder(skb);
 	}
 	return 0;
#42 lore raw

netfilter 28/29: fix warning in net/netfilter/nf_conntrack_proto_tcp.c

In reply to Patrick McHardy

commit 65f233fb1669e6c990cd1d7fd308ac7dc66dc207

Author: Ingo Molnar <[email protected]>
Date:   Tue Nov 25 18:20:13 2008 +0100

netfilter: fix warning in net/netfilter/nf_conntrack_proto_tcp.c

fix this warning:

net/netfilter/nf_conntrack_proto_tcp.c: In function \u2018tcp_in_window\u2019:
net/netfilter/nf_conntrack_proto_tcp.c:491: warning: unused variable \u2018net\u2019 net/netfilter/nf_conntrack_proto_tcp.c: In function \u2018tcp_packet\u2019:
net/netfilter/nf_conntrack_proto_tcp.c:812: warning: unused variable \u2018net\u2019

include/net/netfilter/nf_conntrack_l4proto.h +1 -1
index 7f2f43c..debdaf7 100644
@@ -129,7 +129,7 @@ extern const struct nla_policy nf_ct_port_nla_policy[];
 	 && net_ratelimit())
 #endif
 #else
-#define LOG_INVALID(net, proto) 0
+static inline int LOG_INVALID(struct net *net, int proto) { return 0; }
 #endif /* CONFIG_SYSCTL */
 
 #endif /*_NF_CONNTRACK_PROTOCOL_H*/
#43 lore raw

netfilter 29/29: fix warning in net/netfilter/nf_conntrack_ftp.c

In reply to Patrick McHardy

commit d6e8cc6cc7ac77b0f9118f78c453a2e834e62709

Author: Ingo Molnar <[email protected]>
Date:   Tue Nov 25 18:23:03 2008 +0100

netfilter: fix warning in net/netfilter/nf_conntrack_ftp.c

this warning:

net/netfilter/nf_conntrack_ftp.c: In function 'help':
net/netfilter/nf_conntrack_ftp.c:360: warning: 'matchoff' may be used uninitialized in this function net/netfilter/nf_conntrack_ftp.c:360: warning: 'matchlen' may be used uninitialized in this function

triggers because GCC does not recognize the (correct) error flow between find_pattern(), 'found', 'matchoff' and 'matchlen'.

Annotate it.

net/netfilter/nf_conntrack_ftp.c +1 -1
index 867cad6..00fecc3 100644
@@ -358,7 +358,7 @@ static int help(struct sk_buff *skb,
 	int ret;
 	u32 seq;
 	int dir = CTINFO2DIR(ctinfo);
-	unsigned int matchlen, matchoff;
+	unsigned int uninitialized_var(matchlen), uninitialized_var(matchoff);
 	struct nf_ct_ftp_master *ct_ftp_info = &nfct_help(ct)->help.ct_ftp_info;
 	struct nf_conntrack_expect *exp;
 	union nf_inet_addr *daddr;
#44 lore raw
In reply to Patrick McHardy
Quoted 4 lines · Patrick McHardy

There's a trivial merge conflict in net/netfilter/nf_conntrack_netlink.c, so the patches won't apply directly. Please pull from

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

And for reference, this is what I did to resolve the conflict:

commit dbfaaa37cdfb579e317e2498eb2fc634be178761
Merge: 5b9ab2e... d6e8cc6...
Author: Patrick McHardy <[email protected]>
Date: Thu Nov 27 16:28:34 2008 +0100

Merge branch 'master' of /home/kaber/src/nf/nf-next-2.6

Conflicts:

net/netfilter/nf_conntrack_netlink.c

net/netfilter/nf_conntrack_netlink.c +0 -0
diff --cc net/netfilter/nf_conntrack_netlink.c
index 5f4a651,ccc5ef1..a0c9bc4
@@@ -1087,10 -1131,9 +1131,9 @@@ ctnetlink_create_conntrack(struct nlatt
  {
  	struct nf_conn *ct;
  	int err = -EINVAL;
- 	struct nf_conn_help *help;
  	struct nf_conntrack_helper *helper;
  
 -	ct = nf_conntrack_alloc(&init_net, otuple, rtuple, GFP_KERNEL);
 +	ct = nf_conntrack_alloc(&init_net, otuple, rtuple, GFP_ATOMIC);
  	if (ct == NULL || IS_ERR(ct))
  		return -ENOMEM;
  
@@@ -1209,17 -1294,18 +1294,19 @@@ ctnetlink_new_conntrack(struct sock *ct
  				goto out_unlock;
  			}
  			master_ct = nf_ct_tuplehash_to_ctrack(master_h);
- 			atomic_inc(&master_ct->ct_general.use);
+ 			nf_conntrack_get(&master_ct->ct_general);
  		}
  
 -		spin_unlock_bh(&nf_conntrack_lock);
  		err = -ENOENT;
  		if (nlh->nlmsg_flags & NLM_F_CREATE)
  			err = ctnetlink_create_conntrack(cda,
  							 &otuple,
  							 &rtuple,
- 							 master_ct);
+ 							 master_ct,
+ 							 NETLINK_CB(skb).pid,
+ 							 nlmsg_report(nlh));
 +		spin_unlock_bh(&nf_conntrack_lock);
 +
  		if (err < 0 && master_ct)
  			nf_ct_put(master_ct);
  
#8 lore raw

Re: netfilter 07/29: netns ebtables: ebtable_broute in netns

In reply to Patrick McHardy
Quoted 14 lines · Patrick McHardy

commit 8157e6d16af86e4a8d31a035db7be02a8a171c26

Author: Alexey Dobriyan <[email protected]>
Date:   Tue Nov 4 14:29:03 2008 +0100

netfilter: netns ebtables: ebtable_broute in netns

include/net/netns/x_tables.h +0 -0
index b809397..055e684 100644

include/net/netns/x_tables.h line 13

Quoted 10 lines
include/net/netns/x_tables.h +3 -0
@@ -4,7 +4,10 @@
 #include <linux/list.h>
 #include <linux/netfilter.h>
 
+struct ebt_table;
+
 struct netns_xt {
 	struct list_head tables[NFPROTO_NUMPROTO];
+	struct ebt_table *broute_table;
 };
 #endif

Where are the other tables from ip and ip6? Wait, I think... the ebtables definitions should go to ebtables.h, just like the ip/ip6 ones went to [not x_tables.h].

#9 lore raw

Re: netfilter 07/29: netns ebtables: ebtable_broute in netns

[CCed Alexey]

Quoted 30 lines · Jan Engelhardt
Quoted 14 lines · Patrick McHardy

commit 8157e6d16af86e4a8d31a035db7be02a8a171c26

Author: Alexey Dobriyan <[email protected]>
Date:   Tue Nov 4 14:29:03 2008 +0100

netfilter: netns ebtables: ebtable_broute in netns

include/net/netns/x_tables.h +0 -0
index b809397..055e684 100644

include/net/netns/x_tables.h line 13

Quoted 10 lines
include/net/netns/x_tables.h +3 -0
@@ -4,7 +4,10 @@
 #include <linux/list.h>
 #include <linux/netfilter.h>
 
+struct ebt_table;
+
 struct netns_xt {
 	struct list_head tables[NFPROTO_NUMPROTO];
+	struct ebt_table *broute_table;
 };
 #endif

Where are the other tables from ip and ip6? Wait, I think... the ebtables definitions should go to ebtables.h, just like the ip/ip6 ones went to [not x_tables.h].

#15 lore raw

Re: netfilter 11/29: nf_nat: remove warn_if_extra_mangle

In reply to Patrick McHardy
Quoted 11 lines · Patrick McHardy

netfilter: nf_nat: remove warn_if_extra_mangle

In net/ipv4/netfilter/nf_nat_rule.c, the function warn_if_extra_mangle was added in commit 5b1158e909ecbe1a052203e0d8df15633f829930 (2006-12-02). I have a DNAT target in the OUTPUT chain than changes connections with dst 2.0.0.1 to another address which I'll substitute with 66.102.9.99 below.

On every boot I get the following message:

   [  146.252505] NAT: no longer support implicit source local NAT
   [  146.252517] NAT: packet src 66.102.9.99 -> dst 2.0.0.1
Quoted 7 lines

As far as I can tell from reading the function doing this, it should warn if the source IP for the route to 66.102.9.99 is different from 2.0.0.1 but that is not the case. It doesn't make sense to check the DNAT target against the local route source.

Either the function should be changed to correctly check the route, or it should be removed entirely as it's been nearly 2 years since it was added.

Why did implicit local SNAT even go? It was kind of a neat way to be able to issue socat - tcp-client:localhost:1234 and have it redirected elsewhere on the net.

#20 lore raw

Re: netfilter 15/29: nf_conntrack: connection tracking helper name persistent aliases

In reply to Patrick McHardy
Quoted 4 lines · Patrick McHardy

This patch adds the macro MODULE_ALIAS_NFCT_HELPER that defines a way to provide generic and persistent aliases for the connection tracking helpers.

I wonder a bit. iptables is fine with loading ipt_%s (mapped to xt_%s), but conntrack requires an nfct-help-%s namespace and cannot use nf_conntrack_%s?
Of course it makes sense to use a separate namespace - especially in light of the nf_conntrack_ prefix used by both helpers and protos, but I'm still asking.

#21 lore raw

Re: netfilter 15/29: nf_conntrack: connection tracking helper name persistent aliases

Quoted 6 lines · Jan Engelhardt
Quoted 4 lines · Patrick McHardy

This patch adds the macro MODULE_ALIAS_NFCT_HELPER that defines a way to provide generic and persistent aliases for the connection tracking helpers.

Quoted 7 lines

I wonder a bit. iptables is fine with loading ipt_%s (mapped to xt_%s), but conntrack requires an nfct-help-%s namespace and cannot use nf_conntrack_%s?
Of course it makes sense to use a separate namespace - especially in light of the nf_conntrack_ prefix used by both helpers and protos, but I'm still asking.

Please CC the people that can actually answer this question.

#35 lore raw

Re: netfilter 23/29: ip{,6}t_policy.h should include xp_policy.h

In reply to Patrick McHardy
Quoted 5 lines · Patrick McHardy

commit 018a7bf1e55000dd792194238c9043918d24d3dd

Author: Andy Whitcroft <[email protected]>
Date:   Thu Nov 20 15:59:56 2008 +0100

netfilter: ip{,6}t_policy.h should include xp_policy.h

Still trying to fix Bug #1? It's xt_policy, not XP ;-)

#22 lore raw

Re: netfilter 15/29: nf_conntrack: connection tracking helper name persistent aliases

In reply to Patrick McHardy

[cc morphed to more interested parties]

Quoted 15 lines · Patrick McHardy
Quoted 6 lines · Jan Engelhardt
Quoted 4 lines · Patrick McHardy

This patch adds the macro MODULE_ALIAS_NFCT_HELPER that defines a way to provide generic and persistent aliases for the connection tracking helpers.

Quoted 7 lines

I wonder a bit. iptables is fine with loading ipt_%s (mapped to xt_%s), but conntrack requires an nfct-help-%s namespace and cannot use nf_conntrack_%s?
Of course it makes sense to use a separate namespace - especially in light of the nf_conntrack_ prefix used by both helpers and protos, but I'm still asking.

Quoted 2 lines

Please CC the people that can actually answer this question.

Please set CC when running git-send-email :)

#23 lore raw

Re: netfilter 15/29: nf_conntrack: connection tracking helper name persistent aliases

Quoted 16 lines · Jan Engelhardt

[cc morphed to more interested parties]

Quoted 12 lines · Patrick McHardy
Quoted 11 lines · Jan Engelhardt
Quoted 4 lines · Patrick McHardy

This patch adds the macro MODULE_ALIAS_NFCT_HELPER that defines a way to provide generic and persistent aliases for the connection tracking helpers.

I wonder a bit. iptables is fine with loading ipt_%s (mapped to xt_%s), but conntrack requires an nfct-help-%s namespace and cannot use nf_conntrack_%s?
Of course it makes sense to use a separate namespace - especially in light of the nf_conntrack_ prefix used by both helpers and protos, but I'm still asking.

It is not the same point. The xt_* aliases in iptables were introduced to keep backward compatibility for iptables (old versions try to load ipt_* or ip6t_* modules, as they don't know anything about xt_*. Of course, this is no longer true for current iptables versions).

The reason why I introduced the nfct-help aliases is to avoid a change in every request_module() invocation if we ever rename the helper files to something like nf_conntrack_helper_*.c or whatever. If that happens at some point, we will only have to change the MODULE_ALIAS_NFCT_HELPER macro to point to the new name-space. This looks much cleaner to me.

Quoted 3 lines
Quoted 2 lines

Please CC the people that can actually answer this question.

Please set CC when running git-send-email :)

Burp!

Signature · 1 line
"Los honestos son inadaptados sociales" -- Les Luthiers
#24 lore raw

Re: netfilter 15/29: nf_conntrack: connection tracking helper name persistent aliases

Quoted 11 lines · Pablo Neira Ayuso
Quoted 6 lines

I wonder a bit. iptables is fine with loading ipt_%s (mapped to xt_%s), but conntrack requires an nfct-help-%s namespace and cannot use nf_conntrack_%s?
Of course it makes sense to use a separate namespace - especially in light of the nf_conntrack_ prefix used by both helpers and protos, but I'm still asking.

It is not the same point. The xt_* aliases in iptables were introduced to keep backward compatibility for iptables (old versions try to load ipt_* or ip6t_* modules, as they don't know anything about xt_*. Of course, this is no longer true for current iptables versions).

Sadly enough, iptables still loads ipt_%s instead of xt_%s. Maybe it's time for a patch..

#25 lore raw

Re: netfilter 15/29: nf_conntrack: connection tracking helper name persistent aliases

In reply to Jan Engelhardt
Quoted 7 lines · Jan Engelhardt
Quoted 6 lines · Pablo Neira Ayuso
Quoted 6 lines

I wonder a bit. iptables is fine with loading ipt_%s (mapped to xt_%s), but conntrack requires an nfct-help-%s namespace and cannot use nf_conntrack_%s?
Of course it makes sense to use a separate namespace - especially in light of the nf_conntrack_ prefix used by both helpers and protos, but I'm still asking.

Quoted 7 lines
Quoted 4 lines

It is not the same point. The xt_* aliases in iptables were introduced to keep backward compatibility for iptables (old versions try to load ipt_* or ip6t_* modules, as they don't know anything about xt_*. Of course, this is no longer true for current iptables versions).

Sadly enough, iptables still loads ipt_%s instead of xt_%s. Maybe it's time for a patch..

Its needed to select the proper module, f.i. in case of REJECT.

#10 lore raw

Re: netfilter 07/29: netns ebtables: ebtable_broute in netns

In reply to Patrick McHardy
Quoted 32 lines · Patrick McHardy

[CCed Alexey]

Quoted 29 lines · Jan Engelhardt
Quoted 13 lines · Patrick McHardy

commit 8157e6d16af86e4a8d31a035db7be02a8a171c26

Author: Alexey Dobriyan <[email protected]>
Date:   Tue Nov 4 14:29:03 2008 +0100

netfilter: netns ebtables: ebtable_broute in netns

include/net/netns/x_tables.h +0 -0
index b809397..055e684 100644

include/net/netns/x_tables.h line 13

Quoted 10 lines
include/net/netns/x_tables.h +3 -0
@@ -4,7 +4,10 @@
 #include <linux/list.h>
 #include <linux/netfilter.h>
 
+struct ebt_table;
+
 struct netns_xt {
 	struct list_head tables[NFPROTO_NUMPROTO];
+	struct ebt_table *broute_table;
 };
 #endif

Where are the other tables from ip and ip6? Wait, I think... the ebtables definitions should go to ebtables.h, just like the ip/ip6 ones went to [not x_tables.h].

I haven't bothered with new file for 3 pointers.

When net.bridge.* sysctls will be made per-netns, definitely.

#37 lore raw

Re: netfilter 23/29: ip{,6}t_policy.h should include xp_policy.h

In reply to Jan Engelhardt
Quoted 10 lines · Jan Engelhardt
Quoted 5 lines · Patrick McHardy

commit 018a7bf1e55000dd792194238c9043918d24d3dd

Author: Andy Whitcroft <[email protected]>
Date:   Thu Nov 20 15:59:56 2008 +0100

netfilter: ip{,6}t_policy.h should include xp_policy.h

Still trying to fix Bug #1? It's xt_policy, not XP ;-)

Heh, sorry seems my dyslexia strikes again. The patch itself of course is sane just the write up. If you want me to respin let me know.

-apw

maintainer
#45 lore raw
In reply to Patrick McHardy

From: Patrick McHardy <[email protected]>
Date: Thu, 27 Nov 2008 17:15:03 +0100 (MET)

Quoted 14 lines

the following patches contain part 1 of the netfilter updates for 2.6.29. The highlights are:

- netns support for ebtables, ipt_addrtype and some related cleanups from Alexey Dobriyan

- ctnetlink updates from Pablo: automatic helper module loading, proper event generation for actions performed through ctnetlink, minor cleanups

- switching of xt_NFLOG to directly use nfnetlink_log as backend instead of the first loaded logging module, which was a constant source of confusion for users. From Eric Leblond. Also from Eric are two patches to support rerouting based on packet marks in nfnetlink_queue.

Quoted 8 lines

- Misc cleanups and minor fixes from myself, Andy Whitcroft, Simon Arlot and Ingo Molnar.

There's a trivial merge conflict in net/netfilter/nf_conntrack_netlink.c, so the patches won't apply directly. Please pull from

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

Pulled and pushed out to net-next-2.6, thanks Patrick!

#26 lore raw

Re: netfilter 15/29: nf_conntrack: connection tracking helper name persistent aliases

In reply to Patrick McHardy
Quoted 13 lines · Patrick McHardy
Quoted 12 lines · Jan Engelhardt
Quoted 10 lines · Pablo Neira Ayuso
Quoted 6 lines

I wonder a bit. iptables is fine with loading ipt_%s (mapped to xt_%s), but conntrack requires an nfct-help-%s namespace and cannot use nf_conntrack_%s?
Of course it makes sense to use a separate namespace - especially in light of the nf_conntrack_ prefix used by both helpers and protos, but I'm still asking.

It is not the same point. The xt_* aliases in iptables were introduced to keep backward compatibility for iptables (old versions try to load ipt_* or ip6t_* modules, as they don't know anything about xt_*. Of course, this is no longer true for current iptables versions).

Quoted 5 lines
Quoted 2 lines

Sadly enough, iptables still loads ipt_%s instead of xt_%s. Maybe it's time for a patch..

Its needed to select the proper module, f.i. in case of REJECT.

Yeah I figured that much. How about doing the same as MODULE_ALIAS_NFCT_HELPER?

#define MODULE_ALIAS_NFXT(name, nfproto) \
	MODULE_ALIAS("nfxt-" name "-" __stringify(nfproto))