diff mbox

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

Message ID 1447686417-3979-3-git-send-email-aschultz@tpip.net
State Accepted
Delegated to: Pablo Neira
Headers show

Commit Message

Andreas Schultz Nov. 16, 2015, 3:06 p.m. UTC
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@tpip.net>
---
 gtp.c | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)

Comments

Pablo Neira Ayuso Nov. 16, 2015, 5:39 p.m. UTC | #1
On Mon, Nov 16, 2015 at 04:06:43PM +0100, Andreas Schultz wrote:
> 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.

Also applied with minor nitpick, see below.

> -err1:
> +
> +unreg_rtnl_link:
> +	rtnl_link_unregister(&gtp_link_ops);
> +

No need for extra space here, I have mangled the patch here, no
problem.

> +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
>
Neels Hofmeyr Nov. 17, 2015, 2:03 p.m. UTC | #2
On Mon, Nov 16, 2015 at 04:06:43PM +0100, Andreas Schultz wrote:
>  	pr_err("error loading GTP module loaded\n");

Not related to the patch, but I notice the weird message...

~Neels
diff mbox

Patch

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");
 }