Re: [RFC v2 7/7] net: netfilter conntrack - add per-net functionality for ICMP protocol

Previous thread: [RFC v2 6/7] net: netfilter conntrack - add per-net functionality for UDP protocol by Cyrill Gorcunov on Wednesday, March 11, 2009 - 1:57 pm. (2 messages)

Next thread: [RFC v2 5/7] net: netfilter conntrack - add per-net functionality for TCP protocol by Cyrill Gorcunov on Wednesday, March 11, 2009 - 1:57 pm. (7 messages)
From: Cyrill Gorcunov
Date: Wednesday, March 11, 2009 - 1:57 pm

Module specific data moved into per-net site and being allocated/freed
during net namespace creation/deletion. For this reason module_init/exit
calls added.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
---
 net/ipv4/netfilter/nf_conntrack_proto_icmp.c |  128 +++++++++++++++++++++++++--
 1 file changed, 120 insertions(+), 8 deletions(-)

Index: linux-2.6.git/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
===================================================================
--- linux-2.6.git.orig/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
+++ linux-2.6.git/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
@@ -9,6 +9,7 @@
 #include <linux/types.h>
 #include <linux/timer.h>
 #include <linux/netfilter.h>
+#include <linux/module.h>
 #include <linux/in.h>
 #include <linux/icmp.h>
 #include <linux/seq_file.h>
@@ -20,7 +21,27 @@
 #include <net/netfilter/nf_conntrack_core.h>
 #include <net/netfilter/nf_log.h>
 
-static unsigned int nf_ct_icmp_timeout __read_mostly = 30*HZ;
+#include <net/net_namespace.h>
+#include <net/netns/generic.h>
+
+/* per-net specifics */
+static int icmp_net_id;
+struct icmp_net {
+	unsigned int icmp_timeout;
+#ifdef CONFIG_SYSCTL
+	struct ctl_table_header *sysctl_header;
+	struct ctl_table *sysctl_table;
+#ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
+	struct ctl_table_header *compat_sysctl_header;
+	struct ctl_table *compat_sysctl_table;
+#endif
+#endif
+};
+
+static inline struct icmp_net *icmp_pernet(struct net *net)
+{
+	return net_generic(net, icmp_net_id);
+}
 
 static bool icmp_pkt_to_tuple(const struct sk_buff *skb, unsigned int dataoff,
 			      struct nf_conntrack_tuple *tuple)
@@ -90,9 +111,10 @@ static int icmp_packet(struct nf_conn *c
 		if (atomic_dec_and_test(&ct->proto.icmp.count))
 			nf_ct_kill_acct(ct, ctinfo, skb);
 	} else {
+		struct icmp_net *in = icmp_pernet(nf_ct_net(ct));
 		atomic_inc(&ct->proto.icmp.count);
 		nf_conntrack_event_cache(IPCT_PROTOINFO_VOLATILE, ct);
-		nf_ct_refresh_acct(ct, ctinfo, skb, ...
From: Daniel Lezcano
Date: Thursday, March 12, 2009 - 2:51 am

Acked-by: Daniel Lezcano <daniel.lezcano@free.fr>
--

Previous thread: [RFC v2 6/7] net: netfilter conntrack - add per-net functionality for UDP protocol by Cyrill Gorcunov on Wednesday, March 11, 2009 - 1:57 pm. (2 messages)

Next thread: [RFC v2 5/7] net: netfilter conntrack - add per-net functionality for TCP protocol by Cyrill Gorcunov on Wednesday, March 11, 2009 - 1:57 pm. (7 messages)