netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* netfilter 00/29: Netfilter Update
@ 2008-11-27 16:15 Patrick McHardy
  2008-11-27 16:15 ` netfilter 01/29: xt_NFLOG: don't call nf_log_packet in NFLOG module Patrick McHardy
                   ` (30 more replies)
  0 siblings, 31 replies; 46+ messages in thread
From: Patrick McHardy @ 2008-11-27 16:15 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy, netfilter-devel

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

^ permalink raw reply	[flat|nested] 46+ messages in thread

* netfilter 01/29: xt_NFLOG: don't call nf_log_packet in NFLOG module.
  2008-11-27 16:15 netfilter 00/29: Netfilter Update Patrick McHardy
@ 2008-11-27 16:15 ` Patrick McHardy
  2008-11-27 16:15 ` netfilter 02/29: netns-aware ipt_addrtype Patrick McHardy
                   ` (29 subsequent siblings)
  30 siblings, 0 replies; 46+ messages in thread
From: Patrick McHardy @ 2008-11-27 16:15 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy, netfilter-devel

commit 5f7340eff8f68f41b7e5c7ad47ec4cd1ea1afb40
Author: Eric Leblond <eric@inl.fr>
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.
    
    Signed-off-by: Eric Leblond <eric@inl.fr>
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/include/net/netfilter/nfnetlink_log.h b/include/net/netfilter/nfnetlink_log.h
new file mode 100644
index 0000000..9b67f94
--- /dev/null
+++ b/include/net/netfilter/nfnetlink_log.h
@@ -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 */
+
diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
index 41e0105..a51892b 100644
--- a/net/netfilter/nfnetlink_log.c
+++ b/net/netfilter/nfnetlink_log.c
@@ -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,
diff --git a/net/netfilter/xt_NFLOG.c b/net/netfilter/xt_NFLOG.c
index 50e3a52..a57c5cf 100644
--- a/net/netfilter/xt_NFLOG.c
+++ b/net/netfilter/xt_NFLOG.c
@@ -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 <kaber@trash.net>");
 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;
 }
 

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* netfilter 02/29: netns-aware ipt_addrtype
  2008-11-27 16:15 netfilter 00/29: Netfilter Update Patrick McHardy
  2008-11-27 16:15 ` netfilter 01/29: xt_NFLOG: don't call nf_log_packet in NFLOG module Patrick McHardy
@ 2008-11-27 16:15 ` Patrick McHardy
  2008-11-27 16:15 ` netfilter 03/29: arptable_filter: merge forward hook Patrick McHardy
                   ` (28 subsequent siblings)
  30 siblings, 0 replies; 46+ messages in thread
From: Patrick McHardy @ 2008-11-27 16:15 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy, netfilter-devel

commit d4ec52bae739409b2372fea30dba0e7a8d6b9181
Author: Alexey Dobriyan <adobriyan@gmail.com>
Date:   Tue Nov 4 14:21:48 2008 +0100

    netfilter: netns-aware ipt_addrtype
    
    Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/net/ipv4/netfilter/ipt_addrtype.c b/net/ipv4/netfilter/ipt_addrtype.c
index 88762f0..3b216be 100644
--- a/net/ipv4/netfilter/ipt_addrtype.c
+++ b/net/ipv4/netfilter/ipt_addrtype.c
@@ -23,24 +23,25 @@ MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
 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;
 }

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* netfilter 03/29: arptable_filter: merge forward hook
  2008-11-27 16:15 netfilter 00/29: Netfilter Update Patrick McHardy
  2008-11-27 16:15 ` netfilter 01/29: xt_NFLOG: don't call nf_log_packet in NFLOG module Patrick McHardy
  2008-11-27 16:15 ` netfilter 02/29: netns-aware ipt_addrtype Patrick McHardy
@ 2008-11-27 16:15 ` Patrick McHardy
  2008-11-27 16:15 ` netfilter 04/29: netns ebtables: part 1 Patrick McHardy
                   ` (27 subsequent siblings)
  30 siblings, 0 replies; 46+ messages in thread
From: Patrick McHardy @ 2008-11-27 16:15 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy, netfilter-devel

commit 19223f26d97077da8cf25251458afe00cae20cbb
Author: Alexey Dobriyan <adobriyan@gmail.com>
Date:   Tue Nov 4 14:22:13 2008 +0100

    netfilter: arptable_filter: merge forward hook
    
    It's identical to NF_ARP_IN hook.
    
    Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/net/ipv4/netfilter/arptable_filter.c b/net/ipv4/netfilter/arptable_filter.c
index bee3d11..e091187 100644
--- a/net/ipv4/netfilter/arptable_filter.c
+++ b/net/ipv4/netfilter/arptable_filter.c
@@ -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,

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* netfilter 04/29: netns ebtables: part 1
  2008-11-27 16:15 netfilter 00/29: Netfilter Update Patrick McHardy
                   ` (2 preceding siblings ...)
  2008-11-27 16:15 ` netfilter 03/29: arptable_filter: merge forward hook Patrick McHardy
@ 2008-11-27 16:15 ` Patrick McHardy
  2008-11-27 16:15 ` netfilter 05/29: netns ebtables: part 2 Patrick McHardy
                   ` (26 subsequent siblings)
  30 siblings, 0 replies; 46+ messages in thread
From: Patrick McHardy @ 2008-11-27 16:15 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy, netfilter-devel

commit 511061e2dd1b84bb21bb97c9216a19606c29ac02
Author: Alexey Dobriyan <adobriyan@gmail.com>
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.
    
    Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/include/linux/netfilter_bridge/ebtables.h b/include/linux/netfilter_bridge/ebtables.h
index d45e29c..624e788 100644
--- a/include/linux/netfilter_bridge/ebtables.h
+++ b/include/linux/netfilter_bridge/ebtables.h
@@ -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,
diff --git a/net/bridge/netfilter/ebtable_broute.c b/net/bridge/netfilter/ebtable_broute.c
index 246626b..1731ce8 100644
--- a/net/bridge/netfilter/ebtable_broute.c
+++ b/net/bridge/netfilter/ebtable_broute.c
@@ -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 */
diff --git a/net/bridge/netfilter/ebtable_filter.c b/net/bridge/netfilter/ebtable_filter.c
index 1a58af5..af8953c 100644
--- a/net/bridge/netfilter/ebtable_filter.c
+++ b/net/bridge/netfilter/ebtable_filter.c
@@ -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));
diff --git a/net/bridge/netfilter/ebtable_nat.c b/net/bridge/netfilter/ebtable_nat.c
index f60c1e7..bafe160 100644
--- a/net/bridge/netfilter/ebtable_nat.c
+++ b/net/bridge/netfilter/ebtable_nat.c
@@ -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));
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
index 0fa208e..c1a82b2 100644
--- a/net/bridge/netfilter/ebtables.c
+++ b/net/bridge/netfilter/ebtables.c
@@ -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;
 

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* netfilter 05/29: netns ebtables: part 2
  2008-11-27 16:15 netfilter 00/29: Netfilter Update Patrick McHardy
                   ` (3 preceding siblings ...)
  2008-11-27 16:15 ` netfilter 04/29: netns ebtables: part 1 Patrick McHardy
@ 2008-11-27 16:15 ` Patrick McHardy
  2008-11-27 16:15 ` netfilter 06/29: netns ebtables: more cleanup during ebt_unregister_table() Patrick McHardy
                   ` (25 subsequent siblings)
  30 siblings, 0 replies; 46+ messages in thread
From: Patrick McHardy @ 2008-11-27 16:15 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy, netfilter-devel

commit 6beceee5aa2cb94c4ae9f0784c7d3135d343f5b5
Author: Alexey Dobriyan <adobriyan@gmail.com>
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.
    
    Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/include/linux/netfilter_bridge/ebtables.h b/include/linux/netfilter_bridge/ebtables.h
index 624e788..e40ddb9 100644
--- a/include/linux/netfilter_bridge/ebtables.h
+++ b/include/linux/netfilter_bridge/ebtables.h
@@ -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,
diff --git a/net/bridge/netfilter/ebtable_broute.c b/net/bridge/netfilter/ebtable_broute.c
index 1731ce8..3277d68 100644
--- a/net/bridge/netfilter/ebtable_broute.c
+++ b/net/bridge/netfilter/ebtable_broute.c
@@ -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);
diff --git a/net/bridge/netfilter/ebtable_filter.c b/net/bridge/netfilter/ebtable_filter.c
index af8953c..596564c 100644
--- a/net/bridge/netfilter/ebtable_filter.c
+++ b/net/bridge/netfilter/ebtable_filter.c
@@ -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);
diff --git a/net/bridge/netfilter/ebtable_nat.c b/net/bridge/netfilter/ebtable_nat.c
index bafe160..0d8fc5b 100644
--- a/net/bridge/netfilter/ebtable_nat.c
+++ b/net/bridge/netfilter/ebtable_nat.c
@@ -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);
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
index c1a82b2..82e1752 100644
--- a/net/bridge/netfilter/ebtables.c
+++ b/net/bridge/netfilter/ebtables.c
@@ -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 */

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* netfilter 06/29: netns ebtables: more cleanup during ebt_unregister_table()
  2008-11-27 16:15 netfilter 00/29: Netfilter Update Patrick McHardy
                   ` (4 preceding siblings ...)
  2008-11-27 16:15 ` netfilter 05/29: netns ebtables: part 2 Patrick McHardy
@ 2008-11-27 16:15 ` Patrick McHardy
  2008-11-27 16:15 ` netfilter 07/29: netns ebtables: ebtable_broute in netns Patrick McHardy
                   ` (24 subsequent siblings)
  30 siblings, 0 replies; 46+ messages in thread
From: Patrick McHardy @ 2008-11-27 16:15 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy, netfilter-devel

commit dbcdf85a2e3d2aa584dafd10b5a1f42764e673e7
Author: Alexey Dobriyan <adobriyan@gmail.com>
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.
    
    Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
index 82e1752..fa108c4 100644
--- a/net/bridge/netfilter/ebtables.c
+++ b/net/bridge/netfilter/ebtables.c
@@ -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)

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* netfilter 07/29: netns ebtables: ebtable_broute in netns
  2008-11-27 16:15 netfilter 00/29: Netfilter Update Patrick McHardy
                   ` (5 preceding siblings ...)
  2008-11-27 16:15 ` netfilter 06/29: netns ebtables: more cleanup during ebt_unregister_table() Patrick McHardy
@ 2008-11-27 16:15 ` Patrick McHardy
  2008-11-27 18:25   ` Jan Engelhardt
  2008-11-27 16:15 ` netfilter 08/29: netns ebtables: ebtable_filter " Patrick McHardy
                   ` (23 subsequent siblings)
  30 siblings, 1 reply; 46+ messages in thread
From: Patrick McHardy @ 2008-11-27 16:15 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy, netfilter-devel

commit 8157e6d16af86e4a8d31a035db7be02a8a171c26
Author: Alexey Dobriyan <adobriyan@gmail.com>
Date:   Tue Nov 4 14:29:03 2008 +0100

    netfilter: netns ebtables: ebtable_broute in netns
    
    Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/include/net/netns/x_tables.h b/include/net/netns/x_tables.h
index b809397..055e684 100644
--- a/include/net/netns/x_tables.h
+++ b/include/net/netns/x_tables.h
@@ -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
diff --git a/net/bridge/netfilter/ebtable_broute.c b/net/bridge/netfilter/ebtable_broute.c
index 3277d68..8604dfc 100644
--- a/net/bridge/netfilter/ebtable_broute.c
+++ b/net/bridge/netfilter/ebtable_broute.c
@@ -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);

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* netfilter 08/29: netns ebtables: ebtable_filter in netns
  2008-11-27 16:15 netfilter 00/29: Netfilter Update Patrick McHardy
                   ` (6 preceding siblings ...)
  2008-11-27 16:15 ` netfilter 07/29: netns ebtables: ebtable_broute in netns Patrick McHardy
@ 2008-11-27 16:15 ` Patrick McHardy
  2008-11-27 16:15 ` netfilter 09/29: netns ebtables: ebtable_nat " Patrick McHardy
                   ` (22 subsequent siblings)
  30 siblings, 0 replies; 46+ messages in thread
From: Patrick McHardy @ 2008-11-27 16:15 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy, netfilter-devel

commit 4aad10938d4e4e8364b664cd5420c3bfeb9b679b
Author: Alexey Dobriyan <adobriyan@gmail.com>
Date:   Tue Nov 4 14:29:58 2008 +0100

    netfilter: netns ebtables: ebtable_filter in netns
    
    Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/include/net/netns/x_tables.h b/include/net/netns/x_tables.h
index 055e684..d258e16 100644
--- a/include/net/netns/x_tables.h
+++ b/include/net/netns/x_tables.h
@@ -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
diff --git a/net/bridge/netfilter/ebtable_filter.c b/net/bridge/netfilter/ebtable_filter.c
index 596564c..2b2e804 100644
--- a/net/bridge/netfilter/ebtable_filter.c
+++ b/net/bridge/netfilter/ebtable_filter.c
@@ -50,41 +50,47 @@ 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,
+ebt_in_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, dev_net(in)->xt.frame_filter);
+}
+
+static unsigned int
+ebt_out_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, dev_net(out)->xt.frame_filter);
 }
 
 static struct nf_hook_ops ebt_ops_filter[] __read_mostly = {
 	{
-		.hook		= ebt_hook,
+		.hook		= ebt_in_hook,
 		.owner		= THIS_MODULE,
 		.pf		= PF_BRIDGE,
 		.hooknum	= NF_BR_LOCAL_IN,
 		.priority	= NF_BR_PRI_FILTER_BRIDGED,
 	},
 	{
-		.hook		= ebt_hook,
+		.hook		= ebt_in_hook,
 		.owner		= THIS_MODULE,
 		.pf		= PF_BRIDGE,
 		.hooknum	= NF_BR_FORWARD,
 		.priority	= NF_BR_PRI_FILTER_BRIDGED,
 	},
 	{
-		.hook		= ebt_hook,
+		.hook		= ebt_out_hook,
 		.owner		= THIS_MODULE,
 		.pf		= PF_BRIDGE,
 		.hooknum	= NF_BR_LOCAL_OUT,
@@ -92,23 +98,41 @@ static struct nf_hook_ops ebt_ops_filter[] __read_mostly = {
 	},
 };
 
+static int __net_init frame_filter_net_init(struct net *net)
+{
+	net->xt.frame_filter = ebt_register_table(net, &frame_filter);
+	if (IS_ERR(net->xt.frame_filter))
+		return PTR_ERR(net->xt.frame_filter);
+	return 0;
+}
+
+static void __net_exit frame_filter_net_exit(struct net *net)
+{
+	ebt_unregister_table(net->xt.frame_filter);
+}
+
+static struct pernet_operations frame_filter_net_ops = {
+	.init = frame_filter_net_init,
+	.exit = frame_filter_net_exit,
+};
+
 static int __init ebtable_filter_init(void)
 {
 	int ret;
 
-	frame_filter = ebt_register_table(&init_net, &__frame_filter);
-	if (IS_ERR(frame_filter))
-		return PTR_ERR(frame_filter);
+	ret = register_pernet_subsys(&frame_filter_net_ops);
+	if (ret < 0)
+		return ret;
 	ret = nf_register_hooks(ebt_ops_filter, ARRAY_SIZE(ebt_ops_filter));
 	if (ret < 0)
-		ebt_unregister_table(frame_filter);
+		unregister_pernet_subsys(&frame_filter_net_ops);
 	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);
+	unregister_pernet_subsys(&frame_filter_net_ops);
 }
 
 module_init(ebtable_filter_init);

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* netfilter 09/29: netns ebtables: ebtable_nat in netns
  2008-11-27 16:15 netfilter 00/29: Netfilter Update Patrick McHardy
                   ` (7 preceding siblings ...)
  2008-11-27 16:15 ` netfilter 08/29: netns ebtables: ebtable_filter " Patrick McHardy
@ 2008-11-27 16:15 ` Patrick McHardy
  2008-11-27 16:15 ` netfilter 10/29: netns ebtables: br_nf_pre_routing_finish() fixup Patrick McHardy
                   ` (21 subsequent siblings)
  30 siblings, 0 replies; 46+ messages in thread
From: Patrick McHardy @ 2008-11-27 16:15 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy, netfilter-devel

commit b71b30a626fd0e43c825a05036e7a2c3f377a563
Author: Alexey Dobriyan <adobriyan@gmail.com>
Date:   Tue Nov 4 14:30:46 2008 +0100

    netfilter: netns ebtables: ebtable_nat in netns
    
    Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/include/net/netns/x_tables.h b/include/net/netns/x_tables.h
index d258e16..9554a64 100644
--- a/include/net/netns/x_tables.h
+++ b/include/net/netns/x_tables.h
@@ -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
diff --git a/net/bridge/netfilter/ebtable_nat.c b/net/bridge/netfilter/ebtable_nat.c
index 0d8fc5b..3fe1ae8 100644
--- a/net/bridge/netfilter/ebtable_nat.c
+++ b/net/bridge/netfilter/ebtable_nat.c
@@ -50,48 +50,47 @@ 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
+ebt_nat_in(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, dev_net(in)->xt.frame_nat);
 }
 
 static unsigned int
-ebt_nat_src(unsigned int hook, struct sk_buff *skb, const struct net_device *in
+ebt_nat_out(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, dev_net(out)->xt.frame_nat);
 }
 
 static struct nf_hook_ops ebt_ops_nat[] __read_mostly = {
 	{
-		.hook		= ebt_nat_dst,
+		.hook		= ebt_nat_out,
 		.owner		= THIS_MODULE,
 		.pf		= PF_BRIDGE,
 		.hooknum	= NF_BR_LOCAL_OUT,
 		.priority	= NF_BR_PRI_NAT_DST_OTHER,
 	},
 	{
-		.hook		= ebt_nat_src,
+		.hook		= ebt_nat_out,
 		.owner		= THIS_MODULE,
 		.pf		= PF_BRIDGE,
 		.hooknum	= NF_BR_POST_ROUTING,
 		.priority	= NF_BR_PRI_NAT_SRC,
 	},
 	{
-		.hook		= ebt_nat_dst,
+		.hook		= ebt_nat_in,
 		.owner		= THIS_MODULE,
 		.pf		= PF_BRIDGE,
 		.hooknum	= NF_BR_PRE_ROUTING,
@@ -99,23 +98,41 @@ static struct nf_hook_ops ebt_ops_nat[] __read_mostly = {
 	},
 };
 
+static int __net_init frame_nat_net_init(struct net *net)
+{
+	net->xt.frame_nat = ebt_register_table(net, &frame_nat);
+	if (IS_ERR(net->xt.frame_nat))
+		return PTR_ERR(net->xt.frame_nat);
+	return 0;
+}
+
+static void __net_exit frame_nat_net_exit(struct net *net)
+{
+	ebt_unregister_table(net->xt.frame_nat);
+}
+
+static struct pernet_operations frame_nat_net_ops = {
+	.init = frame_nat_net_init,
+	.exit = frame_nat_net_exit,
+};
+
 static int __init ebtable_nat_init(void)
 {
 	int ret;
 
-	frame_nat = ebt_register_table(&init_net, &__frame_nat);
-	if (IS_ERR(frame_nat))
-		return PTR_ERR(frame_nat);
+	ret = register_pernet_subsys(&frame_nat_net_ops);
+	if (ret < 0)
+		return ret;
 	ret = nf_register_hooks(ebt_ops_nat, ARRAY_SIZE(ebt_ops_nat));
 	if (ret < 0)
-		ebt_unregister_table(frame_nat);
+		unregister_pernet_subsys(&frame_nat_net_ops);
 	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);
+	unregister_pernet_subsys(&frame_nat_net_ops);
 }
 
 module_init(ebtable_nat_init);

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* netfilter 10/29: netns ebtables: br_nf_pre_routing_finish() fixup
  2008-11-27 16:15 netfilter 00/29: Netfilter Update Patrick McHardy
                   ` (8 preceding siblings ...)
  2008-11-27 16:15 ` netfilter 09/29: netns ebtables: ebtable_nat " Patrick McHardy
@ 2008-11-27 16:15 ` Patrick McHardy
  2008-11-27 16:15 ` netfilter 11/29: nf_nat: remove warn_if_extra_mangle Patrick McHardy
                   ` (20 subsequent siblings)
  30 siblings, 0 replies; 46+ messages in thread
From: Patrick McHardy @ 2008-11-27 16:15 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy, netfilter-devel

commit 249b62035ca247b9cedbefa1acf6bdc53b96e678
Author: Alexey Dobriyan <adobriyan@gmail.com>
Date:   Tue Nov 4 14:31:29 2008 +0100

    netfilter: netns ebtables: br_nf_pre_routing_finish() fixup
    
    Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
index db6176d..bf9d6af 100644
--- a/net/bridge/br_netfilter.c
+++ b/net/bridge/br_netfilter.c
@@ -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) {

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* netfilter 11/29: nf_nat: remove warn_if_extra_mangle
  2008-11-27 16:15 netfilter 00/29: Netfilter Update Patrick McHardy
                   ` (9 preceding siblings ...)
  2008-11-27 16:15 ` netfilter 10/29: netns ebtables: br_nf_pre_routing_finish() fixup Patrick McHardy
@ 2008-11-27 16:15 ` Patrick McHardy
  2008-11-27 18:28   ` Jan Engelhardt
  2008-11-27 16:15 ` netfilter 12/29: ctnetlink: use nf_conntrack_get instead of atomic_inc Patrick McHardy
                   ` (19 subsequent siblings)
  30 siblings, 1 reply; 46+ messages in thread
From: Patrick McHardy @ 2008-11-27 16:15 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy, netfilter-devel

commit 6e3354c1e9946fa585de40e93ad917ec7abd006e
Author: Simon Arlott <simon@fire.lp0.eu>
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.
    
    Signed-off-by: Simon Arlott <simon@fire.lp0.eu>
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/net/ipv4/netfilter/nf_nat_rule.c b/net/ipv4/netfilter/nf_nat_rule.c
index a4f1c34..cf95469 100644
--- a/net/ipv4/netfilter/nf_nat_rule.c
+++ b/net/ipv4/netfilter/nf_nat_rule.c
@@ -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);
 }
 

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* netfilter 12/29: ctnetlink: use nf_conntrack_get instead of atomic_inc
  2008-11-27 16:15 netfilter 00/29: Netfilter Update Patrick McHardy
                   ` (10 preceding siblings ...)
  2008-11-27 16:15 ` netfilter 11/29: nf_nat: remove warn_if_extra_mangle Patrick McHardy
@ 2008-11-27 16:15 ` Patrick McHardy
  2008-11-27 16:15 ` netfilter 13/29: ctnetlink: use EOPNOTSUPP instead of EINVAL if the conntrack has no helper Patrick McHardy
                   ` (18 subsequent siblings)
  30 siblings, 0 replies; 46+ messages in thread
From: Patrick McHardy @ 2008-11-27 16:15 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy, netfilter-devel

commit 238ede8160443a32379fd8f9eb88d00456a09bb4
Author: Pablo Neira Ayuso <pablo@netfilter.org>
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.
    
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index a040d46..80a3f13 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -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);

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* netfilter 13/29: ctnetlink: use EOPNOTSUPP instead of EINVAL if the conntrack has no helper
  2008-11-27 16:15 netfilter 00/29: Netfilter Update Patrick McHardy
                   ` (11 preceding siblings ...)
  2008-11-27 16:15 ` netfilter 12/29: ctnetlink: use nf_conntrack_get instead of atomic_inc Patrick McHardy
@ 2008-11-27 16:15 ` Patrick McHardy
  2008-11-27 16:15 ` netfilter 14/29: ctnetlink: get rid of module refcounting in ctnetlink Patrick McHardy
                   ` (17 subsequent siblings)
  30 siblings, 0 replies; 46+ messages in thread
From: Patrick McHardy @ 2008-11-27 16:15 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy, netfilter-devel

commit bfe2967735e0e0f650bf698a5683db2b6cf4cfd7
Author: Pablo Neira Ayuso <pablo@netfilter.org>
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.
    
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index 80a3f13..d87a939 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -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;
 	}
 

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* netfilter 14/29: ctnetlink: get rid of module refcounting in ctnetlink
  2008-11-27 16:15 netfilter 00/29: Netfilter Update Patrick McHardy
                   ` (12 preceding siblings ...)
  2008-11-27 16:15 ` netfilter 13/29: ctnetlink: use EOPNOTSUPP instead of EINVAL if the conntrack has no helper Patrick McHardy
@ 2008-11-27 16:15 ` Patrick McHardy
  2008-11-27 16:15 ` netfilter 15/29: nf_conntrack: connection tracking helper name persistent aliases Patrick McHardy
                   ` (16 subsequent siblings)
  30 siblings, 0 replies; 46+ messages in thread
From: Patrick McHardy @ 2008-11-27 16:15 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy, netfilter-devel

commit 528a3a6f67d4fbe708b9f306be194e78b29e8d7a
Author: Pablo Neira Ayuso <pablo@netfilter.org>
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.
    
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index d87a939..49a04fa 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -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;
 

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* netfilter 15/29: nf_conntrack: connection tracking helper name persistent aliases
  2008-11-27 16:15 netfilter 00/29: Netfilter Update Patrick McHardy
                   ` (13 preceding siblings ...)
  2008-11-27 16:15 ` netfilter 14/29: ctnetlink: get rid of module refcounting in ctnetlink Patrick McHardy
@ 2008-11-27 16:15 ` Patrick McHardy
  2008-11-27 18:31   ` Jan Engelhardt
  2008-11-27 16:15 ` netfilter 16/29: ctnetlink: helper modules load-on-demand support Patrick McHardy
                   ` (15 subsequent siblings)
  30 siblings, 1 reply; 46+ messages in thread
From: Patrick McHardy @ 2008-11-27 16:15 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy, netfilter-devel

commit 4dc06f9633444f426ef9960c53426f2d2ded64ac
Author: Pablo Neira Ayuso <pablo@netfilter.org>
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.
    
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h
index b76a868..f11255e 100644
--- a/include/net/netfilter/nf_conntrack.h
+++ b/include/net/netfilter/nf_conntrack.h
@@ -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 */
diff --git a/net/netfilter/nf_conntrack_amanda.c b/net/netfilter/nf_conntrack_amanda.c
index 38aedee..4f8fcf4 100644
--- a/net/netfilter/nf_conntrack_amanda.c
+++ b/net/netfilter/nf_conntrack_amanda.c
@@ -30,6 +30,7 @@ MODULE_AUTHOR("Brian J. Murrell <netfilter@interlinx.bc.ca>");
 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");
diff --git a/net/netfilter/nf_conntrack_ftp.c b/net/netfilter/nf_conntrack_ftp.c
index 6295009..703a437 100644
--- a/net/netfilter/nf_conntrack_ftp.c
+++ b/net/netfilter/nf_conntrack_ftp.c
@@ -29,6 +29,7 @@ MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Rusty Russell <rusty@rustcorp.com.au>");
 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;
diff --git a/net/netfilter/nf_conntrack_h323_main.c b/net/netfilter/nf_conntrack_h323_main.c
index 99bc803..687bd63 100644
--- a/net/netfilter/nf_conntrack_h323_main.c
+++ b/net/netfilter/nf_conntrack_h323_main.c
@@ -1827,3 +1827,4 @@ MODULE_AUTHOR("Jing Min Zhao <zhaojingmin@users.sourceforge.net>");
 MODULE_DESCRIPTION("H.323 connection tracking helper");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS("ip_conntrack_h323");
+MODULE_ALIAS_NFCT_HELPER("h323");
diff --git a/net/netfilter/nf_conntrack_irc.c b/net/netfilter/nf_conntrack_irc.c
index 4d681a0..409c8be 100644
--- a/net/netfilter/nf_conntrack_irc.c
+++ b/net/netfilter/nf_conntrack_irc.c
@@ -41,6 +41,7 @@ MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
 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");
diff --git a/net/netfilter/nf_conntrack_netbios_ns.c b/net/netfilter/nf_conntrack_netbios_ns.c
index 08404e6..5af4273 100644
--- a/net/netfilter/nf_conntrack_netbios_ns.c
+++ b/net/netfilter/nf_conntrack_netbios_ns.c
@@ -37,6 +37,7 @@ MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
 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);
diff --git a/net/netfilter/nf_conntrack_pptp.c b/net/netfilter/nf_conntrack_pptp.c
index 1bc3001..9e169ef 100644
--- a/net/netfilter/nf_conntrack_pptp.c
+++ b/net/netfilter/nf_conntrack_pptp.c
@@ -37,6 +37,7 @@ MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
 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);
 
diff --git a/net/netfilter/nf_conntrack_sane.c b/net/netfilter/nf_conntrack_sane.c
index a94294b..dcfecbb 100644
--- a/net/netfilter/nf_conntrack_sane.c
+++ b/net/netfilter/nf_conntrack_sane.c
@@ -30,6 +30,7 @@
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Michal Schmidt <mschmidt@redhat.com>");
 MODULE_DESCRIPTION("SANE connection tracking helper");
+MODULE_ALIAS_NFCT_HELPER("sane");
 
 static char *sane_buffer;
 
diff --git a/net/netfilter/nf_conntrack_sip.c b/net/netfilter/nf_conntrack_sip.c
index 6813f1c..4b57216 100644
--- a/net/netfilter/nf_conntrack_sip.c
+++ b/net/netfilter/nf_conntrack_sip.c
@@ -28,6 +28,7 @@ MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Christian Hentschel <chentschel@arnet.com.ar>");
 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];
diff --git a/net/netfilter/nf_conntrack_tftp.c b/net/netfilter/nf_conntrack_tftp.c
index f57f6e7..46e646b 100644
--- a/net/netfilter/nf_conntrack_tftp.c
+++ b/net/netfilter/nf_conntrack_tftp.c
@@ -22,6 +22,7 @@ MODULE_AUTHOR("Magnus Boden <mb@ozaba.mine.nu>");
 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];

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* netfilter 16/29: ctnetlink: helper modules load-on-demand support
  2008-11-27 16:15 netfilter 00/29: Netfilter Update Patrick McHardy
                   ` (14 preceding siblings ...)
  2008-11-27 16:15 ` netfilter 15/29: nf_conntrack: connection tracking helper name persistent aliases Patrick McHardy
@ 2008-11-27 16:15 ` Patrick McHardy
  2008-11-27 16:15 ` netfilter 17/29: ctnetlink: deliver events for conntracks changed from userspace Patrick McHardy
                   ` (14 subsequent siblings)
  30 siblings, 0 replies; 46+ messages in thread
From: Patrick McHardy @ 2008-11-27 16:15 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy, netfilter-devel

commit 226c0c0ef2abdf91b8d9cce1aaf7d4635a5e5926
Author: Pablo Neira Ayuso <pablo@netfilter.org>
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.
    
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/include/net/netfilter/nf_conntrack_helper.h b/include/net/netfilter/nf_conntrack_helper.h
index f8060ab..66d65a7 100644
--- a/include/net/netfilter/nf_conntrack_helper.h
+++ b/include/net/netfilter/nf_conntrack_helper.h
@@ -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);
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 622d7c6..1e649fb 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -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);
diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
index 9c06b9f..9e4b74b 100644
--- a/net/netfilter/nf_conntrack_helper.c
+++ b/net/netfilter/nf_conntrack_helper.c
@@ -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)
 {
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index 49a04fa..4f6486c 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -917,8 +917,22 @@ ctnetlink_change_helper(struct nf_conn *ct, struct nlattr *cda[])
 	}
 
 	helper = __nf_conntrack_helper_find_byname(helpname);
-	if (helper == NULL)
+	if (helper == NULL) {
+#ifdef CONFIG_MODULES
+		spin_unlock_bh(&nf_conntrack_lock);
+
+		if (request_module("nfct-helper-%s", helpname) < 0) {
+			spin_lock_bh(&nf_conntrack_lock);
+			return -EOPNOTSUPP;
+		}
+
+		spin_lock_bh(&nf_conntrack_lock);
+		helper = __nf_conntrack_helper_find_byname(helpname);
+		if (helper)
+			return -EAGAIN;
+#endif
 		return -EOPNOTSUPP;
+	}
 
 	if (help) {
 		if (help->helper == helper)
@@ -1082,7 +1096,6 @@ ctnetlink_create_conntrack(struct nlattr *cda[],
 {
 	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);
@@ -1097,16 +1110,55 @@ ctnetlink_create_conntrack(struct nlattr *cda[],
 	ct->status |= IPS_CONFIRMED;
 
 	rcu_read_lock();
-	helper = __nf_ct_helper_find(rtuple);
-	if (helper) {
-		help = nf_ct_helper_ext_add(ct, GFP_ATOMIC);
-		if (help == NULL) {
+ 	if (cda[CTA_HELP]) {
+ 		char *helpname;
+
+ 		err = ctnetlink_parse_help(cda[CTA_HELP], &helpname);
+ 		if (err < 0) {
+			rcu_read_unlock();
+			goto err;
+		}
+
+		helper = __nf_conntrack_helper_find_byname(helpname);
+		if (helper == NULL) {
+			rcu_read_unlock();
+#ifdef CONFIG_MODULES
+			if (request_module("nfct-helper-%s", helpname) < 0) {
+				err = -EOPNOTSUPP;
+				goto err;
+			}
+
+			rcu_read_lock();
+			helper = __nf_conntrack_helper_find_byname(helpname);
+			if (helper) {
+				rcu_read_unlock();
+				err = -EAGAIN;
+				goto err;
+			}
+			rcu_read_unlock();
+#endif
+			err = -EOPNOTSUPP;
+			goto err;
+		} else {
+			struct nf_conn_help *help;
+
+			help = nf_ct_helper_ext_add(ct, GFP_ATOMIC);
+			if (help == NULL) {
+				rcu_read_unlock();
+				err = -ENOMEM;
+				goto err;
+			}
+
+			/* not in hash table yet so not strictly necessary */
+			rcu_assign_pointer(help->helper, helper);
+		}
+	} else {
+		/* try an implicit helper assignation */
+		err = __nf_ct_try_assign_helper(ct, GFP_ATOMIC);
+		if (err < 0) {
 			rcu_read_unlock();
-			err = -ENOMEM;
 			goto err;
 		}
-		/* not in hash table yet so not strictly necessary */
-		rcu_assign_pointer(help->helper, helper);
 	}
 
 	if (cda[CTA_STATUS]) {

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* netfilter 17/29: ctnetlink: deliver events for conntracks changed from userspace
  2008-11-27 16:15 netfilter 00/29: Netfilter Update Patrick McHardy
                   ` (15 preceding siblings ...)
  2008-11-27 16:15 ` netfilter 16/29: ctnetlink: helper modules load-on-demand support Patrick McHardy
@ 2008-11-27 16:15 ` Patrick McHardy
  2008-11-27 16:15 ` netfilter 18/29: nfnetlink_log: fix warning and prototype mismatch Patrick McHardy
                   ` (13 subsequent siblings)
  30 siblings, 0 replies; 46+ messages in thread
From: Patrick McHardy @ 2008-11-27 16:15 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy, netfilter-devel

commit 19abb7b090a6bce88d4e9b2914a0367f4f684432
Author: Pablo Neira Ayuso <pablo@netfilter.org>
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.
    
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h
index f11255e..2e0c536 100644
--- a/include/net/netfilter/nf_conntrack.h
+++ b/include/net/netfilter/nf_conntrack.h
@@ -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,
diff --git a/include/net/netfilter/nf_conntrack_ecache.h b/include/net/netfilter/nf_conntrack_ecache.h
index 1285ff2..0ff0dc6 100644
--- a/include/net/netfilter/nf_conntrack_ecache.h
+++ b/include/net/netfilter/nf_conntrack_ecache.h
@@ -17,6 +17,13 @@ struct nf_conntrack_ecache {
 	unsigned int events;
 };
 
+/* This structure is passed to event handler */
+struct nf_ct_event {
+	struct nf_conn *ct;
+	u32 pid;
+	int report;
+};
+
 extern struct atomic_notifier_head nf_conntrack_chain;
 extern int nf_conntrack_register_notifier(struct notifier_block *nb);
 extern int nf_conntrack_unregister_notifier(struct notifier_block *nb);
@@ -39,22 +46,56 @@ nf_conntrack_event_cache(enum ip_conntrack_events event, struct nf_conn *ct)
 	local_bh_enable();
 }
 
-static inline void nf_conntrack_event(enum ip_conntrack_events event,
-				      struct nf_conn *ct)
+static inline void
+nf_conntrack_event_report(enum ip_conntrack_events event,
+			  struct nf_conn *ct,
+			  u32 pid,
+			  int report)
 {
+	struct nf_ct_event item = {
+		.ct 	= ct,
+		.pid	= pid,
+		.report = report
+	};
 	if (nf_ct_is_confirmed(ct) && !nf_ct_is_dying(ct))
-		atomic_notifier_call_chain(&nf_conntrack_chain, event, ct);
+		atomic_notifier_call_chain(&nf_conntrack_chain, event, &item);
 }
 
+static inline void
+nf_conntrack_event(enum ip_conntrack_events event, struct nf_conn *ct)
+{
+	nf_conntrack_event_report(event, ct, 0, 0);
+}
+
+struct nf_exp_event {
+	struct nf_conntrack_expect *exp;
+	u32 pid;
+	int report;
+};
+
 extern struct atomic_notifier_head nf_ct_expect_chain;
 extern int nf_ct_expect_register_notifier(struct notifier_block *nb);
 extern int nf_ct_expect_unregister_notifier(struct notifier_block *nb);
 
 static inline void
+nf_ct_expect_event_report(enum ip_conntrack_expect_events event,
+			  struct nf_conntrack_expect *exp,
+			  u32 pid,
+			  int report)
+{
+	struct nf_exp_event item = {
+		.exp	= exp,
+		.pid	= pid,
+		.report = report
+	};
+	atomic_notifier_call_chain(&nf_ct_expect_chain, event, &item);
+}
+
+static inline void
 nf_ct_expect_event(enum ip_conntrack_expect_events event,
 		   struct nf_conntrack_expect *exp)
 {
-	atomic_notifier_call_chain(&nf_ct_expect_chain, event, exp);
+	nf_ct_expect_event_report(event, exp, 0, 0);
 }
 
 extern int nf_conntrack_ecache_init(struct net *net);
@@ -66,9 +107,17 @@ static inline void nf_conntrack_event_cache(enum ip_conntrack_events event,
 					    struct nf_conn *ct) {}
 static inline void nf_conntrack_event(enum ip_conntrack_events event,
 				      struct nf_conn *ct) {}
+static inline void nf_conntrack_event_report(enum ip_conntrack_events event,
+					     struct nf_conn *ct,
+					     u32 pid,
+					     int report) {}
 static inline void nf_ct_deliver_cached_events(const struct nf_conn *ct) {}
 static inline void nf_ct_expect_event(enum ip_conntrack_expect_events event,
 				      struct nf_conntrack_expect *exp) {}
+static inline void nf_ct_expect_event_report(enum ip_conntrack_expect_events e,
+					     struct nf_conntrack_expect *exp,
+ 					     u32 pid,
+ 					     int report) {}
 static inline void nf_ct_event_cache_flush(struct net *net) {}
 
 static inline int nf_conntrack_ecache_init(struct net *net)
diff --git a/include/net/netfilter/nf_conntrack_expect.h b/include/net/netfilter/nf_conntrack_expect.h
index 37a7fc1..ab17a15 100644
--- a/include/net/netfilter/nf_conntrack_expect.h
+++ b/include/net/netfilter/nf_conntrack_expect.h
@@ -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*/
 
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 1e649fb..dc3fea0 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -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;
diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
index a5f5e2e..dee4190 100644
--- a/net/netfilter/nf_conntrack_ecache.c
+++ b/net/netfilter/nf_conntrack_ecache.c
@@ -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);
diff --git a/net/netfilter/nf_conntrack_expect.c b/net/netfilter/nf_conntrack_expect.c
index 37a703b..3a8a34a 100644
--- a/net/netfilter/nf_conntrack_expect.c
+++ b/net/netfilter/nf_conntrack_expect.c
@@ -362,7 +362,7 @@ static inline int refresh_timer(struct nf_conntrack_expect *i)
 	return 1;
 }
 
-int nf_ct_expect_related(struct nf_conntrack_expect *expect)
+static inline int __nf_ct_expect_check(struct nf_conntrack_expect *expect)
 {
 	const struct nf_conntrack_expect_policy *p;
 	struct nf_conntrack_expect *i;
@@ -371,11 +371,8 @@ int nf_ct_expect_related(struct nf_conntrack_expect *expect)
 	struct net *net = nf_ct_exp_net(expect);
 	struct hlist_node *n;
 	unsigned int h;
-	int ret;
-
-	NF_CT_ASSERT(master_help);
+	int ret = 0;
 
-	spin_lock_bh(&nf_conntrack_lock);
 	if (!master_help->helper) {
 		ret = -ESHUTDOWN;
 		goto out;
@@ -409,18 +406,50 @@ int nf_ct_expect_related(struct nf_conntrack_expect *expect)
 			printk(KERN_WARNING
 			       "nf_conntrack: expectation table full\n");
 		ret = -EMFILE;
-		goto out;
 	}
+out:
+	return ret;
+}
+
+int nf_ct_expect_related(struct nf_conntrack_expect *expect)
+{
+	int ret;
+
+	spin_lock_bh(&nf_conntrack_lock);
+	ret = __nf_ct_expect_check(expect);
+	if (ret < 0)
+		goto out;
 
 	nf_ct_expect_insert(expect);
+	atomic_inc(&expect->use);
+	spin_unlock_bh(&nf_conntrack_lock);
 	nf_ct_expect_event(IPEXP_NEW, expect);
-	ret = 0;
+	nf_ct_expect_put(expect);
+	return ret;
 out:
 	spin_unlock_bh(&nf_conntrack_lock);
 	return ret;
 }
 EXPORT_SYMBOL_GPL(nf_ct_expect_related);
 
+int nf_ct_expect_related_report(struct nf_conntrack_expect *expect,
+				u32 pid, int report)
+{
+	int ret;
+
+	spin_lock_bh(&nf_conntrack_lock);
+	ret = __nf_ct_expect_check(expect);
+	if (ret < 0)
+		goto out;
+	nf_ct_expect_insert(expect);
+out:
+	spin_unlock_bh(&nf_conntrack_lock);
+	if (ret == 0)
+		nf_ct_expect_event_report(IPEXP_NEW, expect, pid, report);
+	return ret;
+}
+EXPORT_SYMBOL_GPL(nf_ct_expect_related_report);
+
 #ifdef CONFIG_PROC_FS
 struct ct_expect_iter_state {
 	struct seq_net_private p;
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index 4f6486c..ccc5ef1 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -410,7 +410,8 @@ static int ctnetlink_conntrack_event(struct notifier_block *this,
 	struct nlmsghdr *nlh;
 	struct nfgenmsg *nfmsg;
 	struct nlattr *nest_parms;
-	struct nf_conn *ct = (struct nf_conn *)ptr;
+	struct nf_ct_event *item = (struct nf_ct_event *)ptr;
+	struct nf_conn *ct = item->ct;
 	struct sk_buff *skb;
 	unsigned int type;
 	sk_buff_data_t b;
@@ -443,7 +444,7 @@ static int ctnetlink_conntrack_event(struct notifier_block *this,
 	b = skb->tail;
 
 	type |= NFNL_SUBSYS_CTNETLINK << 8;
-	nlh   = NLMSG_PUT(skb, 0, 0, type, sizeof(struct nfgenmsg));
+	nlh   = NLMSG_PUT(skb, item->pid, 0, type, sizeof(struct nfgenmsg));
 	nfmsg = NLMSG_DATA(nlh);
 
 	nlh->nlmsg_flags    = flags;
@@ -511,7 +512,7 @@ static int ctnetlink_conntrack_event(struct notifier_block *this,
 	rcu_read_unlock();
 
 	nlh->nlmsg_len = skb->tail - b;
-	nfnetlink_send(skb, 0, group, 0);
+	nfnetlink_send(skb, item->pid, group, item->report);
 	return NOTIFY_DONE;
 
 nla_put_failure:
@@ -722,7 +723,9 @@ ctnetlink_del_conntrack(struct sock *ctnl, struct sk_buff *skb,
 		err = ctnetlink_parse_tuple(cda, &tuple, CTA_TUPLE_REPLY, u3);
 	else {
 		/* Flush the whole table */
-		nf_conntrack_flush(&init_net);
+		nf_conntrack_flush(&init_net,
+				   NETLINK_CB(skb).pid,
+				   nlmsg_report(nlh));
 		return 0;
 	}
 
@@ -743,6 +746,14 @@ ctnetlink_del_conntrack(struct sock *ctnl, struct sk_buff *skb,
 		}
 	}
 
+	nf_conntrack_event_report(IPCT_DESTROY,
+				  ct,
+				  NETLINK_CB(skb).pid,
+				  nlmsg_report(nlh));
+
+	/* death_by_timeout would report the event again */
+	set_bit(IPS_DYING_BIT, &ct->status);
+
 	nf_ct_kill(ct);
 	nf_ct_put(ct);
 
@@ -1088,11 +1099,35 @@ ctnetlink_change_conntrack(struct nf_conn *ct, struct nlattr *cda[])
 	return 0;
 }
 
+static inline void
+ctnetlink_event_report(struct nf_conn *ct, u32 pid, int report)
+{
+	unsigned int events = 0;
+
+	if (test_bit(IPS_EXPECTED_BIT, &ct->status))
+		events |= IPCT_RELATED;
+	else
+		events |= IPCT_NEW;
+
+	nf_conntrack_event_report(IPCT_STATUS |
+				  IPCT_HELPER |
+				  IPCT_REFRESH |
+				  IPCT_PROTOINFO |
+				  IPCT_NATSEQADJ |
+				  IPCT_MARK |
+				  events,
+				  ct,
+				  pid,
+				  report);
+}
+
 static int
 ctnetlink_create_conntrack(struct nlattr *cda[],
 			   struct nf_conntrack_tuple *otuple,
 			   struct nf_conntrack_tuple *rtuple,
-			   struct nf_conn *master_ct)
+			   struct nf_conn *master_ct,
+			   u32 pid,
+			   int report)
 {
 	struct nf_conn *ct;
 	int err = -EINVAL;
@@ -1198,9 +1233,12 @@ ctnetlink_create_conntrack(struct nlattr *cda[],
 		ct->master = master_ct;
 	}
 
+	nf_conntrack_get(&ct->ct_general);
 	add_timer(&ct->timeout);
 	nf_conntrack_hash_insert(ct);
 	rcu_read_unlock();
+	ctnetlink_event_report(ct, pid, report);
+	nf_ct_put(ct);
 
 	return 0;
 
@@ -1265,7 +1303,9 @@ ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,
 			err = ctnetlink_create_conntrack(cda,
 							 &otuple,
 							 &rtuple,
-							 master_ct);
+							 master_ct,
+							 NETLINK_CB(skb).pid,
+							 nlmsg_report(nlh));
 		if (err < 0 && master_ct)
 			nf_ct_put(master_ct);
 
@@ -1277,6 +1317,8 @@ ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,
 	 * so there's no need to increase the refcount */
 	err = -EEXIST;
 	if (!(nlh->nlmsg_flags & NLM_F_EXCL)) {
+		struct nf_conn *ct = nf_ct_tuplehash_to_ctrack(h);
+
 		/* we only allow nat config for new conntracks */
 		if (cda[CTA_NAT_SRC] || cda[CTA_NAT_DST]) {
 			err = -EOPNOTSUPP;
@@ -1287,8 +1329,19 @@ ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,
 			err = -EOPNOTSUPP;
 			goto out_unlock;
 		}
-		err = ctnetlink_change_conntrack(nf_ct_tuplehash_to_ctrack(h),
-						 cda);
+
+		err = ctnetlink_change_conntrack(ct, cda);
+		if (err == 0) {
+			nf_conntrack_get(&ct->ct_general);
+			spin_unlock_bh(&nf_conntrack_lock);
+			ctnetlink_event_report(ct,
+					       NETLINK_CB(skb).pid,
+					       nlmsg_report(nlh));
+			nf_ct_put(ct);
+		} else
+			spin_unlock_bh(&nf_conntrack_lock);
+
+		return err;
 	}
 
 out_unlock:
@@ -1423,7 +1476,8 @@ static int ctnetlink_expect_event(struct notifier_block *this,
 {
 	struct nlmsghdr *nlh;
 	struct nfgenmsg *nfmsg;
-	struct nf_conntrack_expect *exp = (struct nf_conntrack_expect *)ptr;
+	struct nf_exp_event *item = (struct nf_exp_event *)ptr;
+	struct nf_conntrack_expect *exp = item->exp;
 	struct sk_buff *skb;
 	unsigned int type;
 	sk_buff_data_t b;
@@ -1445,7 +1499,7 @@ static int ctnetlink_expect_event(struct notifier_block *this,
 	b = skb->tail;
 
 	type |= NFNL_SUBSYS_CTNETLINK_EXP << 8;
-	nlh   = NLMSG_PUT(skb, 0, 0, type, sizeof(struct nfgenmsg));
+	nlh   = NLMSG_PUT(skb, item->pid, 0, type, sizeof(struct nfgenmsg));
 	nfmsg = NLMSG_DATA(nlh);
 
 	nlh->nlmsg_flags    = flags;
@@ -1459,7 +1513,7 @@ static int ctnetlink_expect_event(struct notifier_block *this,
 	rcu_read_unlock();
 
 	nlh->nlmsg_len = skb->tail - b;
-	nfnetlink_send(skb, 0, NFNLGRP_CONNTRACK_EXP_NEW, 0);
+	nfnetlink_send(skb, item->pid, NFNLGRP_CONNTRACK_EXP_NEW, item->report);
 	return NOTIFY_DONE;
 
 nla_put_failure:
@@ -1673,7 +1727,7 @@ ctnetlink_change_expect(struct nf_conntrack_expect *x, struct nlattr *cda[])
 }
 
 static int
-ctnetlink_create_expect(struct nlattr *cda[], u_int8_t u3)
+ctnetlink_create_expect(struct nlattr *cda[], u_int8_t u3, u32 pid, int report)
 {
 	struct nf_conntrack_tuple tuple, mask, master_tuple;
 	struct nf_conntrack_tuple_hash *h = NULL;
@@ -1720,7 +1774,7 @@ ctnetlink_create_expect(struct nlattr *cda[], u_int8_t u3)
 	memcpy(&exp->mask.src.u3, &mask.src.u3, sizeof(exp->mask.src.u3));
 	exp->mask.src.u.all = mask.src.u.all;
 
-	err = nf_ct_expect_related(exp);
+	err = nf_ct_expect_related_report(exp, pid, report);
 	nf_ct_expect_put(exp);
 
 out:
@@ -1753,8 +1807,12 @@ ctnetlink_new_expect(struct sock *ctnl, struct sk_buff *skb,
 	if (!exp) {
 		spin_unlock_bh(&nf_conntrack_lock);
 		err = -ENOENT;
-		if (nlh->nlmsg_flags & NLM_F_CREATE)
-			err = ctnetlink_create_expect(cda, u3);
+		if (nlh->nlmsg_flags & NLM_F_CREATE) {
+			err = ctnetlink_create_expect(cda,
+						      u3,
+						      NETLINK_CB(skb).pid,
+						      nlmsg_report(nlh));
+		}
 		return err;
 	}
 

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* netfilter 18/29: nfnetlink_log: fix warning and prototype mismatch
  2008-11-27 16:15 netfilter 00/29: Netfilter Update Patrick McHardy
                   ` (16 preceding siblings ...)
  2008-11-27 16:15 ` netfilter 17/29: ctnetlink: deliver events for conntracks changed from userspace Patrick McHardy
@ 2008-11-27 16:15 ` Patrick McHardy
  2008-11-27 16:15 ` netfilter 19/29: nf_conntrack: " Patrick McHardy
                   ` (12 subsequent siblings)
  30 siblings, 0 replies; 46+ messages in thread
From: Patrick McHardy @ 2008-11-27 16:15 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy, netfilter-devel

commit d9e150071d18b5c87ba7a097af4063a5ad0c6a0c
Author: Patrick McHardy <kaber@trash.net>
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.
    
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/include/net/netfilter/nfnetlink_log.h b/include/net/netfilter/nfnetlink_log.h
index 9b67f94..b0569ff 100644
--- a/include/net/netfilter/nfnetlink_log.h
+++ b/include/net/netfilter/nfnetlink_log.h
@@ -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,
diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
index a51892b..2770b4e 100644
--- a/net/netfilter/nfnetlink_log.c
+++ b/net/netfilter/nfnetlink_log.c
@@ -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>
 

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* netfilter 19/29: nf_conntrack: fix warning and prototype mismatch
  2008-11-27 16:15 netfilter 00/29: Netfilter Update Patrick McHardy
                   ` (17 preceding siblings ...)
  2008-11-27 16:15 ` netfilter 18/29: nfnetlink_log: fix warning and prototype mismatch Patrick McHardy
@ 2008-11-27 16:15 ` Patrick McHardy
  2008-11-27 16:15 ` netfilter 20/29: xt_recent: don't save proc dirs Patrick McHardy
                   ` (11 subsequent siblings)
  30 siblings, 0 replies; 46+ messages in thread
From: Patrick McHardy @ 2008-11-27 16:15 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy, netfilter-devel

commit e17b666a468285409ab9f6caff9df16936d27d71
Author: Patrick McHardy <kaber@trash.net>
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.
    
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index dc3fea0..73419de 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -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);

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* netfilter 20/29: xt_recent: don't save proc dirs
  2008-11-27 16:15 netfilter 00/29: Netfilter Update Patrick McHardy
                   ` (18 preceding siblings ...)
  2008-11-27 16:15 ` netfilter 19/29: nf_conntrack: " Patrick McHardy
@ 2008-11-27 16:15 ` Patrick McHardy
  2008-11-27 16:15 ` netfilter 21/29: ip6table_filter: merge LOCAL_IN and FORWARD hooks Patrick McHardy
                   ` (10 subsequent siblings)
  30 siblings, 0 replies; 46+ messages in thread
From: Patrick McHardy @ 2008-11-27 16:15 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy, netfilter-devel

commit b0ceb560a4119f187dc50da655be389cb54ae4f9
Author: Alexey Dobriyan <adobriyan@gmail.com>
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.
    
    Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/net/netfilter/xt_recent.c b/net/netfilter/xt_recent.c
index 3c3dd22..fe80b61 100644
--- a/net/netfilter/xt_recent.c
+++ b/net/netfilter/xt_recent.c
@@ -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);

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* netfilter 21/29: ip6table_filter: merge LOCAL_IN and FORWARD hooks
  2008-11-27 16:15 netfilter 00/29: Netfilter Update Patrick McHardy
                   ` (19 preceding siblings ...)
  2008-11-27 16:15 ` netfilter 20/29: xt_recent: don't save proc dirs Patrick McHardy
@ 2008-11-27 16:15 ` Patrick McHardy
  2008-11-27 16:15 ` netfilter 22/29: nf_conntrack_proto_gre: spread __exit Patrick McHardy
                   ` (9 subsequent siblings)
  30 siblings, 0 replies; 46+ messages in thread
From: Patrick McHardy @ 2008-11-27 16:15 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy, netfilter-devel

commit 61d3015808d877eb4ea225b5924feb128b0c1bc7
Author: Alexey Dobriyan <adobriyan@gmail.com>
Date:   Thu Nov 20 09:58:08 2008 +0100

    netfilter: ip6table_filter: merge LOCAL_IN and FORWARD hooks
    
    Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/net/ipv6/netfilter/ip6table_filter.c b/net/ipv6/netfilter/ip6table_filter.c
index b110a8a..40d2e36 100644
--- a/net/ipv6/netfilter/ip6table_filter.c
+++ b/net/ipv6/netfilter/ip6table_filter.c
@@ -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,

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* netfilter 22/29: nf_conntrack_proto_gre: spread __exit
  2008-11-27 16:15 netfilter 00/29: Netfilter Update Patrick McHardy
                   ` (20 preceding siblings ...)
  2008-11-27 16:15 ` netfilter 21/29: ip6table_filter: merge LOCAL_IN and FORWARD hooks Patrick McHardy
@ 2008-11-27 16:15 ` Patrick McHardy
  2008-11-27 16:15 ` netfilter 23/29: ip{,6}t_policy.h should include xp_policy.h Patrick McHardy
                   ` (8 subsequent siblings)
  30 siblings, 0 replies; 46+ messages in thread
From: Patrick McHardy @ 2008-11-27 16:15 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy, netfilter-devel

commit 56bc0f9603e45cf13db51e554e1541e289a7f8e9
Author: Alexey Dobriyan <adobriyan@gmail.com>
Date:   Thu Nov 20 10:01:37 2008 +0100

    netfilter: nf_conntrack_proto_gre: spread __exit
    
    Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/net/netfilter/nf_conntrack_proto_gre.c b/net/netfilter/nf_conntrack_proto_gre.c
index 4ab62ad..1b279f9 100644
--- a/net/netfilter/nf_conntrack_proto_gre.c
+++ b/net/netfilter/nf_conntrack_proto_gre.c
@@ -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);

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* netfilter 23/29: ip{,6}t_policy.h should include xp_policy.h
  2008-11-27 16:15 netfilter 00/29: Netfilter Update Patrick McHardy
                   ` (21 preceding siblings ...)
  2008-11-27 16:15 ` netfilter 22/29: nf_conntrack_proto_gre: spread __exit Patrick McHardy
@ 2008-11-27 16:15 ` Patrick McHardy
  2008-11-27 18:33   ` Jan Engelhardt
  2008-11-27 16:15 ` netfilter 24/29: nf_conntrack_proto_sctp: avoid bogus warning Patrick McHardy
                   ` (7 subsequent siblings)
  30 siblings, 1 reply; 46+ messages in thread
From: Patrick McHardy @ 2008-11-27 16:15 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy, netfilter-devel

commit 018a7bf1e55000dd792194238c9043918d24d3dd
Author: Andy Whitcroft <apw@canonical.com>
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.
    
    Signed-off-by: Andy Whitcroft <apw@canonical.com>
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/include/linux/netfilter_ipv4/ipt_policy.h b/include/linux/netfilter_ipv4/ipt_policy.h
index b9478a2..1037fb2 100644
--- a/include/linux/netfilter_ipv4/ipt_policy.h
+++ b/include/linux/netfilter_ipv4/ipt_policy.h
@@ -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 */
diff --git a/include/linux/netfilter_ipv6/ip6t_policy.h b/include/linux/netfilter_ipv6/ip6t_policy.h
index 6bab316..b1c449d 100644
--- a/include/linux/netfilter_ipv6/ip6t_policy.h
+++ b/include/linux/netfilter_ipv6/ip6t_policy.h
@@ -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 */

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* netfilter 24/29: nf_conntrack_proto_sctp: avoid bogus warning
  2008-11-27 16:15 netfilter 00/29: Netfilter Update Patrick McHardy
                   ` (22 preceding siblings ...)
  2008-11-27 16:15 ` netfilter 23/29: ip{,6}t_policy.h should include xp_policy.h Patrick McHardy
@ 2008-11-27 16:15 ` Patrick McHardy
  2008-11-27 16:15 ` netfilter 25/29: nf_conntrack_ftp: change "partial ..." message to pr_debug() Patrick McHardy
                   ` (6 subsequent siblings)
  30 siblings, 0 replies; 46+ messages in thread
From: Patrick McHardy @ 2008-11-27 16:15 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy, netfilter-devel

commit 328bd8997dbb7184d5389e45c642af44ae6e9043
Author: Patrick McHardy <kaber@trash.net>
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 <wfg@linux.intel.com>
    
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/net/netfilter/nf_conntrack_proto_sctp.c b/net/netfilter/nf_conntrack_proto_sctp.c
index c2bd457..74e0379 100644
--- a/net/netfilter/nf_conntrack_proto_sctp.c
+++ b/net/netfilter/nf_conntrack_proto_sctp.c
@@ -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) */

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* netfilter 25/29: nf_conntrack_ftp: change "partial ..." message to pr_debug()
  2008-11-27 16:15 netfilter 00/29: Netfilter Update Patrick McHardy
                   ` (23 preceding siblings ...)
  2008-11-27 16:15 ` netfilter 24/29: nf_conntrack_proto_sctp: avoid bogus warning Patrick McHardy
@ 2008-11-27 16:15 ` Patrick McHardy
  2008-11-27 16:15 ` netfilter 26/29: nfmark routing in OUTPUT, mangle, NFQUEUE Patrick McHardy
                   ` (5 subsequent siblings)
  30 siblings, 0 replies; 46+ messages in thread
From: Patrick McHardy @ 2008-11-27 16:15 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy, netfilter-devel

commit 4813eadf6b17caa7fcce67ac2f929a3dd5178fa2
Author: Patrick McHardy <kaber@trash.net>
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.
    
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/net/netfilter/nf_conntrack_ftp.c b/net/netfilter/nf_conntrack_ftp.c
index 703a437..867cad6 100644
--- a/net/netfilter/nf_conntrack_ftp.c
+++ b/net/netfilter/nf_conntrack_ftp.c
@@ -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 */

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* netfilter 26/29: nfmark routing in OUTPUT, mangle, NFQUEUE
  2008-11-27 16:15 netfilter 00/29: Netfilter Update Patrick McHardy
                   ` (24 preceding siblings ...)
  2008-11-27 16:15 ` netfilter 25/29: nf_conntrack_ftp: change "partial ..." message to pr_debug() Patrick McHardy
@ 2008-11-27 16:15 ` Patrick McHardy
  2008-11-27 16:15 ` netfilter 27/29: nfmark IPV6 " Patrick McHardy
                   ` (4 subsequent siblings)
  30 siblings, 0 replies; 46+ messages in thread
From: Patrick McHardy @ 2008-11-27 16:15 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy, netfilter-devel

commit 5f145e44ae09f629d25536b2947a91e9c01bddcb
Author: Eric Leblond <eric@inl.fr>
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 <laurent@licour.com>
    Signed-off-by: Eric Leblond <eric@inl.fr>
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/net/ipv4/netfilter.c b/net/ipv4/netfilter.c
index 6efdb70..7c145d7 100644
--- a/net/ipv4/netfilter.c
+++ b/net/ipv4/netfilter.c
@@ -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);

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* netfilter 27/29: nfmark IPV6 routing in OUTPUT, mangle, NFQUEUE
  2008-11-27 16:15 netfilter 00/29: Netfilter Update Patrick McHardy
                   ` (25 preceding siblings ...)
  2008-11-27 16:15 ` netfilter 26/29: nfmark routing in OUTPUT, mangle, NFQUEUE Patrick McHardy
@ 2008-11-27 16:15 ` Patrick McHardy
  2008-11-27 16:15 ` netfilter 28/29: fix warning in net/netfilter/nf_conntrack_proto_tcp.c Patrick McHardy
                   ` (3 subsequent siblings)
  30 siblings, 0 replies; 46+ messages in thread
From: Patrick McHardy @ 2008-11-27 16:15 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy, netfilter-devel

commit 9f40ac713c49fb6ca655550b620edc85c445d743
Author: Eric Leblond <eric@inl.fr>
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.
    
    Signed-off-by: Eric Leblond <eric@inl.fr>
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/net/ipv6/netfilter.c b/net/ipv6/netfilter.c
index fd5b3a4..0b88c56 100644
--- a/net/ipv6/netfilter.c
+++ b/net/ipv6/netfilter.c
@@ -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;

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* netfilter 28/29: fix warning in net/netfilter/nf_conntrack_proto_tcp.c
  2008-11-27 16:15 netfilter 00/29: Netfilter Update Patrick McHardy
                   ` (26 preceding siblings ...)
  2008-11-27 16:15 ` netfilter 27/29: nfmark IPV6 " Patrick McHardy
@ 2008-11-27 16:15 ` Patrick McHardy
  2008-11-27 16:15 ` netfilter 29/29: fix warning in net/netfilter/nf_conntrack_ftp.c Patrick McHardy
                   ` (2 subsequent siblings)
  30 siblings, 0 replies; 46+ messages in thread
From: Patrick McHardy @ 2008-11-27 16:15 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy, netfilter-devel

commit 65f233fb1669e6c990cd1d7fd308ac7dc66dc207
Author: Ingo Molnar <mingo@elte.hu>
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
    
    Signed-off-by: Ingo Molnar <mingo@elte.hu>
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/include/net/netfilter/nf_conntrack_l4proto.h b/include/net/netfilter/nf_conntrack_l4proto.h
index 7f2f43c..debdaf7 100644
--- a/include/net/netfilter/nf_conntrack_l4proto.h
+++ b/include/net/netfilter/nf_conntrack_l4proto.h
@@ -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*/

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* netfilter 29/29: fix warning in net/netfilter/nf_conntrack_ftp.c
  2008-11-27 16:15 netfilter 00/29: Netfilter Update Patrick McHardy
                   ` (27 preceding siblings ...)
  2008-11-27 16:15 ` netfilter 28/29: fix warning in net/netfilter/nf_conntrack_proto_tcp.c Patrick McHardy
@ 2008-11-27 16:15 ` Patrick McHardy
  2008-11-27 16:16 ` netfilter 00/29: Netfilter Update Patrick McHardy
  2008-11-28 11:03 ` David Miller
  30 siblings, 0 replies; 46+ messages in thread
From: Patrick McHardy @ 2008-11-27 16:15 UTC (permalink / raw)
  To: davem; +Cc: netdev, Patrick McHardy, netfilter-devel

commit d6e8cc6cc7ac77b0f9118f78c453a2e834e62709
Author: Ingo Molnar <mingo@elte.hu>
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.
    
    Signed-off-by: Ingo Molnar <mingo@elte.hu>
    Signed-off-by: Patrick McHardy <kaber@trash.net>

diff --git a/net/netfilter/nf_conntrack_ftp.c b/net/netfilter/nf_conntrack_ftp.c
index 867cad6..00fecc3 100644
--- a/net/netfilter/nf_conntrack_ftp.c
+++ b/net/netfilter/nf_conntrack_ftp.c
@@ -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;

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* Re: netfilter 00/29: Netfilter Update
  2008-11-27 16:15 netfilter 00/29: Netfilter Update Patrick McHardy
                   ` (28 preceding siblings ...)
  2008-11-27 16:15 ` netfilter 29/29: fix warning in net/netfilter/nf_conntrack_ftp.c Patrick McHardy
@ 2008-11-27 16:16 ` Patrick McHardy
  2008-11-28 11:03 ` David Miller
  30 siblings, 0 replies; 46+ messages in thread
From: Patrick McHardy @ 2008-11-27 16:16 UTC (permalink / raw)
  To: davem; +Cc: netdev, netfilter-devel

[-- Attachment #1: Type: text/plain, Size: 293 bytes --]

Patrick McHardy wrote:
> 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:


[-- Attachment #2: conflict.diff --]
[-- Type: text/x-patch, Size: 1483 bytes --]

commit dbfaaa37cdfb579e317e2498eb2fc634be178761
Merge: 5b9ab2e... d6e8cc6...
Author: Patrick McHardy <kaber@trash.net>
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

diff --cc net/netfilter/nf_conntrack_netlink.c
index 5f4a651,ccc5ef1..a0c9bc4
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@@ -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);
  

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: netfilter 07/29: netns ebtables: ebtable_broute in netns
  2008-11-27 16:15 ` netfilter 07/29: netns ebtables: ebtable_broute in netns Patrick McHardy
@ 2008-11-27 18:25   ` Jan Engelhardt
  2008-11-27 18:28     ` Patrick McHardy
  0 siblings, 1 reply; 46+ messages in thread
From: Jan Engelhardt @ 2008-11-27 18:25 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: davem, netdev, netfilter-devel


On Thursday 2008-11-27 17:15, Patrick McHardy wrote:

>commit 8157e6d16af86e4a8d31a035db7be02a8a171c26
>Author: Alexey Dobriyan <adobriyan@gmail.com>
>Date:   Tue Nov 4 14:29:03 2008 +0100
>
>    netfilter: netns ebtables: ebtable_broute in netns
>    
>    Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
>    Signed-off-by: Patrick McHardy <kaber@trash.net>
>
>diff --git a/include/net/netns/x_tables.h b/include/net/netns/x_tables.h
>index b809397..055e684 100644
>--- a/include/net/netns/x_tables.h
>+++ b/include/net/netns/x_tables.h
>@@ -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].


^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: netfilter 07/29: netns ebtables: ebtable_broute in netns
  2008-11-27 18:25   ` Jan Engelhardt
@ 2008-11-27 18:28     ` Patrick McHardy
  2008-11-28  8:02       ` Alexey Dobriyan
  0 siblings, 1 reply; 46+ messages in thread
From: Patrick McHardy @ 2008-11-27 18:28 UTC (permalink / raw)
  To: Jan Engelhardt; +Cc: davem, netdev, netfilter-devel, Alexey Dobriyan

[CCed Alexey]

Jan Engelhardt wrote:
> On Thursday 2008-11-27 17:15, Patrick McHardy wrote:
> 
>> commit 8157e6d16af86e4a8d31a035db7be02a8a171c26
>> Author: Alexey Dobriyan <adobriyan@gmail.com>
>> Date:   Tue Nov 4 14:29:03 2008 +0100
>>
>>    netfilter: netns ebtables: ebtable_broute in netns
>>    
>>    Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
>>    Signed-off-by: Patrick McHardy <kaber@trash.net>
>>
>> diff --git a/include/net/netns/x_tables.h b/include/net/netns/x_tables.h
>> index b809397..055e684 100644
>> --- a/include/net/netns/x_tables.h
>> +++ b/include/net/netns/x_tables.h
>> @@ -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].


^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: netfilter 11/29: nf_nat: remove warn_if_extra_mangle
  2008-11-27 16:15 ` netfilter 11/29: nf_nat: remove warn_if_extra_mangle Patrick McHardy
@ 2008-11-27 18:28   ` Jan Engelhardt
  0 siblings, 0 replies; 46+ messages in thread
From: Jan Engelhardt @ 2008-11-27 18:28 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: davem, netdev, netfilter-devel


On Thursday 2008-11-27 17:15, Patrick McHardy wrote:

>    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.

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.

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: netfilter 15/29: nf_conntrack: connection tracking helper name persistent aliases
  2008-11-27 16:15 ` netfilter 15/29: nf_conntrack: connection tracking helper name persistent aliases Patrick McHardy
@ 2008-11-27 18:31   ` Jan Engelhardt
  2008-11-27 18:33     ` Patrick McHardy
  0 siblings, 1 reply; 46+ messages in thread
From: Jan Engelhardt @ 2008-11-27 18:31 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: davem, netdev, netfilter-devel


On Thursday 2008-11-27 17:15, Patrick McHardy wrote:
>    
>    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.

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: netfilter 15/29: nf_conntrack: connection tracking helper name persistent aliases
  2008-11-27 18:31   ` Jan Engelhardt
@ 2008-11-27 18:33     ` Patrick McHardy
  2008-11-27 18:34       ` Jan Engelhardt
  0 siblings, 1 reply; 46+ messages in thread
From: Patrick McHardy @ 2008-11-27 18:33 UTC (permalink / raw)
  To: Jan Engelhardt; +Cc: davem, netdev, netfilter-devel

Jan Engelhardt wrote:
> On Thursday 2008-11-27 17:15, Patrick McHardy wrote:
>>    
>>    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.
>

Please CC the people that can actually answer this question.

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: netfilter 23/29: ip{,6}t_policy.h should include xp_policy.h
  2008-11-27 16:15 ` netfilter 23/29: ip{,6}t_policy.h should include xp_policy.h Patrick McHardy
@ 2008-11-27 18:33   ` Jan Engelhardt
  2008-11-27 23:06     ` David Miller
  2008-11-28  8:58     ` Andy Whitcroft
  0 siblings, 2 replies; 46+ messages in thread
From: Jan Engelhardt @ 2008-11-27 18:33 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: Netfilter Developer Mailing List, apw


On Thursday 2008-11-27 17:15, Patrick McHardy wrote:

>commit 018a7bf1e55000dd792194238c9043918d24d3dd
>Author: Andy Whitcroft <apw@canonical.com>
>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 ;-)

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: netfilter 15/29: nf_conntrack: connection tracking helper name persistent aliases
  2008-11-27 18:33     ` Patrick McHardy
@ 2008-11-27 18:34       ` Jan Engelhardt
  2008-11-27 21:52         ` Pablo Neira Ayuso
  0 siblings, 1 reply; 46+ messages in thread
From: Jan Engelhardt @ 2008-11-27 18:34 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: Netfilter Developer Mailing List, pablo

[cc morphed to more interested parties]

On Thursday 2008-11-27 19:33, Patrick McHardy wrote:

> Jan Engelhardt wrote:
>> On Thursday 2008-11-27 17:15, Patrick McHardy wrote:
>> >    
>> >    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.
>>
>
> Please CC the people that can actually answer this question.
>
Please set CC when running git-send-email :)

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: netfilter 15/29: nf_conntrack: connection tracking helper name persistent aliases
  2008-11-27 18:34       ` Jan Engelhardt
@ 2008-11-27 21:52         ` Pablo Neira Ayuso
  2008-11-27 22:14           ` Jan Engelhardt
  0 siblings, 1 reply; 46+ messages in thread
From: Pablo Neira Ayuso @ 2008-11-27 21:52 UTC (permalink / raw)
  To: Jan Engelhardt; +Cc: Patrick McHardy, Netfilter Developer Mailing List

Jan Engelhardt wrote:
> [cc morphed to more interested parties]
> 
> On Thursday 2008-11-27 19:33, Patrick McHardy wrote:
> 
>> Jan Engelhardt wrote:
>>> On Thursday 2008-11-27 17:15, Patrick McHardy wrote:
>>>>    
>>>>    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.

>> Please CC the people that can actually answer this question.
>>
> Please set CC when running git-send-email :)

Burp!

-- 
"Los honestos son inadaptados sociales" -- Les Luthiers

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: netfilter 15/29: nf_conntrack: connection tracking helper name persistent aliases
  2008-11-27 21:52         ` Pablo Neira Ayuso
@ 2008-11-27 22:14           ` Jan Engelhardt
  2008-11-28  7:15             ` Patrick McHardy
  0 siblings, 1 reply; 46+ messages in thread
From: Jan Engelhardt @ 2008-11-27 22:14 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: Patrick McHardy, Netfilter Developer Mailing List


On Thursday 2008-11-27 22:52, Pablo Neira Ayuso wrote:
>> 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..

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: netfilter 23/29: ip{,6}t_policy.h should include xp_policy.h
  2008-11-27 18:33   ` Jan Engelhardt
@ 2008-11-27 23:06     ` David Miller
  2008-11-28  8:58     ` Andy Whitcroft
  1 sibling, 0 replies; 46+ messages in thread
From: David Miller @ 2008-11-27 23:06 UTC (permalink / raw)
  To: jengelh; +Cc: kaber, netfilter-devel, apw


Can you _PLEASE_ stop dropping netdev from the CC: list?!?!?

Doing that SCREWS UP EVERYTHING with how we log patches and their
followup discussion at:

	http://patchwork.ozlabs.org/project/netdev/list/

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: netfilter 15/29: nf_conntrack: connection tracking helper name persistent aliases
  2008-11-27 22:14           ` Jan Engelhardt
@ 2008-11-28  7:15             ` Patrick McHardy
  2008-11-28 11:39               ` Jan Engelhardt
  0 siblings, 1 reply; 46+ messages in thread
From: Patrick McHardy @ 2008-11-28  7:15 UTC (permalink / raw)
  To: Jan Engelhardt; +Cc: Pablo Neira Ayuso, Netfilter Developer Mailing List

Jan Engelhardt wrote:
> On Thursday 2008-11-27 22:52, Pablo Neira Ayuso wrote:
>>> 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..

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


^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: netfilter 07/29: netns ebtables: ebtable_broute in netns
  2008-11-27 18:28     ` Patrick McHardy
@ 2008-11-28  8:02       ` Alexey Dobriyan
  0 siblings, 0 replies; 46+ messages in thread
From: Alexey Dobriyan @ 2008-11-28  8:02 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: Jan Engelhardt, davem, netdev, netfilter-devel

On Thu, Nov 27, 2008 at 07:28:04PM +0100, Patrick McHardy wrote:
> [CCed Alexey]
>
> Jan Engelhardt wrote:
>> On Thursday 2008-11-27 17:15, Patrick McHardy wrote:
>>
>>> commit 8157e6d16af86e4a8d31a035db7be02a8a171c26
>>> Author: Alexey Dobriyan <adobriyan@gmail.com>
>>> Date:   Tue Nov 4 14:29:03 2008 +0100
>>>
>>>    netfilter: netns ebtables: ebtable_broute in netns
>>>       Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
>>>    Signed-off-by: Patrick McHardy <kaber@trash.net>
>>>
>>> diff --git a/include/net/netns/x_tables.h b/include/net/netns/x_tables.h
>>> index b809397..055e684 100644
>>> --- a/include/net/netns/x_tables.h
>>> +++ b/include/net/netns/x_tables.h
>>> @@ -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.

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: netfilter 23/29: ip{,6}t_policy.h should include xp_policy.h
  2008-11-27 18:33   ` Jan Engelhardt
  2008-11-27 23:06     ` David Miller
@ 2008-11-28  8:58     ` Andy Whitcroft
  1 sibling, 0 replies; 46+ messages in thread
From: Andy Whitcroft @ 2008-11-28  8:58 UTC (permalink / raw)
  To: Jan Engelhardt; +Cc: Patrick McHardy, Netfilter Developer Mailing List

On Thu, Nov 27, 2008 at 07:33:39PM +0100, Jan Engelhardt wrote:
> 
> On Thursday 2008-11-27 17:15, Patrick McHardy wrote:
> 
> >commit 018a7bf1e55000dd792194238c9043918d24d3dd
> >Author: Andy Whitcroft <apw@canonical.com>
> >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

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: netfilter 00/29: Netfilter Update
  2008-11-27 16:15 netfilter 00/29: Netfilter Update Patrick McHardy
                   ` (29 preceding siblings ...)
  2008-11-27 16:16 ` netfilter 00/29: Netfilter Update Patrick McHardy
@ 2008-11-28 11:03 ` David Miller
  30 siblings, 0 replies; 46+ messages in thread
From: David Miller @ 2008-11-28 11:03 UTC (permalink / raw)
  To: kaber; +Cc: netdev, netfilter-devel

From: Patrick McHardy <kaber@trash.net>
Date: Thu, 27 Nov 2008 17:15:03 +0100 (MET)

> 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

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

^ permalink raw reply	[flat|nested] 46+ messages in thread

* Re: netfilter 15/29: nf_conntrack: connection tracking helper name persistent aliases
  2008-11-28  7:15             ` Patrick McHardy
@ 2008-11-28 11:39               ` Jan Engelhardt
  0 siblings, 0 replies; 46+ messages in thread
From: Jan Engelhardt @ 2008-11-28 11:39 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: Pablo Neira Ayuso, Netfilter Developer Mailing List


On Friday 2008-11-28 08:15, Patrick McHardy wrote:
> Jan Engelhardt wrote:
>> On Thursday 2008-11-27 22:52, Pablo Neira Ayuso wrote:
>> > > 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..
>
> 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))

^ permalink raw reply	[flat|nested] 46+ messages in thread

end of thread, other threads:[~2008-11-28 11:39 UTC | newest]

Thread overview: 46+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-27 16:15 netfilter 00/29: Netfilter Update Patrick McHardy
2008-11-27 16:15 ` netfilter 01/29: xt_NFLOG: don't call nf_log_packet in NFLOG module Patrick McHardy
2008-11-27 16:15 ` netfilter 02/29: netns-aware ipt_addrtype Patrick McHardy
2008-11-27 16:15 ` netfilter 03/29: arptable_filter: merge forward hook Patrick McHardy
2008-11-27 16:15 ` netfilter 04/29: netns ebtables: part 1 Patrick McHardy
2008-11-27 16:15 ` netfilter 05/29: netns ebtables: part 2 Patrick McHardy
2008-11-27 16:15 ` netfilter 06/29: netns ebtables: more cleanup during ebt_unregister_table() Patrick McHardy
2008-11-27 16:15 ` netfilter 07/29: netns ebtables: ebtable_broute in netns Patrick McHardy
2008-11-27 18:25   ` Jan Engelhardt
2008-11-27 18:28     ` Patrick McHardy
2008-11-28  8:02       ` Alexey Dobriyan
2008-11-27 16:15 ` netfilter 08/29: netns ebtables: ebtable_filter " Patrick McHardy
2008-11-27 16:15 ` netfilter 09/29: netns ebtables: ebtable_nat " Patrick McHardy
2008-11-27 16:15 ` netfilter 10/29: netns ebtables: br_nf_pre_routing_finish() fixup Patrick McHardy
2008-11-27 16:15 ` netfilter 11/29: nf_nat: remove warn_if_extra_mangle Patrick McHardy
2008-11-27 18:28   ` Jan Engelhardt
2008-11-27 16:15 ` netfilter 12/29: ctnetlink: use nf_conntrack_get instead of atomic_inc Patrick McHardy
2008-11-27 16:15 ` netfilter 13/29: ctnetlink: use EOPNOTSUPP instead of EINVAL if the conntrack has no helper Patrick McHardy
2008-11-27 16:15 ` netfilter 14/29: ctnetlink: get rid of module refcounting in ctnetlink Patrick McHardy
2008-11-27 16:15 ` netfilter 15/29: nf_conntrack: connection tracking helper name persistent aliases Patrick McHardy
2008-11-27 18:31   ` Jan Engelhardt
2008-11-27 18:33     ` Patrick McHardy
2008-11-27 18:34       ` Jan Engelhardt
2008-11-27 21:52         ` Pablo Neira Ayuso
2008-11-27 22:14           ` Jan Engelhardt
2008-11-28  7:15             ` Patrick McHardy
2008-11-28 11:39               ` Jan Engelhardt
2008-11-27 16:15 ` netfilter 16/29: ctnetlink: helper modules load-on-demand support Patrick McHardy
2008-11-27 16:15 ` netfilter 17/29: ctnetlink: deliver events for conntracks changed from userspace Patrick McHardy
2008-11-27 16:15 ` netfilter 18/29: nfnetlink_log: fix warning and prototype mismatch Patrick McHardy
2008-11-27 16:15 ` netfilter 19/29: nf_conntrack: " Patrick McHardy
2008-11-27 16:15 ` netfilter 20/29: xt_recent: don't save proc dirs Patrick McHardy
2008-11-27 16:15 ` netfilter 21/29: ip6table_filter: merge LOCAL_IN and FORWARD hooks Patrick McHardy
2008-11-27 16:15 ` netfilter 22/29: nf_conntrack_proto_gre: spread __exit Patrick McHardy
2008-11-27 16:15 ` netfilter 23/29: ip{,6}t_policy.h should include xp_policy.h Patrick McHardy
2008-11-27 18:33   ` Jan Engelhardt
2008-11-27 23:06     ` David Miller
2008-11-28  8:58     ` Andy Whitcroft
2008-11-27 16:15 ` netfilter 24/29: nf_conntrack_proto_sctp: avoid bogus warning Patrick McHardy
2008-11-27 16:15 ` netfilter 25/29: nf_conntrack_ftp: change "partial ..." message to pr_debug() Patrick McHardy
2008-11-27 16:15 ` netfilter 26/29: nfmark routing in OUTPUT, mangle, NFQUEUE Patrick McHardy
2008-11-27 16:15 ` netfilter 27/29: nfmark IPV6 " Patrick McHardy
2008-11-27 16:15 ` netfilter 28/29: fix warning in net/netfilter/nf_conntrack_proto_tcp.c Patrick McHardy
2008-11-27 16:15 ` netfilter 29/29: fix warning in net/netfilter/nf_conntrack_ftp.c Patrick McHardy
2008-11-27 16:16 ` netfilter 00/29: Netfilter Update Patrick McHardy
2008-11-28 11:03 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).