Skip to content

Commit

Permalink
[NET] sysctl: prepare core tables to point to netns variables
Browse files Browse the repository at this point in the history
Some of ctl variables are going to be on the struct
net. Here's the way to adjust the ->data pointer on the
ctl_table-s to point on the right variable.

Since some pointers still point on the global variables,
I keep turning the write bits off on such tables.

This looks to become a common procedure for net sysctls,
so later parts of this code may migrate to some more
generic place.

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Pavel Emelyanov authored and David S. Miller committed Jan 28, 2008
1 parent 024626e commit 790a353
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions net/core/sysctl_net_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,13 @@ static __net_init int sysctl_core_net_init(struct net *net)
if (tbl == NULL)
goto err_dup;

for (tmp = tbl; tmp->procname; tmp++)
tmp->mode &= ~0222;
for (tmp = tbl; tmp->procname; tmp++) {
if (tmp->data >= (void *)&init_net &&
tmp->data < (void *)(&init_net + 1))
tmp->data += (char *)net - (char *)&init_net;
else
tmp->mode &= ~0222;
}
}

net->sysctl_core_hdr = register_net_sysctl_table(net,
Expand Down

0 comments on commit 790a353

Please sign in to comment.