[NET] sysctl: prepare core tables to point to netns variables
authorPavel Emelyanov <xemul@openvz.org>
Sat, 8 Dec 2007 08:11:51 +0000 (00:11 -0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 28 Jan 2008 22:56:56 +0000 (14:56 -0800)
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>
net/core/sysctl_net_core.c

index 57a7eadb8551ca83a7c98878e269c6fc69c56156..dc4cf7dda9d173fe9c23fba4d2563afce357f6f8 100644 (file)
@@ -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,