Skip to content

Commit

Permalink
net sysctl: Initialize the network sysctls sooner to avoid problems.
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Pavel Emelyanov <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
ebiederm authored and davem330 committed Apr 21, 2012
1 parent bc8a369 commit 2ca794e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions include/net/net_namespace.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,11 @@ struct ctl_path;
struct ctl_table;
struct ctl_table_header;

#ifdef CONFIG_SYSCTL
extern int net_sysctl_init(void);
#else
static inline int net_sysctl_init(void) { return 0; }
#endif
extern struct ctl_table_header *register_net_sysctl_table(struct net *net,
const struct ctl_path *path, struct ctl_table *table);
extern struct ctl_table_header *register_net_sysctl_rotable(
Expand Down
6 changes: 6 additions & 0 deletions net/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -2524,6 +2524,12 @@ EXPORT_SYMBOL(sock_unregister);
static int __init sock_init(void)
{
int err;
/*
* Initialize the network sysctl infrastructure.
*/
err = net_sysctl_init();
if (err)
goto out;

/*
* Initialize sock SLAB cache.
Expand Down
3 changes: 1 addition & 2 deletions net/sysctl_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ static struct pernet_operations sysctl_pernet_ops = {
};

static struct ctl_table_header *net_header;
static __init int net_sysctl_init(void)
__init int net_sysctl_init(void)
{
static struct ctl_table empty[1];
int ret = -ENOMEM;
Expand All @@ -109,7 +109,6 @@ static __init int net_sysctl_init(void)
out:
return ret;
}
subsys_initcall(net_sysctl_init);

struct ctl_table_header *register_net_sysctl_table(struct net *net,
const struct ctl_path *path, struct ctl_table *table)
Expand Down

0 comments on commit 2ca794e

Please sign in to comment.