Patchwork [nf-next,06/11] netfilter: timeout: move initial codes out of pernet_operations

login
register
mail settings
Submitter Gao feng
Date Jan. 22, 2013, 8:10 a.m.
Message ID <1358842234-15005-6-git-send-email-gaofeng@cn.fujitsu.com>
Download mbox | patch
Permalink /patch/214443/
State Accepted
Headers show

Comments

Gao feng - Jan. 22, 2013, 8:10 a.m.
Move the global initial codes to the module_init/exit context.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
---
 include/net/netfilter/nf_conntrack_timeout.h |  8 ++++----
 net/netfilter/nf_conntrack_core.c            | 15 ++++++++-------
 net/netfilter/nf_conntrack_timeout.c         | 23 +++++++----------------
 3 files changed, 19 insertions(+), 27 deletions(-)
Pablo Neira - Jan. 23, 2013, 1:13 p.m.
On Tue, Jan 22, 2013 at 04:10:29PM +0800, Gao feng wrote:
> Move the global initial codes to the module_init/exit context.

I hit a compilation error:

net/netfilter/nf_conntrack_timeout.c: In function ‘nf_conntrack_timeout_init’:
net/netfilter/nf_conntrack_timeout.c:48:1: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
net/netfilter/nf_conntrack_timeout.c:51:1: error: expected declaration or statement at end of input
net/netfilter/nf_conntrack_timeout.c:51:1: warning: control reaches end of non-void function [-Wreturn-type]

int nf_conntrack_timeout_init(void)
{
        int ret = nf_ct_extend_register(&timeout_extend);
        if (ret < 0) {
                pr_err("nf_ct_timeout: Unable to register timeout extension.\n");
        return ret;
}

Unbalanced bracket.

I have fixed this myself and I have applied it to nf-next. Please,
next time make sure you have selected all conntrack / netfilter
modules in your .config file.

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Gao feng - Jan. 24, 2013, 12:43 a.m.
On 2013/01/23 21:13, Pablo Neira Ayuso wrote:
> On Tue, Jan 22, 2013 at 04:10:29PM +0800, Gao feng wrote:
>> Move the global initial codes to the module_init/exit context.
> 
> I hit a compilation error:
> 
> net/netfilter/nf_conntrack_timeout.c: In function ‘nf_conntrack_timeout_init’:
> net/netfilter/nf_conntrack_timeout.c:48:1: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
> net/netfilter/nf_conntrack_timeout.c:51:1: error: expected declaration or statement at end of input
> net/netfilter/nf_conntrack_timeout.c:51:1: warning: control reaches end of non-void function [-Wreturn-type]
> 
> int nf_conntrack_timeout_init(void)
> {
>         int ret = nf_ct_extend_register(&timeout_extend);
>         if (ret < 0) {
>                 pr_err("nf_ct_timeout: Unable to register timeout extension.\n");
>         return ret;
> }
> 
> Unbalanced bracket.
> 
> I have fixed this myself and I have applied it to nf-next. Please,
> next time make sure you have selected all conntrack / netfilter
> modules in your .config file.
>

I'm sorry.will take care of it next time. :)

Thanks!
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/include/net/netfilter/nf_conntrack_timeout.h b/include/net/netfilter/nf_conntrack_timeout.h
index e41e472..d23aceb 100644
--- a/include/net/netfilter/nf_conntrack_timeout.h
+++ b/include/net/netfilter/nf_conntrack_timeout.h
@@ -76,15 +76,15 @@  nf_ct_timeout_lookup(struct net *net, struct nf_conn *ct,
 }
 
 #ifdef CONFIG_NF_CONNTRACK_TIMEOUT
-extern int nf_conntrack_timeout_init(struct net *net);
-extern void nf_conntrack_timeout_fini(struct net *net);
+extern int nf_conntrack_timeout_init(void);
+extern void nf_conntrack_timeout_fini(void);
 #else
-static inline int nf_conntrack_timeout_init(struct net *net)
+static inline int nf_conntrack_timeout_init(void)
 {
         return 0;
 }
 
-static inline void nf_conntrack_timeout_fini(struct net *net)
+static inline void nf_conntrack_timeout_fini(void)
 {
         return;
 }
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 048fe77..4f4d107 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -1348,6 +1348,7 @@  void nf_conntrack_cleanup_end(void)
 #ifdef CONFIG_NF_CONNTRACK_ZONES
 	nf_ct_extend_unregister(&nf_ct_zone_extend);
 #endif
+	nf_conntrack_timeout_fini();
 	nf_conntrack_ecache_fini();
 	nf_conntrack_tstamp_fini();
 	nf_conntrack_acct_fini();
@@ -1378,7 +1379,6 @@  void nf_conntrack_cleanup_net(struct net *net)
 	nf_conntrack_proto_fini(net);
 	nf_conntrack_labels_fini(net);
 	nf_conntrack_helper_fini(net);
-	nf_conntrack_timeout_fini(net);
 	nf_conntrack_ecache_pernet_fini(net);
 	nf_conntrack_tstamp_pernet_fini(net);
 	nf_conntrack_acct_pernet_fini(net);
@@ -1522,6 +1522,10 @@  int nf_conntrack_init_start(void)
 	if (ret < 0)
 		goto err_ecache;
 
+	ret = nf_conntrack_timeout_init();
+	if (ret < 0)
+		goto err_timeout;
+
 #ifdef CONFIG_NF_CONNTRACK_ZONES
 	ret = nf_ct_extend_register(&nf_ct_zone_extend);
 	if (ret < 0)
@@ -1539,8 +1543,10 @@  int nf_conntrack_init_start(void)
 
 #ifdef CONFIG_NF_CONNTRACK_ZONES
 err_extend:
-	nf_conntrack_ecache_fini();
+	nf_conntrack_timeout_fini();
 #endif
+err_timeout:
+	nf_conntrack_ecache_fini();
 err_ecache:
 	nf_conntrack_tstamp_fini();
 err_tstamp:
@@ -1616,9 +1622,6 @@  int nf_conntrack_init_net(struct net *net)
 	ret = nf_conntrack_ecache_pernet_init(net);
 	if (ret < 0)
 		goto err_ecache;
-	ret = nf_conntrack_timeout_init(net);
-	if (ret < 0)
-		goto err_timeout;
 	ret = nf_conntrack_helper_init(net);
 	if (ret < 0)
 		goto err_helper;
@@ -1637,8 +1640,6 @@  err_proto:
 err_labels:
 	nf_conntrack_helper_fini(net);
 err_helper:
-	nf_conntrack_timeout_fini(net);
-err_timeout:
 	nf_conntrack_ecache_pernet_fini(net);
 err_ecache:
 	nf_conntrack_tstamp_pernet_fini(net);
diff --git a/net/netfilter/nf_conntrack_timeout.c b/net/netfilter/nf_conntrack_timeout.c
index a878ce5..1a2248b 100644
--- a/net/netfilter/nf_conntrack_timeout.c
+++ b/net/netfilter/nf_conntrack_timeout.c
@@ -37,24 +37,15 @@  static struct nf_ct_ext_type timeout_extend __read_mostly = {
 	.id	= NF_CT_EXT_TIMEOUT,
 };
 
-int nf_conntrack_timeout_init(struct net *net)
+int nf_conntrack_timeout_init(void)
 {
-	int ret = 0;
-
-	if (net_eq(net, &init_net)) {
-		ret = nf_ct_extend_register(&timeout_extend);
-		if (ret < 0) {
-			printk(KERN_ERR "nf_ct_timeout: Unable to register "
-					"timeout extension.\n");
-			return ret;
-		}
-	}
-
-	return 0;
+	int ret = nf_ct_extend_register(&timeout_extend);
+	if (ret < 0) {
+		pr_err("nf_ct_timeout: Unable to register timeout extension.\n");
+	return ret;
 }
 
-void nf_conntrack_timeout_fini(struct net *net)
+void nf_conntrack_timeout_fini(void)
 {
-	if (net_eq(net, &init_net))
-		nf_ct_extend_unregister(&timeout_extend);
+	nf_ct_extend_unregister(&timeout_extend);
 }