Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
[linux-2.6-microblaze.git] / net / ipv4 / sysctl_net_ipv4.c
index a09e466..a62934b 100644 (file)
@@ -1383,9 +1383,19 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
                if (!table)
                        goto err_alloc;
 
-               /* Update the variables to point into the current struct net */
-               for (i = 0; i < ARRAY_SIZE(ipv4_net_table) - 1; i++)
-                       table[i].data += (void *)net - (void *)&init_net;
+               for (i = 0; i < ARRAY_SIZE(ipv4_net_table) - 1; i++) {
+                       if (table[i].data) {
+                               /* Update the variables to point into
+                                * the current struct net
+                                */
+                               table[i].data += (void *)net - (void *)&init_net;
+                       } else {
+                               /* Entries without data pointer are global;
+                                * Make them read-only in non-init_net ns
+                                */
+                               table[i].mode &= ~0222;
+                       }
+               }
        }
 
        net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);