[S] Change in openvpn[master]: SIGHUP-restart instance on UDP write error EADDRNOTAVAIL

"cron2 \(Code Review\) via Openvpn-devel" <[email protected]> Wed, 29 Jul 2026 08:10:08 +0000
Newsgroups gmane.network.openvpn.devel
Message-ID <bf6cffcf8b5facb11f47b7eb50b22a5126d7278e-EmailReplacePatchSet-HTML@gerrit.openvpn.net>
Attention is currently required from: plaisthos.

Hello plaisthos, 

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1830?usp=email

to look at the new patch set (#2).


Change subject: SIGHUP-restart instance on UDP write error EADDRNOTAVAIL
......................................................................

SIGHUP-restart instance on UDP write error EADDRNOTAVAIL

If a client device roams to a new network attachment point (LAN to WiFi,
WiFi A to WiFi B, ...) while openvpn is active and a "VPN server host
route" is installed (--redirect-gateway, or just overlapping routes with
the VPN server IP), this host route is no longer active and the VPN is
generally no longer working.

On macOS at least, sendto() will return EADDRNOTAVAIL in many of these
cases, because the route is still active but the "egress interface" is
not - so we can notice, and restart the instance.  A full SIGHUP restart
is needed because we need to remove all overlapping routes first, before
a reconnect can work.

Github: OpenVPN/openvpn#1086

Change-Id: I96b5ea3542df77b1be17079874fb9e4970b539ed
Signed-off-by: Gert Doering <[email protected]>
---
M src/openvpn/forward.c
1 file changed, 11 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/30/1830/2

diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c
index 46e1a53..225ba6b 100644
--- a/src/openvpn/forward.c
+++ b/src/openvpn/forward.c
@@ -1856,6 +1856,17 @@
             msg(M_INFO, "Network unreachable, restarting");
             register_signal(c->sig, SIGUSR1, "network-unreachable");
         }
+
+        /* on some platforms when the client changes to a new network
+         * segment (LAN -> WiFi, etc) and there is a host redirect route
+         * around, we get "cannot assign requested address" as a fairly
+         * reliable (and quick!) indicator for "this connection is dead"
+         */
+        if (size < 0 && errno == EADDRNOTAVAIL)
+        {
+            msg(M_INFO, "UDP socket broken, assuming client-link change, restarting");
+            register_signal(c->sig, SIGHUP, "link-changed");
+        }
     }
     else
     {

-- 
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1830?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I96b5ea3542df77b1be17079874fb9e4970b539ed
Gerrit-Change-Number: 1830
Gerrit-PatchSet: 2
Gerrit-Owner: cron2 <[email protected]>
Gerrit-Reviewer: plaisthos <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]>

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel