]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
[NETNS][FRAGS]: Duplicate sysctl tables for new namespaces.
authorPavel Emelyanov <xemul@openvz.org>
Tue, 22 Jan 2008 14:08:36 +0000 (06:08 -0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 28 Jan 2008 23:10:37 +0000 (15:10 -0800)
Each namespace has to have own tables to tune their
different parameters, so duplicate the tables and
register them.

All the tables in sub-namespaces are temporarily made
read-only.

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/netns/ipv4.h
include/net/netns/ipv6.h
net/ipv4/ip_fragment.c
net/ipv6/reassembly.c

index 80680e09443c6202d8fd51c8b27d2c52f00b8268..15a0b052df222f9e9930d50be7ee448c5371e7b8 100644 (file)
@@ -16,6 +16,7 @@ struct sock;
 struct netns_ipv4 {
 #ifdef CONFIG_SYSCTL
        struct ctl_table_header *forw_hdr;
+       struct ctl_table_header *frags_hdr;
 #endif
        struct ipv4_devconf     *devconf_all;
        struct ipv4_devconf     *devconf_dflt;
index 057c8e473a755592608c48cfe6539e5a62155a5b..87ab56ab93fc8aff5226c3bb4fee599d4f67b4d9 100644 (file)
@@ -12,6 +12,7 @@ struct ctl_table_header;
 struct netns_sysctl_ipv6 {
 #ifdef CONFIG_SYSCTL
        struct ctl_table_header *table;
+       struct ctl_table_header *frags_hdr;
 #endif
        struct inet_frags_ctl frags;
        int bindv6only;
index 4f013343cef7feae433218340a43dcf5389dfb58..c51e1a11dc6b515532ebcf0b32f4ea336bd7bc15 100644 (file)
@@ -661,17 +661,53 @@ static struct ctl_table ip4_frags_ctl_table[] = {
 
 static int ip4_frags_ctl_register(struct net *net)
 {
+       struct ctl_table *table;
        struct ctl_table_header *hdr;
 
-       hdr = register_net_sysctl_table(net, net_ipv4_ctl_path,
-                       ip4_frags_ctl_table);
-       return hdr == NULL ? -ENOMEM : 0;
+       table = ip4_frags_ctl_table;
+       if (net != &init_net) {
+               table = kmemdup(table, sizeof(ip4_frags_ctl_table), GFP_KERNEL);
+               if (table == NULL)
+                       goto err_alloc;
+
+               table[0].mode &= ~0222;
+               table[1].mode &= ~0222;
+               table[2].mode &= ~0222;
+               table[3].mode &= ~0222;
+               table[4].mode &= ~0222;
+       }
+
+       hdr = register_net_sysctl_table(net, net_ipv4_ctl_path, table);
+       if (hdr == NULL)
+               goto err_reg;
+
+       net->ipv4.frags_hdr = hdr;
+       return 0;
+
+err_reg:
+       if (net != &init_net)
+               kfree(table);
+err_alloc:
+       return -ENOMEM;
+}
+
+static void ip4_frags_ctl_unregister(struct net *net)
+{
+       struct ctl_table *table;
+
+       table = net->ipv4.frags_hdr->ctl_table_arg;
+       unregister_net_sysctl_table(net->ipv4.frags_hdr);
+       kfree(table);
 }
 #else
 static inline int ip4_frags_ctl_register(struct net *net)
 {
        return 0;
 }
+
+static inline void ip4_frags_ctl_unregister(struct net *net)
+{
+}
 #endif
 
 static int ipv4_frags_init_net(struct net *net)
index 241b2cc49bf51e2ef8a65baf344ba23e65b16492..0300dcbf1a7569e92f46cd25bf999688ba6f6cdc 100644 (file)
@@ -670,17 +670,52 @@ static struct ctl_table ip6_frags_ctl_table[] = {
 
 static int ip6_frags_sysctl_register(struct net *net)
 {
+       struct ctl_table *table;
        struct ctl_table_header *hdr;
 
-       hdr = register_net_sysctl_table(net, net_ipv6_ctl_path,
-                       ip6_frags_ctl_table);
-       return hdr == NULL ? -ENOMEM : 0;
+       table = ip6_frags_ctl_table;
+       if (net != &init_net) {
+               table = kmemdup(table, sizeof(ip6_frags_ctl_table), GFP_KERNEL);
+               if (table == NULL)
+                       goto err_alloc;
+
+               table[0].mode &= ~0222;
+               table[1].mode &= ~0222;
+               table[2].mode &= ~0222;
+               table[3].mode &= ~0222;
+       }
+
+       hdr = register_net_sysctl_table(net, net_ipv6_ctl_path, table);
+       if (hdr == NULL)
+               goto err_reg;
+
+       net->ipv6.sysctl.frags_hdr = hdr;
+       return 0;
+
+err_reg:
+       if (net != &init_net)
+               kfree(table);
+err_alloc:
+       return -ENOMEM;
+}
+
+static void ip6_frags_sysctl_unregister(struct net *net)
+{
+       struct ctl_table *table;
+
+       table = net->ipv6.sysctl.frags_hdr->ctl_table_arg;
+       unregister_net_sysctl_table(net->ipv6.sysctl.frags_hdr);
+       kfree(table);
 }
 #else
 static inline int ip6_frags_sysctl_register(struct net *net)
 {
        return 0;
 }
+
+static inline void ip6_frags_sysctl_unregister(struct net *net)
+{
+}
 #endif
 
 static int ipv6_frags_init_net(struct net *net)