[IPV6]: make the protocol initialization to return an error code
This patchset makes the different protocols to return an error code, so
the af_inet6 module can check the initialization was correct or not.
The raw6 was taken into account to be consistent with the rest of the
protocols, but the registration is at the same place.
Because the raw6 has its own init function, the proto and the ops structure
can be moved inside the raw6.c file.
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
diff --git a/net/ipv6/udplite.c b/net/ipv6/udplite.c
index 5a0379f..f20b376 100644
--- a/net/ipv6/udplite.c
+++ b/net/ipv6/udplite.c
@@ -77,12 +77,29 @@
.flags = INET_PROTOSW_PERMANENT,
};
-void __init udplitev6_init(void)
+int __init udplitev6_init(void)
{
- if (inet6_add_protocol(&udplitev6_protocol, IPPROTO_UDPLITE) < 0)
- printk(KERN_ERR "%s: Could not register.\n", __FUNCTION__);
+ int ret;
- inet6_register_protosw(&udplite6_protosw);
+ ret = inet6_add_protocol(&udplitev6_protocol, IPPROTO_UDPLITE);
+ if (ret)
+ goto out;
+
+ ret = inet6_register_protosw(&udplite6_protosw);
+ if (ret)
+ goto out_udplitev6_protocol;
+out:
+ return ret;
+
+out_udplitev6_protocol:
+ inet6_del_protocol(&udplitev6_protocol, IPPROTO_UDPLITE);
+ goto out;
+}
+
+void __exit udplitev6_exit(void)
+{
+ inet6_unregister_protosw(&udplite6_protosw);
+ inet6_del_protocol(&udplitev6_protocol, IPPROTO_UDPLITE);
}
#ifdef CONFIG_PROC_FS