Piss-poor sysctl registration API strikes again, film at 11...
What we really need is _pathname_ required to be present in already
registered table, so that kernel could warn about bad order. That's the
next target for sysctl stuff (and generally saner and more explicit
order of initialization of ipv[46] internals wouldn't hurt either).
For the time being, here are full fixups required by ..._rotable()
stuff; we make per-net sysctl sets descendents of "ro" one and make sure
that sufficient skeleton is there before we start registering per-net
sysctls.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
extern struct ctl_table *ipv6_route_sysctl_init(struct net *net);
extern int ipv6_sysctl_register(void);
extern void ipv6_sysctl_unregister(void);
+extern int ipv6_static_sysctl_register(void);
+extern void ipv6_static_sysctl_unregister(void);
#endif
#endif /* __KERNEL__ */
return rt->peer;
}
-extern ctl_table ipv4_route_table[];
-
#endif /* _ROUTE_H */
return 0;
}
-ctl_table ipv4_route_table[] = {
+static ctl_table ipv4_route_table[] = {
{
.ctl_name = NET_IPV4_ROUTE_GC_THRESH,
.procname = "gc_thresh",
return rc;
}
+/*
+ * We really need to sanitize the damn ipv4 init order, then all
+ * this nonsense will go away.
+ */
+void __init ip_static_sysctl_init(void)
+{
+ register_sysctl_paths(ipv4_route_path, ipv4_route_table);
+}
+
EXPORT_SYMBOL(__ip_select_ident);
EXPORT_SYMBOL(ip_route_input);
EXPORT_SYMBOL(ip_route_output_key);
.proc_handler = &ipv4_local_port_range,
.strategy = &ipv4_sysctl_local_port_range,
},
- {
- .ctl_name = NET_IPV4_ROUTE,
- .procname = "route",
- .maxlen = 0,
- .mode = 0555,
- .child = ipv4_route_table
- },
#ifdef CONFIG_IP_MULTICAST
{
.ctl_name = NET_IPV4_IGMP_MAX_MEMBERSHIPS,
return 0;
}
-/* set enough of tree skeleton to get rid of ordering problems */
-void __init ip_static_sysctl_init(void)
-{
- static ctl_table table[1];
- register_sysctl_paths(net_ipv4_ctl_path, table);
-}
-
__initcall(sysctl_ipv4_init);
if (err)
goto out_unregister_sock;
+#ifdef CONFIG_SYSCTL
+ err = ipv6_static_sysctl_register();
+ if (err)
+ goto static_sysctl_fail;
+#endif
/*
* ipngwg API draft makes clear that the correct semantics
* for TCP and UDP is to consider one TCP and UDP instance
icmp_fail:
unregister_pernet_subsys(&inet6_net_ops);
register_pernet_fail:
+#ifdef CONFIG_SYSCTL
+ ipv6_static_sysctl_unregister();
+static_sysctl_fail:
+#endif
cleanup_ipv6_mibs();
out_unregister_sock:
sock_unregister(PF_INET6);
rawv6_exit();
unregister_pernet_subsys(&inet6_net_ops);
+#ifdef CONFIG_SYSCTL
+ ipv6_static_sysctl_unregister();
+#endif
cleanup_ipv6_mibs();
proto_unregister(&rawv6_prot);
proto_unregister(&udplitev6_prot);
unregister_net_sysctl_table(ip6_header);
unregister_pernet_subsys(&ipv6_sysctl_net_ops);
}
+
+static struct ctl_table_header *ip6_base;
+
+int ipv6_static_sysctl_register(void)
+{
+ static struct ctl_table empty[1];
+ ip6_base = register_net_sysctl_rotable(net_ipv6_ctl_path, empty);
+ if (ip6_base == NULL)
+ return -ENOMEM;
+ return 0;
+}
+
+void ipv6_static_sysctl_unregister(void)
+{
+ unregister_net_sysctl_table(ip6_base);
+}
static int sysctl_net_init(struct net *net)
{
- setup_sysctl_set(&net->sysctls, NULL, is_seen);
+ setup_sysctl_set(&net->sysctls,
+ &net_sysctl_ro_root.default_set,
+ is_seen);
return 0;
}