]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Reconnect when TCP is on use on network-change management command
authorArne Schwabe <arne@rfc2549.org>
Sat, 15 Feb 2025 15:24:56 +0000 (16:24 +0100)
committerGert Doering <gert@greenie.muc.de>
Sat, 15 Feb 2025 15:28:09 +0000 (16:28 +0100)
On some newer Android handsets, changing to a different network
often does not trigger a TCP reset but continues using the old
connection (e.g. using mobile connection when WiFi becomes available)

Force a reconnect in these situation to have a more expected beheaviour.

Change-Id: Id4febcceecab33ee5189cd67b249a15d12b84799
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250215152456.5691-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30908.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/init.c

index da20241de3bda7ecc42b4f8a997afa161ab99594..920f8d70d205bd7d4a543e43c0d7459f88c443ae 100644 (file)
@@ -4412,6 +4412,15 @@ management_callback_network_change(void *arg, bool samenetwork)
         return -1;
     }
 
+    /* On some newer Android handsets, changing to a different network
+     * often does not trigger a TCP reset but continue using the old
+     * connection (e.g. using mobile connection when WiFi becomes available */
+    struct link_socket_info *lsi = get_link_socket_info(c);
+    if (lsi && proto_is_tcp(lsi->proto) && !samenetwork)
+    {
+        return -2;
+    }
+
     socketfd = c->c2.link_sockets[0]->sd;
     if (!c->options.pull || c->c2.tls_multi->use_peer_id || samenetwork)
     {