[Openvpn-devel,v3] tun: removed unnecessary route installations

Message ID 20240912142421.703-1-gert@greenie.muc.de
State Accepted
Headers show
Series [Openvpn-devel,v3] tun: removed unnecessary route installations | expand

Commit Message

Gert Doering Sept. 12, 2024, 2:24 p.m. UTC
From: Marco Baffo <marco@mandelbit.com>

Removed superfluous calls to 'add_route_ipv6' for adding ipv6 routes after tun opening in OpenBSD, NetBSD and Darwin.

Change-Id: I235891212b15277349810913c9c1763da5c48587
Signed-off-by: Marco Baffo <marco@mandelbit.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
---

This change was reviewed on Gerrit and approved by at least one
developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/731
This mail reflects revision 3 of this Change.

Acked-by according to Gerrit (reflected above):
Gert Doering <gert@greenie.muc.de>

Comments

Gert Doering Sept. 12, 2024, 2:30 p.m. UTC | #1
Thanks for this.  I'm not sure why this code was there originally, but
I guess one of the BSDs needed it ("15 years ago!") and I just assumed
the others would, too.  I have tested this on NetBSD, OpenBSD and
MacOS, with all variants I thought might make a difference (tun/p2p,
tun/subnet, tun/subnet with a non-/64 IPv6 mask, tap) and it turns out
that this extra route is needed on none of them.

MacOS has no easily accessible TAP anymore (system security, kext loading)
so this was not tested - but I see no reason why it would break this.

.. and testing this really trivial patch took me about 2 days of
fighting with VMs, macOS, buildbots, ... *sigh*

Your patch has been applied to the master branch.

commit 992da812ad56d2cff44fd4f171dd85c808e1ed50
Author: Marco Baffo
Date:   Thu Sep 12 16:24:21 2024 +0200

     tun: removed unnecessary route installations

     Signed-off-by: Marco Baffo <marco@mandelbit.com>
     Acked-by: Gert Doering <gert@greenie.muc.de>
     Message-Id: <20240912142421.703-1-gert@greenie.muc.de>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29217.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c
index 739e008..82c5c00 100644
--- a/src/openvpn/tun.c
+++ b/src/openvpn/tun.c
@@ -1008,8 +1008,7 @@ 
 #endif /* ifdef _WIN32 */
 }
 
-#if defined(_WIN32)    \
-    || defined(TARGET_DARWIN) || defined(TARGET_NETBSD) || defined(TARGET_OPENBSD)
+#if defined(_WIN32)
 
 /* some of the platforms will auto-add a "network route" pointing
  * to the interface on "ifconfig tunX 2001:db8::1/64", others need
@@ -1200,11 +1199,6 @@ 
                          "FreeBSD BSD 'ifconfig inet6 -ifdisabled' failed");
 #endif
 
-#if defined(TARGET_OPENBSD) || defined(TARGET_NETBSD) \
-    || defined(TARGET_DARWIN)
-    /* and, hooray, we explicitly need to add a route... */
-    add_route_connected_v6_net(tt, es);
-#endif
 #elif defined(TARGET_AIX)
     argv_printf(&argv, "%s %s inet6 %s/%d mtu %d up", IFCONFIG_PATH, ifname,
                 ifconfig_ipv6_local, tt->netbits_ipv6, tun_mtu);