Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 78371
b: refs/heads/master
c: 024626e
h: refs/heads/master
i:
  78369: 0d4edce
  78367: 1c146da
v: v3
  • Loading branch information
Pavel Emelyanov authored and David S. Miller committed Jan 28, 2008
1 parent e51b302 commit d0099fa
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: cbbb90e68cd073b8d63b491166066e347902b7e9
refs/heads/master: 024626e36d75fc8c6e32d50d4c68bfc3b8df5fdf
3 changes: 3 additions & 0 deletions trunk/include/net/net_namespace.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ struct net {

struct sock *rtnl; /* rtnetlink socket */

/* core sysctls */
struct ctl_table_header *sysctl_core_hdr;

/* List of all packet sockets. */
rwlock_t packet_sklist_lock;
struct hlist_head packet_sklist;
Expand Down
50 changes: 45 additions & 5 deletions trunk/net/core/sysctl_net_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,58 @@ static struct ctl_table net_core_table[] = {
{ .ctl_name = 0 }
};

static __initdata struct ctl_path net_core_path[] = {
static __net_initdata struct ctl_path net_core_path[] = {
{ .procname = "net", .ctl_name = CTL_NET, },
{ .procname = "core", .ctl_name = NET_CORE, },
{ },
};

static __init int sysctl_core_init(void)
static __net_init int sysctl_core_net_init(struct net *net)
{
struct ctl_table_header *hdr;
struct ctl_table *tbl, *tmp;

tbl = net_core_table;
if (net != &init_net) {
tbl = kmemdup(tbl, sizeof(net_core_table), GFP_KERNEL);
if (tbl == NULL)
goto err_dup;

for (tmp = tbl; tmp->procname; tmp++)
tmp->mode &= ~0222;
}

net->sysctl_core_hdr = register_net_sysctl_table(net,
net_core_path, tbl);
if (net->sysctl_core_hdr == NULL)
goto err_reg;

hdr = register_sysctl_paths(net_core_path, net_core_table);
return hdr == NULL ? -ENOMEM : 0;
return 0;

err_reg:
if (tbl != net_core_table)
kfree(tbl);
err_dup:
return -ENOMEM;
}

static __net_exit void sysctl_core_net_exit(struct net *net)
{
struct ctl_table *tbl;

tbl = net->sysctl_core_hdr->ctl_table_arg;
unregister_net_sysctl_table(net->sysctl_core_hdr);
BUG_ON(tbl == net_core_table);
kfree(tbl);
}

static __net_initdata struct pernet_operations sysctl_core_ops = {
.init = sysctl_core_net_init,
.exit = sysctl_core_net_exit,
};

static __init int sysctl_core_init(void)
{
return register_pernet_subsys(&sysctl_core_ops);
}

__initcall(sysctl_core_init);

0 comments on commit d0099fa

Please sign in to comment.