aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2012-04-19 09:20:32 -0400
committerDavid S. Miller <davem@davemloft.net>2012-04-20 21:21:16 -0400
commit2ca794e5e86c800d7f98c4ebb8bd325099c0afe8 (patch)
treef0ae38f58dec5a07ae57e31aca4943c85ffe9d65
parentbc8a36942a5c05896d373a8e98d5e6b14514b4bc (diff)
net sysctl: Initialize the network sysctls sooner to avoid problems.
If the netfilter code is modified to use register_net_sysctl_table the kernel fails to boot because the per net sysctl infrasturce is not setup soon enough. So to avoid races call net_sysctl_init from sock_init(). Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Acked-by: Pavel Emelyanov <xemul@parallels.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/net_namespace.h5
-rw-r--r--net/socket.c6
-rw-r--r--net/sysctl_net.c3
3 files changed, 12 insertions, 2 deletions
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index 446245e3adea..767dcd401e57 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -283,6 +283,11 @@ struct ctl_path;
283struct ctl_table; 283struct ctl_table;
284struct ctl_table_header; 284struct ctl_table_header;
285 285
286#ifdef CONFIG_SYSCTL
287extern int net_sysctl_init(void);
288#else
289static inline int net_sysctl_init(void) { return 0; }
290#endif
286extern struct ctl_table_header *register_net_sysctl_table(struct net *net, 291extern struct ctl_table_header *register_net_sysctl_table(struct net *net,
287 const struct ctl_path *path, struct ctl_table *table); 292 const struct ctl_path *path, struct ctl_table *table);
288extern struct ctl_table_header *register_net_sysctl_rotable( 293extern struct ctl_table_header *register_net_sysctl_rotable(
diff --git a/net/socket.c b/net/socket.c
index d6c1af9ae7b2..e34510928dcc 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -2524,6 +2524,12 @@ EXPORT_SYMBOL(sock_unregister);
2524static int __init sock_init(void) 2524static int __init sock_init(void)
2525{ 2525{
2526 int err; 2526 int err;
2527 /*
2528 * Initialize the network sysctl infrastructure.
2529 */
2530 err = net_sysctl_init();
2531 if (err)
2532 goto out;
2527 2533
2528 /* 2534 /*
2529 * Initialize sock SLAB cache. 2535 * Initialize sock SLAB cache.
diff --git a/net/sysctl_net.c b/net/sysctl_net.c
index 2b2986dd04ae..ce97237b653f 100644
--- a/net/sysctl_net.c
+++ b/net/sysctl_net.c
@@ -89,7 +89,7 @@ static struct pernet_operations sysctl_pernet_ops = {
89}; 89};
90 90
91static struct ctl_table_header *net_header; 91static struct ctl_table_header *net_header;
92static __init int net_sysctl_init(void) 92__init int net_sysctl_init(void)
93{ 93{
94 static struct ctl_table empty[1]; 94 static struct ctl_table empty[1];
95 int ret = -ENOMEM; 95 int ret = -ENOMEM;
@@ -109,7 +109,6 @@ static __init int net_sysctl_init(void)
109out: 109out:
110 return ret; 110 return ret;
111} 111}
112subsys_initcall(net_sysctl_init);
113 112
114struct ctl_table_header *register_net_sysctl_table(struct net *net, 113struct ctl_table_header *register_net_sysctl_table(struct net *net,
115 const struct ctl_path *path, struct ctl_table *table) 114 const struct ctl_path *path, struct ctl_table *table)