Re: [RFC 2/4] net: netfilter conntrack - add per-net functionality for DCCP protocol

Previous thread: [RFC 3/4] net: netfilter conntrack - add per-net functionality for SCTP protocol by Cyrill Gorcunov on Monday, March 9, 2009 - 11:16 am. (2 messages)

Next thread: none
From: Cyrill Gorcunov
Date: Monday, March 9, 2009 - 11:16 am

Module specific data moved into per-net site and being allocated/freed
during net namespace creation/deletion.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
---
 net/netfilter/nf_conntrack_proto_dccp.c |  148 ++++++++++++++++++++++++--------
 1 file changed, 111 insertions(+), 37 deletions(-)

Index: linux-2.6.git/net/netfilter/nf_conntrack_proto_dccp.c
===================================================================
--- linux-2.6.git.orig/net/netfilter/nf_conntrack_proto_dccp.c
+++ linux-2.6.git/net/netfilter/nf_conntrack_proto_dccp.c
@@ -16,6 +16,9 @@
 #include <linux/skbuff.h>
 #include <linux/dccp.h>
 
+#include <net/net_namespace.h>
+#include <net/netns/generic.h>
+
 #include <linux/netfilter/nfnetlink_conntrack.h>
 #include <net/netfilter/nf_conntrack.h>
 #include <net/netfilter/nf_conntrack_l4proto.h>
@@ -23,8 +26,6 @@
 
 static DEFINE_RWLOCK(dccp_lock);
 
-static int nf_ct_dccp_loose __read_mostly = 1;
-
 /* Timeouts are based on values from RFC4340:
  *
  * - REQUEST:
@@ -72,16 +73,6 @@ static int nf_ct_dccp_loose __read_mostl
 
 #define DCCP_MSL (2 * 60 * HZ)
 
-static unsigned int dccp_timeout[CT_DCCP_MAX + 1] __read_mostly = {
-	[CT_DCCP_REQUEST]	= 2 * DCCP_MSL,
-	[CT_DCCP_RESPOND]	= 4 * DCCP_MSL,
-	[CT_DCCP_PARTOPEN]	= 4 * DCCP_MSL,
-	[CT_DCCP_OPEN]		= 12 * 3600 * HZ,
-	[CT_DCCP_CLOSEREQ]	= 64 * HZ,
-	[CT_DCCP_CLOSING]	= 64 * HZ,
-	[CT_DCCP_TIMEWAIT]	= 2 * DCCP_MSL,
-};
-
 static const char * const dccp_state_names[] = {
 	[CT_DCCP_NONE]		= "NONE",
 	[CT_DCCP_REQUEST]	= "REQUEST",
@@ -393,6 +384,22 @@ dccp_state_table[CT_DCCP_ROLE_MAX + 1][D
 	},
 };
 
+/* this module per-net specifics */
+static int dccp_net_id;
+struct dccp_net {
+	int dccp_loose;
+	unsigned int dccp_timeout[CT_DCCP_MAX + 1];
+#ifdef CONFIG_SYSCTL
+	struct ctl_table_header *sysctl_header;
+	struct ctl_table *sysctl_table;
+#endif
+};
+
+static inline struct dccp_net *dccp_pernet(struct net *net)
+{
+	return net_generic(net, dccp_net_id);
+}
+
 static ...
From: Daniel Lezcano
Date: Tuesday, March 10, 2009 - 3:33 am

If you use register_pernet_gen_device, your subsystem will be deleted 
before the network devices and potentially you can receive a packet even 
if your subsystem is already freed.

Eric did a fix for tcp and icmp a few weeks ago. I thing its explanation 
is better than mine :)
it is the commit 6eb0777228f31932fc941eafe8b08848466630a1 for net-2.6

Thanks.
  -- Daniel
--

From: Cyrill Gorcunov
Date: Tuesday, March 10, 2009 - 3:59 am

No, I believe. By using  register_pernet_gen_device I'm allowed to
not modify 'struct net' and friends and keep all I need in my own

Thanks a lot Daniel, will check!
--

From: Pavel Emelyanov
Date: Tuesday, March 10, 2009 - 4:35 am

I believe Daniel means, that we need the register_xxx_get_subsys call
for subsystems, rather than devices, that will behave according to the
generic net pointers.


--

From: Cyrill Gorcunov
Date: Tuesday, March 10, 2009 - 4:51 am

On Tue, Mar 10, 2009 at 2:35 PM, Pavel Emelyanov <xemul@openvz.org> wrote:
...
Ah, yes, just checked register_pernet_gen_subsys -- it's what I need. Thanks!
--

From: Pavel Emelyanov
Date: Tuesday, March 10, 2009 - 4:56 am

Good. This would require some factorization work as well. Cyrill, your turn ;)
--

From: Daniel Lezcano
Date: Tuesday, March 10, 2009 - 5:43 am

Correct, otherwise that can lead to a kernel panic if you receive a 
You are welcome :)

  -- Daniel
--

From: David Miller
Date: Tuesday, March 10, 2009 - 4:25 am

From: Daniel Lezcano <daniel.lezcano@free.fr>

Do I really have to carefully and meticuliously scan down
hundreds and hundreds of irrelevant quoted patch text just
to see what bit you're commenting on?

Please, just provide the necessary context of the patch for
your comments, don't quote the whole thing :-(

Thanks.
--

From: Daniel Lezcano
Date: Tuesday, March 10, 2009 - 6:02 am

Sorry, I will do that in the future.

  -- Daniel
--

Previous thread: [RFC 3/4] net: netfilter conntrack - add per-net functionality for SCTP protocol by Cyrill Gorcunov on Monday, March 9, 2009 - 11:16 am. (2 messages)

Next thread: none