aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGao feng <gaofeng@cn.fujitsu.com>2013-01-21 17:10:28 -0500
committerPablo Neira Ayuso <pablo@netfilter.org>2013-01-23 06:55:50 -0500
commit3fe0f943d4f52f875f0fdf8dbe472c8a9b852891 (patch)
treedc2bde810da925172a0b8253a3df360005abd916
parent73f4001a52c986114f540504d70b21e52eb0d92a (diff)
netfilter: nf_ct_ecache: move initialization out of pernet_operations
Move the global initial codes to the module_init/exit context. Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r--include/net/netfilter/nf_conntrack_ecache.h19
-rw-r--r--net/netfilter/nf_conntrack_core.c15
-rw-r--r--net/netfilter/nf_conntrack_ecache.c37
3 files changed, 39 insertions, 32 deletions
diff --git a/include/net/netfilter/nf_conntrack_ecache.h b/include/net/netfilter/nf_conntrack_ecache.h
index 5654d292efd4..092dc651689f 100644
--- a/include/net/netfilter/nf_conntrack_ecache.h
+++ b/include/net/netfilter/nf_conntrack_ecache.h
@@ -207,9 +207,11 @@ nf_ct_expect_event(enum ip_conntrack_expect_events event,
207 nf_ct_expect_event_report(event, exp, 0, 0); 207 nf_ct_expect_event_report(event, exp, 0, 0);
208} 208}
209 209
210extern int nf_conntrack_ecache_init(struct net *net); 210extern int nf_conntrack_ecache_pernet_init(struct net *net);
211extern void nf_conntrack_ecache_fini(struct net *net); 211extern void nf_conntrack_ecache_pernet_fini(struct net *net);
212 212
213extern int nf_conntrack_ecache_init(void);
214extern void nf_conntrack_ecache_fini(void);
213#else /* CONFIG_NF_CONNTRACK_EVENTS */ 215#else /* CONFIG_NF_CONNTRACK_EVENTS */
214 216
215static inline void nf_conntrack_event_cache(enum ip_conntrack_events event, 217static inline void nf_conntrack_event_cache(enum ip_conntrack_events event,
@@ -232,12 +234,21 @@ static inline void nf_ct_expect_event_report(enum ip_conntrack_expect_events e,
232 u32 portid, 234 u32 portid,
233 int report) {} 235 int report) {}
234 236
235static inline int nf_conntrack_ecache_init(struct net *net) 237static inline int nf_conntrack_ecache_pernet_init(struct net *net)
236{ 238{
237 return 0; 239 return 0;
238} 240}
239 241
240static inline void nf_conntrack_ecache_fini(struct net *net) 242static inline void nf_conntrack_ecache_pernet_fini(struct net *net)
243{
244}
245
246static inline int nf_conntrack_ecache_init(void)
247{
248 return 0;
249}
250
251static inline void nf_conntrack_ecache_fini(void)
241{ 252{
242} 253}
243#endif /* CONFIG_NF_CONNTRACK_EVENTS */ 254#endif /* CONFIG_NF_CONNTRACK_EVENTS */
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 20ebfff0a47e..048fe77bf20c 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)
1348#ifdef CONFIG_NF_CONNTRACK_ZONES 1348#ifdef CONFIG_NF_CONNTRACK_ZONES
1349 nf_ct_extend_unregister(&nf_ct_zone_extend); 1349 nf_ct_extend_unregister(&nf_ct_zone_extend);
1350#endif 1350#endif
1351 nf_conntrack_ecache_fini();
1351 nf_conntrack_tstamp_fini(); 1352 nf_conntrack_tstamp_fini();
1352 nf_conntrack_acct_fini(); 1353 nf_conntrack_acct_fini();
1353 nf_conntrack_expect_fini(); 1354 nf_conntrack_expect_fini();
@@ -1378,7 +1379,7 @@ void nf_conntrack_cleanup_net(struct net *net)
1378 nf_conntrack_labels_fini(net); 1379 nf_conntrack_labels_fini(net);
1379 nf_conntrack_helper_fini(net); 1380 nf_conntrack_helper_fini(net);
1380 nf_conntrack_timeout_fini(net); 1381 nf_conntrack_timeout_fini(net);
1381 nf_conntrack_ecache_fini(net); 1382 nf_conntrack_ecache_pernet_fini(net);
1382 nf_conntrack_tstamp_pernet_fini(net); 1383 nf_conntrack_tstamp_pernet_fini(net);
1383 nf_conntrack_acct_pernet_fini(net); 1384 nf_conntrack_acct_pernet_fini(net);
1384 nf_conntrack_expect_pernet_fini(net); 1385 nf_conntrack_expect_pernet_fini(net);
@@ -1517,6 +1518,10 @@ int nf_conntrack_init_start(void)
1517 if (ret < 0) 1518 if (ret < 0)
1518 goto err_tstamp; 1519 goto err_tstamp;
1519 1520
1521 ret = nf_conntrack_ecache_init();
1522 if (ret < 0)
1523 goto err_ecache;
1524
1520#ifdef CONFIG_NF_CONNTRACK_ZONES 1525#ifdef CONFIG_NF_CONNTRACK_ZONES
1521 ret = nf_ct_extend_register(&nf_ct_zone_extend); 1526 ret = nf_ct_extend_register(&nf_ct_zone_extend);
1522 if (ret < 0) 1527 if (ret < 0)
@@ -1534,8 +1539,10 @@ int nf_conntrack_init_start(void)
1534 1539
1535#ifdef CONFIG_NF_CONNTRACK_ZONES 1540#ifdef CONFIG_NF_CONNTRACK_ZONES
1536err_extend: 1541err_extend:
1537 nf_conntrack_tstamp_fini(); 1542 nf_conntrack_ecache_fini();
1538#endif 1543#endif
1544err_ecache:
1545 nf_conntrack_tstamp_fini();
1539err_tstamp: 1546err_tstamp:
1540 nf_conntrack_acct_fini(); 1547 nf_conntrack_acct_fini();
1541err_acct: 1548err_acct:
@@ -1606,7 +1613,7 @@ int nf_conntrack_init_net(struct net *net)
1606 ret = nf_conntrack_tstamp_pernet_init(net); 1613 ret = nf_conntrack_tstamp_pernet_init(net);
1607 if (ret < 0) 1614 if (ret < 0)
1608 goto err_tstamp; 1615 goto err_tstamp;
1609 ret = nf_conntrack_ecache_init(net); 1616 ret = nf_conntrack_ecache_pernet_init(net);
1610 if (ret < 0) 1617 if (ret < 0)
1611 goto err_ecache; 1618 goto err_ecache;
1612 ret = nf_conntrack_timeout_init(net); 1619 ret = nf_conntrack_timeout_init(net);
@@ -1632,7 +1639,7 @@ err_labels:
1632err_helper: 1639err_helper:
1633 nf_conntrack_timeout_fini(net); 1640 nf_conntrack_timeout_fini(net);
1634err_timeout: 1641err_timeout:
1635 nf_conntrack_ecache_fini(net); 1642 nf_conntrack_ecache_pernet_fini(net);
1636err_ecache: 1643err_ecache:
1637 nf_conntrack_tstamp_pernet_fini(net); 1644 nf_conntrack_tstamp_pernet_fini(net);
1638err_tstamp: 1645err_tstamp:
diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
index faa978f1714b..b5d2eb8bf0d5 100644
--- a/net/netfilter/nf_conntrack_ecache.c
+++ b/net/netfilter/nf_conntrack_ecache.c
@@ -233,38 +233,27 @@ static void nf_conntrack_event_fini_sysctl(struct net *net)
233} 233}
234#endif /* CONFIG_SYSCTL */ 234#endif /* CONFIG_SYSCTL */
235 235
236int nf_conntrack_ecache_init(struct net *net) 236int nf_conntrack_ecache_pernet_init(struct net *net)
237{ 237{
238 int ret;
239
240 net->ct.sysctl_events = nf_ct_events; 238 net->ct.sysctl_events = nf_ct_events;
241 net->ct.sysctl_events_retry_timeout = nf_ct_events_retry_timeout; 239 net->ct.sysctl_events_retry_timeout = nf_ct_events_retry_timeout;
240 return nf_conntrack_event_init_sysctl(net);
241}
242 242
243 if (net_eq(net, &init_net)) { 243void nf_conntrack_ecache_pernet_fini(struct net *net)
244 ret = nf_ct_extend_register(&event_extend); 244{
245 if (ret < 0) { 245 nf_conntrack_event_fini_sysctl(net);
246 printk(KERN_ERR "nf_ct_event: Unable to register " 246}
247 "event extension.\n");
248 goto out_extend_register;
249 }
250 }
251 247
252 ret = nf_conntrack_event_init_sysctl(net); 248int nf_conntrack_ecache_init(void)
249{
250 int ret = nf_ct_extend_register(&event_extend);
253 if (ret < 0) 251 if (ret < 0)
254 goto out_sysctl; 252 pr_err("nf_ct_event: Unable to register event extension.\n");
255
256 return 0;
257
258out_sysctl:
259 if (net_eq(net, &init_net))
260 nf_ct_extend_unregister(&event_extend);
261out_extend_register:
262 return ret; 253 return ret;
263} 254}
264 255
265void nf_conntrack_ecache_fini(struct net *net) 256void nf_conntrack_ecache_fini(void)
266{ 257{
267 nf_conntrack_event_fini_sysctl(net); 258 nf_ct_extend_unregister(&event_extend);
268 if (net_eq(net, &init_net))
269 nf_ct_extend_unregister(&event_extend);
270} 259}