[Openvpn-devel,net,v3,8/9] ovpn: ensure TCP vars are initialized first

Message ID 20260727200705.869169-9-a@unstable.cc
State New
Headers
Series ovpn: assorted net fixes |

Commit Message

Antonio Quartulli July 27, 2026, 8:07 p.m. UTC
  From: Antonio Quartulli <antonio@openvpn.net>

Netlink calls may access TCP global vars (i.e. when attaching
a TCP socket), therefore we need to make sure the
latters are initialized beforehand.

For this reason move the global TCP initialization at the top
of the module init function.

Fixes: 11851cbd60ea ("ovpn: implement TCP transport")
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
---
 drivers/net/ovpn/main.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
  

Patch

diff --git a/drivers/net/ovpn/main.c b/drivers/net/ovpn/main.c
index c4e775250727..f8ae64612951 100644
--- a/drivers/net/ovpn/main.c
+++ b/drivers/net/ovpn/main.c
@@ -253,8 +253,14 @@  static struct rtnl_link_ops ovpn_link_ops = {
 
 static int __init ovpn_init(void)
 {
-	int err = rtnl_link_register(&ovpn_link_ops);
+	int err;
 
+	/* init TCP first so that any subsequent netlink operation
+	 * is ensured to access initialized TCP global vars
+	 */
+	ovpn_tcp_init();
+
+	err = rtnl_link_register(&ovpn_link_ops);
 	if (err) {
 		pr_err("ovpn: can't register rtnl link ops: %d\n", err);
 		return err;
@@ -266,8 +272,6 @@  static int __init ovpn_init(void)
 		goto unreg_rtnl;
 	}
 
-	ovpn_tcp_init();
-
 	return 0;
 
 unreg_rtnl: