[PATCH 02/16] gtp: remove genl_register_family_with_ops for Linux < 3.13

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.

Andreas Schultz aschultz at tpip.net
Mon Nov 16 15:06:43 UTC 2015


Remove the support for genl_register_family_with_ops for
Linux < 3.13. Also reorder the initialization to be more
in line with similar modules.

Signed-off-by: Andreas Schultz <aschultz at tpip.net>
---
 gtp.c | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/gtp.c b/gtp.c
index 11bda38..7e615f3 100644
--- a/gtp.c
+++ b/gtp.c
@@ -1321,35 +1321,31 @@ static int __init gtp_init(void)
 
 	get_random_bytes(&gtp_h_initval, sizeof(gtp_h_initval));
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)
-	err = genl_register_family_with_ops(&gtp_genl_family, gtp_genl_ops);
-	if (err < 0)
-		return err;
-#else
-	err = genl_register_family_with_ops(&gtp_genl_family,
-					    gtp_genl_ops,
-					    ARRAY_SIZE(gtp_genl_ops));
-	if (err < 0)
-		return err;
-#endif
 	err = rtnl_link_register(&gtp_link_ops);
 	if (err < 0)
-		goto err1;
+		goto error_out;
+
+	err = genl_register_family_with_ops(&gtp_genl_family, gtp_genl_ops);
+	if (err < 0)
+		goto unreg_rtnl_link;
 
 	pr_info("GTP module loaded (pdp ctx size %Zd bytes)\n",
 		sizeof(struct pdp_ctx));
 	return 0;
-err1:
+
+unreg_rtnl_link:
+	rtnl_link_unregister(&gtp_link_ops);
+
+error_out:
 	pr_err("error loading GTP module loaded\n");
-	genl_unregister_family(&gtp_genl_family);
 	return err;
 }
 late_initcall(gtp_init);
 
 static void __exit gtp_fini(void)
 {
-	rtnl_link_unregister(&gtp_link_ops);
 	genl_unregister_family(&gtp_genl_family);
+	rtnl_link_unregister(&gtp_link_ops);
 
 	pr_info("GTP module unloaded\n");
 }
-- 
2.5.0




More information about the OpenBSC mailing list