Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
[sfrench/cifs-2.6.git] / net / ipv4 / devinet.c
index 5267b6b191ebaa540b0012d468fd995d3c79cd8f..123a6d39438f8dc04c4745c7063c8ba22ec50b7a 100644 (file)
@@ -2367,8 +2367,7 @@ static int devinet_conf_ifindex(struct net *net, struct ipv4_devconf *cnf)
 }
 
 static int devinet_conf_proc(struct ctl_table *ctl, int write,
-                            void __user *buffer,
-                            size_t *lenp, loff_t *ppos)
+                            void *buffer, size_t *lenp, loff_t *ppos)
 {
        int old_value = *(int *)ctl->data;
        int ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
@@ -2420,8 +2419,7 @@ static int devinet_conf_proc(struct ctl_table *ctl, int write,
 }
 
 static int devinet_sysctl_forward(struct ctl_table *ctl, int write,
-                                 void __user *buffer,
-                                 size_t *lenp, loff_t *ppos)
+                                 void *buffer, size_t *lenp, loff_t *ppos)
 {
        int *valp = ctl->data;
        int val = *valp;
@@ -2464,8 +2462,7 @@ static int devinet_sysctl_forward(struct ctl_table *ctl, int write,
 }
 
 static int ipv4_doint_and_flush(struct ctl_table *ctl, int write,
-                               void __user *buffer,
-                               size_t *lenp, loff_t *ppos)
+                               void *buffer, size_t *lenp, loff_t *ppos)
 {
        int *valp = ctl->data;
        int val = *valp;
@@ -2670,11 +2667,24 @@ static __net_init int devinet_init_net(struct net *net)
        tbl[0].extra2 = net;
 #endif
 
-       if ((!IS_ENABLED(CONFIG_SYSCTL) ||
-            sysctl_devconf_inherit_init_net != 2) &&
-           !net_eq(net, &init_net)) {
-               memcpy(all, init_net.ipv4.devconf_all, sizeof(ipv4_devconf));
-               memcpy(dflt, init_net.ipv4.devconf_dflt, sizeof(ipv4_devconf_dflt));
+       if (!net_eq(net, &init_net)) {
+               if (IS_ENABLED(CONFIG_SYSCTL) &&
+                   sysctl_devconf_inherit_init_net == 3) {
+                       /* copy from the current netns */
+                       memcpy(all, current->nsproxy->net_ns->ipv4.devconf_all,
+                              sizeof(ipv4_devconf));
+                       memcpy(dflt,
+                              current->nsproxy->net_ns->ipv4.devconf_dflt,
+                              sizeof(ipv4_devconf_dflt));
+               } else if (!IS_ENABLED(CONFIG_SYSCTL) ||
+                          sysctl_devconf_inherit_init_net != 2) {
+                       /* inherit == 0 or 1: copy from init_net */
+                       memcpy(all, init_net.ipv4.devconf_all,
+                              sizeof(ipv4_devconf));
+                       memcpy(dflt, init_net.ipv4.devconf_dflt,
+                              sizeof(ipv4_devconf_dflt));
+               }
+               /* else inherit == 2: use compiled values */
        }
 
 #ifdef CONFIG_SYSCTL