Commit 4344475797a16ef948385780943f7a5cf09f0675

Authored by Eric W. Biederman
Committed by David S. Miller
1 parent 2ca794e5e8

net: Kill register_sysctl_rotable

register_sysctl_rotable never caught on as an interesting way to
register sysctls.  My take on the situation is that what we want are
sysctls that we can only see in the initial network namespace.  What we
have implemented with register_sysctl_rotable are sysctls that we can
see in all of the network namespaces and can only change in the initial
network namespace.

That is a very silly way to go.  Just register the network sysctls
in the initial network namespace and we don't have any weird special
cases to deal with.

The sysctls affected are:
/proc/sys/net/ipv4/ipfrag_secret_interval
/proc/sys/net/ipv4/ipfrag_max_dist
/proc/sys/net/ipv6/ip6frag_secret_interval
/proc/sys/net/ipv6/mld_max_msf

I really don't expect anyone will miss them if they can't read them in a
child user namespace.

CC: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 6 changed files with 4 additions and 29 deletions Side-by-side Diff

include/net/net_namespace.h
... ... @@ -290,8 +290,6 @@
290 290 #endif
291 291 extern struct ctl_table_header *register_net_sysctl_table(struct net *net,
292 292 const struct ctl_path *path, struct ctl_table *table);
293   -extern struct ctl_table_header *register_net_sysctl_rotable(
294   - const struct ctl_path *path, struct ctl_table *table);
295 293 extern struct ctl_table_header *register_net_sysctl(struct net *net,
296 294 const char *path, struct ctl_table *table);
297 295 extern void unregister_net_sysctl_table(struct ctl_table_header *header);
net/core/sysctl_net_core.c
... ... @@ -258,7 +258,7 @@
258 258 static struct ctl_table empty[1];
259 259  
260 260 kmemleak_not_leak(register_sysctl_paths(net_core_path, empty));
261   - register_net_sysctl_rotable(net_core_path, net_core_table);
  261 + register_net_sysctl(&init_net, "net/core", net_core_table);
262 262 return register_pernet_subsys(&sysctl_core_ops);
263 263 }
264 264  
net/ipv4/ip_fragment.c
... ... @@ -807,7 +807,7 @@
807 807  
808 808 static void ip4_frags_ctl_register(void)
809 809 {
810   - register_net_sysctl_rotable(net_ipv4_ctl_path, ip4_frags_ctl_table);
  810 + register_net_sysctl(&init_net, "net/ipv4", ip4_frags_ctl_table);
811 811 }
812 812 #else
813 813 static inline int ip4_frags_ns_ctl_register(struct net *net)
net/ipv6/reassembly.c
... ... @@ -674,7 +674,7 @@
674 674  
675 675 static int ip6_frags_sysctl_register(void)
676 676 {
677   - ip6_ctl_header = register_net_sysctl_rotable(net_ipv6_ctl_path,
  677 + ip6_ctl_header = register_net_sysctl(&init_net, "net/ipv6",
678 678 ip6_frags_ctl_table);
679 679 return ip6_ctl_header == NULL ? -ENOMEM : 0;
680 680 }
net/ipv6/sysctl_net_ipv6.c
... ... @@ -140,7 +140,7 @@
140 140 {
141 141 int err = -ENOMEM;
142 142  
143   - ip6_header = register_net_sysctl_rotable(net_ipv6_ctl_path, ipv6_rotable);
  143 + ip6_header = register_net_sysctl(&init_net, "net/ipv6", ipv6_rotable);
144 144 if (ip6_header == NULL)
145 145 goto out;
146 146  
... ... @@ -59,19 +59,6 @@
59 59 .permissions = net_ctl_permissions,
60 60 };
61 61  
62   -static int net_ctl_ro_header_perms(struct ctl_table_root *root,
63   - struct nsproxy *namespaces, struct ctl_table *table)
64   -{
65   - if (net_eq(namespaces->net_ns, &init_net))
66   - return table->mode;
67   - else
68   - return table->mode & ~0222;
69   -}
70   -
71   -static struct ctl_table_root net_sysctl_ro_root = {
72   - .permissions = net_ctl_ro_header_perms,
73   -};
74   -
75 62 static int __net_init sysctl_net_init(struct net *net)
76 63 {
77 64 setup_sysctl_set(&net->sysctls, &net_sysctl_root, is_seen);
... ... @@ -103,8 +90,6 @@
103 90 ret = register_pernet_subsys(&sysctl_pernet_ops);
104 91 if (ret)
105 92 goto out;
106   - setup_sysctl_set(&net_sysctl_ro_root.default_set, &net_sysctl_ro_root, NULL);
107   - register_sysctl_root(&net_sysctl_ro_root);
108 93 register_sysctl_root(&net_sysctl_root);
109 94 out:
110 95 return ret;
... ... @@ -116,14 +101,6 @@
116 101 return __register_sysctl_paths(&net->sysctls, path, table);
117 102 }
118 103 EXPORT_SYMBOL_GPL(register_net_sysctl_table);
119   -
120   -struct ctl_table_header *register_net_sysctl_rotable(const
121   - struct ctl_path *path, struct ctl_table *table)
122   -{
123   - return __register_sysctl_paths(&net_sysctl_ro_root.default_set,
124   - path, table);
125   -}
126   -EXPORT_SYMBOL_GPL(register_net_sysctl_rotable);
127 104  
128 105 struct ctl_table_header *register_net_sysctl(struct net *net,
129 106 const char *path, struct ctl_table *table)