Skip to contentSkip to conversation

Change in openvpn[master]: route: copied 'gateway_needed' logic from add_route_ipv6 to add_route

Openvpn-devel mrbff (Code Review) 1 participant 12 messages Jul 18, 2024 – Oct 21, 2025 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1721311407000.Id1ec0c6e4c391604ec5dbb8b7122f2e47ad186d1@...2715...

#1 lore raw

Attention is currently required from: flichtenheld, plaisthos.

Hello plaisthos, flichtenheld,

I'd like you to do a code review.
Please visit

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

to review the following change.

Change subject: route: copied 'gateway_needed' logic from add_route_ipv6 to add_route
......................................................................

route: copied 'gateway_needed' logic from add_route_ipv6 to add_route

Under certain circumstances it may not be necessary to pass the gateway when adding a new route via net_route_v4_add() API function. add_route_ipv6() already accounts for some of these cases and therefore this patch copies the same logic to add_route().

Change-Id Id1ec0c6e4c391604ec5dbb8b7122f2e47ad186d1

---
M src/openvpn/route.c

1 file changed, 31 insertions(+), 3 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/77/677/1

src/openvpn/route.c +31 -3
index 91f2032..bc8f561 100644
@@ -1571,6 +1571,7 @@
 {
     int status = 0;
     int is_local_route;
+    bool gateway_needed = false;
 
     if (!(r->flags & RT_DEFINED))
     {
@@ -1580,8 +1581,20 @@
     struct argv argv = argv_new();
     struct gc_arena gc = gc_new();
 
-#if !defined(TARGET_LINUX)
+#if defined(TARGET_LINUX)
+    const char *iface = tt->actual_name;
+    if (rgi && rgi->iface[0] != '\0')  /* vpn server special route */
+    {
+        iface = rgi->iface;
+        if (r->gateway != 0)
+        {
+            gateway_needed = true;
+        }
+    }
+#endif
+
     const char *network = print_in_addr_t(r->network, 0, &gc);
+#if !defined(TARGET_LINUX)
 #if !defined(TARGET_AIX)
     const char *netmask = print_in_addr_t(r->netmask, 0, &gc);
 #endif
@@ -1594,8 +1607,22 @@
         goto done;
     }
 
+    if (tt->type == DEV_TYPE_TAP && !(r->flags & RT_METRIC_DEFINED && r->metric == 0))
+    {
+        gateway_needed = true;
+    }
+
+    if (gateway_needed && r->gateway == 0)
+    {
+        msg(M_WARN, "ROUTE WARNING: " PACKAGE_NAME " needs a gateway "
+            "parameter for a --route option and no default was set via "
+            "--route-gateway or --ifconfig option. Not installing "
+            "IPv4 route to %s/%d.", network, netmask_to_netbits2(r->netmask));
+        status = 0;
+        goto done;
+    }
+
 #if defined(TARGET_LINUX)
-    const char *iface = NULL;
     int metric = -1;
 
     if (is_on_link(is_local_route, flags, rgi))
@@ -1610,7 +1637,8 @@
 
     status = RTA_SUCCESS;
     int ret = net_route_v4_add(ctx, &r->network, netmask_to_netbits2(r->netmask),
-                               &r->gateway, iface, 0, metric);
+                               gateway_needed ? &r->gateway : NULL,
+                               iface, 0, metric);
     if (ret == -EEXIST)
     {
         msg(D_ROUTE, "NOTE: Linux route add command failed because route exists");

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

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id1ec0c6e4c391604ec5dbb8b7122f2e47ad186d1
Gerrit-Change-Number: 677
Gerrit-PatchSet: 1
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: mrbff, plaisthos.

flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/677?usp=email )

Change subject: route: copied 'gateway_needed' logic from add_route_ipv6 to add_route
......................................................................

Patch Set 1: Code-Review-1

(1 comment)

Patchset:

PS1:
Needs to fix build errors first

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

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id1ec0c6e4c391604ec5dbb8b7122f2e47ad186d1
Gerrit-Change-Number: 677
Gerrit-PatchSet: 1
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: mrbff <[email protected]...>
Gerrit-Comment-Date: Fri, 19 Jul 2024 13:16:54 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#3 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, mrbff, plaisthos.

Hello flichtenheld, plaisthos,

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

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

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

The following approvals got outdated and were removed:
Code-Review-1 by flichtenheld

Change subject: route: copied 'gateway_needed' logic from add_route_ipv6 to add_route
......................................................................

route: copied 'gateway_needed' logic from add_route_ipv6 to add_route

Under certain circumstances it may not be necessary to pass the gateway when adding a new route via net_route_v4_add() API function. add_route_ipv6() already accounts for some of these cases and therefore this patch copies the same logic to add_route().

Change-Id Id1ec0c6e4c391604ec5dbb8b7122f2e47ad186d1

---
M src/openvpn/route.c

1 file changed, 40 insertions(+), 3 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/77/677/3

src/openvpn/route.c +40 -3
index 91f2032..06a4919 100644
@@ -1571,6 +1571,7 @@
 {
     int status = 0;
     int is_local_route;
+    bool gateway_needed = false;
 
     if (!(r->flags & RT_DEFINED))
     {
@@ -1580,8 +1581,8 @@
     struct argv argv = argv_new();
     struct gc_arena gc = gc_new();
 
-#if !defined(TARGET_LINUX)
     const char *network = print_in_addr_t(r->network, 0, &gc);
+#if !defined(TARGET_LINUX)
 #if !defined(TARGET_AIX)
     const char *netmask = print_in_addr_t(r->netmask, 0, &gc);
 #endif
@@ -1594,8 +1595,43 @@
         goto done;
     }
 
+    #ifndef _WIN32
+
+    if (rgi && (rgi->flags & RGI_IFACE_DEFINED) && rgi->iface[0] != 0)  /* vpn server special route */
+    {
+        if (rgi->flags & RGI_ADDR_DEFINED && r->gateway != 0)
+        {
+            gateway_needed = true;
+        }
+    }
+
+    #endif
+
+    if (tt->type == DEV_TYPE_TAP
+        && !( (r->flags & RT_METRIC_DEFINED) && r->metric == 0 ) )
+    {
+        gateway_needed = true;
+    }
+
+    if (gateway_needed && r->gateway == 0)
+    {
+        msg(M_WARN, "ROUTE WARNING: " PACKAGE_NAME " needs a gateway "
+            "parameter for a --route option and no default was set via "
+            "--route-gateway or --ifconfig option. Not installing "
+            "IPv4 route to %s/%d.", network, netmask_to_netbits2(r->netmask));
+        status = 0;
+        goto done;
+    }
+
 #if defined(TARGET_LINUX)
-    const char *iface = NULL;
+    const char *iface = tt->actual_name;
+    if (!gateway_needed && rgi && (rgi->flags & RGI_IFACE_DEFINED) && rgi->iface[0] != 0)  /* vpn server special route */
+    {
+        iface = rgi->iface;
+    }
+#endif
+
+#if defined(TARGET_LINUX)
     int metric = -1;
 
     if (is_on_link(is_local_route, flags, rgi))
@@ -1610,7 +1646,8 @@
 
     status = RTA_SUCCESS;
     int ret = net_route_v4_add(ctx, &r->network, netmask_to_netbits2(r->netmask),
-                               &r->gateway, iface, 0, metric);
+                               gateway_needed ? &r->gateway : NULL,
+                               iface, 0, metric);
     if (ret == -EEXIST)
     {
         msg(D_ROUTE, "NOTE: Linux route add command failed because route exists");

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

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id1ec0c6e4c391604ec5dbb8b7122f2e47ad186d1
Gerrit-Change-Number: 677
Gerrit-PatchSet: 3
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: mrbff <[email protected]...>
Gerrit-MessageType: newpatchset

#4 lore raw
In reply to a message not in the archive

Attention is currently required from: mrbff, plaisthos.

flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/677?usp=email )

Change subject: route: copied 'gateway_needed' logic from add_route_ipv6 to add_route
......................................................................

Patch Set 5: Code-Review-1

(1 comment)

File src/openvpn/route.c:

http://gerrit.openvpn.net/c/openvpn/+/677/comment/05ce0096_0799e982 :
PS5, Line 1598: #ifndef _WIN32
preprocessor directives should not be indented

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

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id1ec0c6e4c391604ec5dbb8b7122f2e47ad186d1
Gerrit-Change-Number: 677
Gerrit-PatchSet: 5
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: mrbff <[email protected]...>
Gerrit-Comment-Date: Thu, 05 Sep 2024 10:09:53 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#5 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, mrbff, plaisthos.

Hello flichtenheld, plaisthos,

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

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

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

The following approvals got outdated and were removed:
Code-Review-1 by flichtenheld

Change subject: route: copied 'gateway_needed' logic from add_route_ipv6 to add_route
......................................................................

route: copied 'gateway_needed' logic from add_route_ipv6 to add_route

Under certain circumstances it may not be necessary to pass the gateway when adding a new route via net_route_v4_add() API function. add_route_ipv6() already accounts for some of these cases and therefore this patch copies the same logic to add_route().

Change-Id Id1ec0c6e4c391604ec5dbb8b7122f2e47ad186d1

---
M src/openvpn/route.c

1 file changed, 40 insertions(+), 3 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/77/677/6

src/openvpn/route.c +40 -3
index 91f2032..2033433 100644
@@ -1571,6 +1571,7 @@
 {
     int status = 0;
     int is_local_route;
+    bool gateway_needed = false;
 
     if (!(r->flags & RT_DEFINED))
     {
@@ -1580,8 +1581,8 @@
     struct argv argv = argv_new();
     struct gc_arena gc = gc_new();
 
-#if !defined(TARGET_LINUX)
     const char *network = print_in_addr_t(r->network, 0, &gc);
+#if !defined(TARGET_LINUX)
 #if !defined(TARGET_AIX)
     const char *netmask = print_in_addr_t(r->netmask, 0, &gc);
 #endif
@@ -1594,8 +1595,43 @@
         goto done;
     }
 
+#ifndef _WIN32
+
+    if (rgi && (rgi->flags & RGI_IFACE_DEFINED) && rgi->iface[0] != 0)  /* vpn server special route */
+    {
+        if (rgi->flags & RGI_ADDR_DEFINED && r->gateway != 0)
+        {
+            gateway_needed = true;
+        }
+    }
+
+#endif
+
+    if (tt->type == DEV_TYPE_TAP
+        && !( (r->flags & RT_METRIC_DEFINED) && r->metric == 0 ) )
+    {
+        gateway_needed = true;
+    }
+
+    if (gateway_needed && r->gateway == 0)
+    {
+        msg(M_WARN, "ROUTE WARNING: " PACKAGE_NAME " needs a gateway "
+            "parameter for a --route option and no default was set via "
+            "--route-gateway or --ifconfig option. Not installing "
+            "IPv4 route to %s/%d.", network, netmask_to_netbits2(r->netmask));
+        status = 0;
+        goto done;
+    }
+
 #if defined(TARGET_LINUX)
-    const char *iface = NULL;
+    const char *iface = tt->actual_name;
+    if (!gateway_needed && rgi && (rgi->flags & RGI_IFACE_DEFINED) && rgi->iface[0] != 0)  /* vpn server special route */
+    {
+        iface = rgi->iface;
+    }
+#endif
+
+#if defined(TARGET_LINUX)
     int metric = -1;
 
     if (is_on_link(is_local_route, flags, rgi))
@@ -1610,7 +1646,8 @@
 
     status = RTA_SUCCESS;
     int ret = net_route_v4_add(ctx, &r->network, netmask_to_netbits2(r->netmask),
-                               &r->gateway, iface, 0, metric);
+                               gateway_needed ? &r->gateway : NULL,
+                               iface, 0, metric);
     if (ret == -EEXIST)
     {
         msg(D_ROUTE, "NOTE: Linux route add command failed because route exists");

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

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id1ec0c6e4c391604ec5dbb8b7122f2e47ad186d1
Gerrit-Change-Number: 677
Gerrit-PatchSet: 6
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: mrbff <[email protected]...>
Gerrit-MessageType: newpatchset

#6 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, mrbff, plaisthos.

cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/677?usp=email )

Change subject: route: copied 'gateway_needed' logic from add_route_ipv6 to add_route
......................................................................

Patch Set 9:

(5 comments)

Patchset:

PS9:
Getting there...

File src/openvpn/route.c:

http://gerrit.openvpn.net/c/openvpn/+/677/comment/cc58944a_810b6a73 :
PS9, Line 1585: #if !defined(TARGET_LINUX)
why is that #ifndef moved`? It's not used by the new Linux code either, or am I misreading it (so, no -Werror safe)?

http://gerrit.openvpn.net/c/openvpn/+/677/comment/fc88af46_52bd13d6 :
PS9, Line 1599:
this blank line (and the one at the end of the if()) feel superfluous

http://gerrit.openvpn.net/c/openvpn/+/677/comment/6c4000d3_493952ff :
PS9, Line 1616: if (gateway_needed && r->gateway == 0)
if we add this here, we might consider getting rid of this warning in init_route() then... but this is a bit complex, as for most platforms gateway_needed = true is still valid, due to limits in route table handling

http://gerrit.openvpn.net/c/openvpn/+/677/comment/1ea919ca_7a56279c :
PS9, Line 1634: #if defined(TARGET_LINUX)
this needs to go - two #if defined(TARGET_LINUX) next to each other, with nothing else in between. Or am I misreading the diff?

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

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id1ec0c6e4c391604ec5dbb8b7122f2e47ad186d1
Gerrit-Change-Number: 677
Gerrit-PatchSet: 9
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: mrbff <[email protected]...>
Gerrit-Comment-Date: Thu, 19 Sep 2024 11:10:41 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment

#7 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, mrbff, plaisthos.

Hello flichtenheld, plaisthos,

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

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

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

Change subject: route: copied 'gateway_needed' logic from add_route_ipv6 to add_route
......................................................................

route: copied 'gateway_needed' logic from add_route_ipv6 to add_route

Under certain circumstances it may not be necessary to pass the gateway when adding a new route via net_route_v4_add() API function. add_route_ipv6() already accounts for some of these cases and therefore this patch copies the same logic to add_route().

Change-Id Id1ec0c6e4c391604ec5dbb8b7122f2e47ad186d1

---
M src/openvpn/route.c

1 file changed, 36 insertions(+), 3 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/77/677/10

src/openvpn/route.c +36 -3
index 91f2032..ae7707c 100644
@@ -1571,6 +1571,7 @@
 {
     int status = 0;
     int is_local_route;
+    bool gateway_needed = false;
 
     if (!(r->flags & RT_DEFINED))
     {
@@ -1580,8 +1581,8 @@
     struct argv argv = argv_new();
     struct gc_arena gc = gc_new();
 
-#if !defined(TARGET_LINUX)
     const char *network = print_in_addr_t(r->network, 0, &gc);
+#if !defined(TARGET_LINUX)
 #if !defined(TARGET_AIX)
     const char *netmask = print_in_addr_t(r->netmask, 0, &gc);
 #endif
@@ -1594,8 +1595,39 @@
         goto done;
     }
 
+#ifndef _WIN32
+    if (rgi && (rgi->flags & RGI_IFACE_DEFINED) && rgi->iface[0] != 0)  /* vpn server special route */
+    {
+        if (rgi->flags & RGI_ADDR_DEFINED && r->gateway != 0)
+        {
+            gateway_needed = true;
+        }
+    }
+#endif
+
+    if (tt->type == DEV_TYPE_TAP
+        && !( (r->flags & RT_METRIC_DEFINED) && r->metric == 0 ) )
+    {
+        gateway_needed = true;
+    }
+
+    if (gateway_needed && r->gateway == 0)
+    {
+        msg(M_WARN, "ROUTE WARNING: " PACKAGE_NAME " needs a gateway "
+            "parameter for a --route option and no default was set via "
+            "--route-gateway or --ifconfig option. Not installing "
+            "IPv4 route to %s/%d.", network, netmask_to_netbits2(r->netmask));
+        status = 0;
+        goto done;
+    }
+
 #if defined(TARGET_LINUX)
-    const char *iface = NULL;
+    const char *iface = tt->actual_name;
+    if (!gateway_needed && rgi && (rgi->flags & RGI_IFACE_DEFINED) && rgi->iface[0] != 0)  /* vpn server special route */
+    {
+        iface = rgi->iface;
+    }
+
     int metric = -1;
 
     if (is_on_link(is_local_route, flags, rgi))
@@ -1610,7 +1642,8 @@
 
     status = RTA_SUCCESS;
     int ret = net_route_v4_add(ctx, &r->network, netmask_to_netbits2(r->netmask),
-                               &r->gateway, iface, 0, metric);
+                               gateway_needed ? &r->gateway : NULL,
+                               iface, 0, metric);
     if (ret == -EEXIST)
     {
         msg(D_ROUTE, "NOTE: Linux route add command failed because route exists");

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

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id1ec0c6e4c391604ec5dbb8b7122f2e47ad186d1
Gerrit-Change-Number: 677
Gerrit-PatchSet: 10
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: mrbff <[email protected]...>
Gerrit-MessageType: newpatchset

#8 lore raw
In reply to a message not in the archive

Attention is currently required from: cron2, flichtenheld, plaisthos.

mrbff has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/677?usp=email )

Change subject: route: copied 'gateway_needed' logic from add_route_ipv6 to add_route
......................................................................

Patch Set 10:

(5 comments)

File src/openvpn/route.c:

http://gerrit.openvpn.net/c/openvpn/+/677/comment/6cceaa5b_47265977 :
PS5, Line 1598: #ifndef _WIN32

Quoted 1 line

preprocessor directives should not be indented

Done

File src/openvpn/route.c:

http://gerrit.openvpn.net/c/openvpn/+/677/comment/71e62482_873a6e01 :
PS9, Line 1585: #if !defined(TARGET_LINUX)

Quoted 1 line

why is that #ifndef moved`? It's not used by the new Linux code either, or am I misreading it (so […]

"network" is now used in the new waning

http://gerrit.openvpn.net/c/openvpn/+/677/comment/39ad8e78_7d4d9eb3 :
PS9, Line 1599:

Quoted 1 line

this blank line (and the one at the end of the if()) feel superfluous

Done

http://gerrit.openvpn.net/c/openvpn/+/677/comment/aa38e9c7_74e2196e :
PS9, Line 1616: if (gateway_needed && r->gateway == 0)

Quoted 1 line

if we add this here, we might consider getting rid of this warning in init_route() then... […]

Acknowledged

http://gerrit.openvpn.net/c/openvpn/+/677/comment/423f7057_a24ac63a :
PS9, Line 1634: #if defined(TARGET_LINUX)

Quoted 1 line

this needs to go - two #if defined(TARGET_LINUX) next to each other, with nothing else in between. […]

no, you are right, my bad

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

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id1ec0c6e4c391604ec5dbb8b7122f2e47ad186d1
Gerrit-Change-Number: 677
Gerrit-PatchSet: 10
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Thu, 19 Sep 2024 12:58:57 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: cron2 <[email protected]...>
Comment-In-Reply-To: flichtenheld <[email protected]...>
Gerrit-MessageType: comment

#9 lore raw
In reply to a message not in the archive

Attention is currently required from: cron2, flichtenheld, mrbff.

plaisthos has posted comments on this change by mrbff. ( http://gerrit.openvpn.net/c/openvpn/+/677?usp=email )

Change subject: route: copied 'gateway_needed' logic from add_route_ipv6 to add_route
......................................................................

Patch Set 11:

(2 comments)

Patchset:

PS11:
This changes the logic of adding routes on all platforms in a very drastic way. This requires at least a note in Changes.rst to call this different default behaviour out.

File src/openvpn/route.c:

http://gerrit.openvpn.net/c/openvpn/+/677/comment/3706b988_994b1a63?usp=email :
PS11, Line 1606: gateway_needed = true;
Sure but why is the gateway needed in this case?

And why is this always the vpn server special route? For me this is not obvious and I would like some comment describing the reason here.

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

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id1ec0c6e4c391604ec5dbb8b7122f2e47ad186d1
Gerrit-Change-Number: 677
Gerrit-PatchSet: 11
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: mrbff <[email protected]...>
Gerrit-Comment-Date: Mon, 13 Oct 2025 14:49:02 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No

#10 lore raw
In reply to a message not in the archive

Attention is currently required from: cron2, flichtenheld, mrbff.

plaisthos has posted comments on this change by mrbff. ( http://gerrit.openvpn.net/c/openvpn/+/677?usp=email )

Change subject: route: copied 'gateway_needed' logic from add_route_ipv6 to add_route
......................................................................

Patch Set 11: Code-Review-1

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

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id1ec0c6e4c391604ec5dbb8b7122f2e47ad186d1
Gerrit-Change-Number: 677
Gerrit-PatchSet: 11
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: mrbff <[email protected]...>
Gerrit-Comment-Date: Mon, 13 Oct 2025 14:49:09 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes

#11 lore raw
In reply to a message not in the archive

Attention is currently required from: cron2, flichtenheld, mrbff, plaisthos.

Hello flichtenheld, plaisthos,

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

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

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

The following approvals got outdated and were removed:
Code-Review-1 by plaisthos

Change subject: route: copied 'gateway_needed' logic from add_route_ipv6 to add_route
......................................................................

route: copied 'gateway_needed' logic from add_route_ipv6 to add_route

Under certain circumstances it may not be necessary to pass the gateway when adding a new route via net_route_v4_add() API function. add_route_ipv6() already accounts for some of these cases and therefore this patch copies the same logic to add_route().

Change-Id Id1ec0c6e4c391604ec5dbb8b7122f2e47ad186d1

---
M Changes.rst
M src/openvpn/route.c

2 files changed, 51 insertions(+), 3 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/77/677/12

Changes.rst +7 -0
index 4feacad2..a3e00c2 100644
@@ -170,6 +170,13 @@
 COPYING: license details only relevant to our Windows installers have
    been updated and moved to the openvpn-build repo
 
+The route gateway is now only added for IPv4 when strictly necessary.
+  The gateway-needed logic previously applied to IPv6 only has been copied
+  and extended to IPv4 route handling.  Route additions now omit the
+  gateway unless required after checking device type, special routes,
+  on-link gateways, and whether the gateway lies inside the VPN subnet,
+  optimizing route configuration and potentially reducing redundant route
+  entries.
 
 Deprecated features
 -------------------
src/openvpn/route.c +44 -3

73 lines not on this page · raw message

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/677?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: Id1ec0c6e4c391604ec5dbb8b7122f2e47ad186d1
Gerrit-Change-Number: 677
Gerrit-PatchSet: 12
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: mrbff <[email protected]...>

#12 lore raw
In reply to a message not in the archive

Attention is currently required from: cron2, flichtenheld, plaisthos.

mrbff has posted comments on this change by mrbff. ( http://gerrit.openvpn.net/c/openvpn/+/677?usp=email )

Change subject: route: copied 'gateway_needed' logic from add_route_ipv6 to add_route
......................................................................

Patch Set 12:

(2 comments)

Patchset:

PS11:

Quoted 1 line

This changes the logic of adding routes on all platforms in a very drastic way. […]

Done

File src/openvpn/route.c:

http://gerrit.openvpn.net/c/openvpn/+/677/comment/2b9f3a14_b1ffc52f?usp=email :
PS11, Line 1606: gateway_needed = true;

Quoted 1 line

Sure but why is the gateway needed in this case? […]

Done

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

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id1ec0c6e4c391604ec5dbb8b7122f2e47ad186d1
Gerrit-Change-Number: 677
Gerrit-PatchSet: 12
Gerrit-Owner: mrbff <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Tue, 21 Oct 2025 14:10:43 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: plaisthos <[email protected]...>