Przeglądaj źródła

[NETNS][IPV6] Move sysctl initialization later on in the IPv6 init sequence

This patch moves initialization of IPv6 sysctl stuff at the end of
IPv6 initialization.

This will be helpful for network namespaces where some sysctl entries
depend on per-namespace variables, that need to be allocated and
initialized before they are referenced by sysctl.

Signed-off-by: Benjamin Thery <benjamin.thery@bull.net>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Benjamin Thery 17 lat temu
rodzic
commit
94911fe317
1 zmienionych plików z 14 dodań i 13 usunięć
  1. 14 13
      net/ipv6/af_inet6.c

+ 14 - 13
net/ipv6/af_inet6.c

@@ -934,12 +934,6 @@ static int __init inet6_init(void)
 	err = register_pernet_subsys(&inet6_net_ops);
 	err = register_pernet_subsys(&inet6_net_ops);
 	if (err)
 	if (err)
 		goto register_pernet_fail;
 		goto register_pernet_fail;
-
-#ifdef CONFIG_SYSCTL
-	err = ipv6_sysctl_register();
-	if (err)
-		goto sysctl_fail;
-#endif
 	err = icmpv6_init();
 	err = icmpv6_init();
 	if (err)
 	if (err)
 		goto icmp_fail;
 		goto icmp_fail;
@@ -1006,9 +1000,19 @@ static int __init inet6_init(void)
 	err = ipv6_packet_init();
 	err = ipv6_packet_init();
 	if (err)
 	if (err)
 		goto ipv6_packet_fail;
 		goto ipv6_packet_fail;
+
+#ifdef CONFIG_SYSCTL
+	err = ipv6_sysctl_register();
+	if (err)
+		goto sysctl_fail;
+#endif
 out:
 out:
 	return err;
 	return err;
 
 
+#ifdef CONFIG_SYSCTL
+sysctl_fail:
+	ipv6_packet_cleanup();
+#endif
 ipv6_packet_fail:
 ipv6_packet_fail:
 	tcpv6_exit();
 	tcpv6_exit();
 tcpv6_fail:
 tcpv6_fail:
@@ -1050,10 +1054,6 @@ igmp_fail:
 ndisc_fail:
 ndisc_fail:
 	icmpv6_cleanup();
 	icmpv6_cleanup();
 icmp_fail:
 icmp_fail:
-#ifdef CONFIG_SYSCTL
-	ipv6_sysctl_unregister();
-sysctl_fail:
-#endif
 	unregister_pernet_subsys(&inet6_net_ops);
 	unregister_pernet_subsys(&inet6_net_ops);
 register_pernet_fail:
 register_pernet_fail:
 	cleanup_ipv6_mibs();
 	cleanup_ipv6_mibs();
@@ -1083,6 +1083,9 @@ static void __exit inet6_exit(void)
 	/* Disallow any further netlink messages */
 	/* Disallow any further netlink messages */
 	rtnl_unregister_all(PF_INET6);
 	rtnl_unregister_all(PF_INET6);
 
 
+#ifdef CONFIG_SYSCTL
+	ipv6_sysctl_unregister();
+#endif
 	udpv6_exit();
 	udpv6_exit();
 #ifdef CONFIG_IP_UDPLITE
 #ifdef CONFIG_IP_UDPLITE
 	udplitev6_exit();
 	udplitev6_exit();
@@ -1112,9 +1115,7 @@ static void __exit inet6_exit(void)
 	ndisc_cleanup();
 	ndisc_cleanup();
 	icmpv6_cleanup();
 	icmpv6_cleanup();
 	rawv6_exit();
 	rawv6_exit();
-#ifdef CONFIG_SYSCTL
-	ipv6_sysctl_unregister();
-#endif
+
 	unregister_pernet_subsys(&inet6_net_ops);
 	unregister_pernet_subsys(&inet6_net_ops);
 	cleanup_ipv6_mibs();
 	cleanup_ipv6_mibs();
 	proto_unregister(&rawv6_prot);
 	proto_unregister(&rawv6_prot);