* [Openvpn-devel] [S] Change in openvpn[master]: route: handle default gateway (net_gateway) and nexthop towards VPN s...
[not found] <gerrit.1740476988000.Ifc54be34101c0eb0f3dc479a9480d7219628cc76@...2715...>
@ 2025-02-25 9:49 ` mrbff (Code Review)
2025-09-26 20:06 ` mrbff (Code Review)
1 sibling, 0 replies; 14+ messages in thread
From: mrbff (Code Review) @ 2025-02-25 9:49 UTC (permalink / raw)
To: plaisthos <arne-openvpn@; +Cc: openvpn-devel
[-- Attachment #1: Type: text/plain, Size: 3833 bytes --]
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/+/902?usp=email
to review the following change.
Change subject: route: handle default gateway (net_gateway) and nexthop towards VPN server separately
......................................................................
route: handle default gateway (net_gateway) and nexthop towards VPN server separately
Right now there is the assumption that the gateway used for net_gateway is the same used to reach the VPN server.
However, these two gateways may be different (i.e. when there is a specific hostroute for the VPN server using a different nexthop).
For this reason we must adapt init_route_list() to fetch the two gateways separately.
Change-Id: Ifc54be34101c0eb0f3dc479a9480d7219628cc76
---
M src/openvpn/route.c
1 file changed, 14 insertions(+), 6 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/02/902/1
diff --git a/src/openvpn/route.c b/src/openvpn/route.c
index bc41492..3ddc333 100644
--- a/src/openvpn/route.c
+++ b/src/openvpn/route.c
@@ -655,10 +655,12 @@
rl->spec.flags |= RTSA_DEFAULT_METRIC;
}
- get_default_gateway(&rl->rgi, remote_host != IPV4_INVALID_ADDR ? remote_host : INADDR_ANY, ctx);
- if (rl->rgi.flags & RGI_ADDR_DEFINED)
+ struct route_gateway_info ngi;
+
+ get_default_gateway(&ngi, INADDR_ANY, ctx);
+ if (ngi.flags & RGI_ADDR_DEFINED)
{
- setenv_route_addr(es, "net_gateway", rl->rgi.gateway.addr, -1);
+ setenv_route_addr(es, "net_gateway", ngi.gateway.addr, -1);
#if defined(ENABLE_DEBUG) && !defined(ENABLE_SMALL)
print_default_gateway(D_ROUTE, &rl->rgi, NULL);
#endif
@@ -668,6 +670,8 @@
dmsg(D_ROUTE, "ROUTE: default_gateway=UNDEF");
}
+ get_default_gateway(&rl->rgi, remote_host != IPV4_INVALID_ADDR ? remote_host : INADDR_ANY, ctx);
+
if (rl->spec.flags & RTSA_REMOTE_HOST)
{
rl->spec.remote_host_local = test_local_addr(remote_host, &rl->rgi);
@@ -818,10 +822,12 @@
msg(D_ROUTE, "GDG6: remote_host_ipv6=%s",
remote_host_ipv6 ? print_in6_addr(*remote_host_ipv6, 0, &gc) : "n/a" );
- get_default_gateway_ipv6(&rl6->rgi6, remote_host_ipv6, ctx);
- if (rl6->rgi6.flags & RGI_ADDR_DEFINED)
+ struct route_ipv6_gateway_info ngi6;
+
+ get_default_gateway_ipv6(&ngi6, NULL, ctx);
+ if (ngi6.flags & RGI_ADDR_DEFINED)
{
- setenv_str(es, "net_gateway_ipv6", print_in6_addr(rl6->rgi6.gateway.addr_ipv6, 0, &gc));
+ setenv_str(es, "net_gateway_ipv6", print_in6_addr(ngi6.gateway.addr_ipv6, 0, &gc));
#if defined(ENABLE_DEBUG) && !defined(ENABLE_SMALL)
print_default_gateway(D_ROUTE, NULL, &rl6->rgi6);
#endif
@@ -831,6 +837,8 @@
dmsg(D_ROUTE, "ROUTE6: default_gateway=UNDEF");
}
+ get_default_gateway_ipv6(&rl6->rgi6, remote_host_ipv6, ctx);
+
if (is_route_parm_defined( remote_endpoint ))
{
if (inet_pton( AF_INET6, remote_endpoint,
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/902?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: Ifc54be34101c0eb0f3dc479a9480d7219628cc76
Gerrit-Change-Number: 902
Gerrit-PatchSet: 1
Gerrit-Owner: mrbff <marco@...2726...>
Gerrit-Reviewer: flichtenheld <frank@...2641...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@lists.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...1227...>
Gerrit-Attention: flichtenheld <frank@...2641...>
Gerrit-MessageType: newchange
[-- Attachment #2: Type: text/html, Size: 6439 bytes --]
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Openvpn-devel] [S] Change in openvpn[master]: route: handle default gateway (net_gateway) and nexthop towards VPN s...
[not found] <gerrit.1758894427000.I16d90221d0a75193035253817ff195f6da9dc0b3@...2715...>
@ 2025-09-26 13:47 ` mrbff (Code Review)
2025-11-15 17:07 ` cron2 (Code Review)
` (9 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: mrbff (Code Review) @ 2025-09-26 13:47 UTC (permalink / raw)
To: plaisthos <arne-openvpn@; +Cc: openvpn-devel
[-- Attachment #1: Type: text/plain, Size: 3913 bytes --]
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/+/1222?usp=email
to review the following change.
Change subject: route: handle default gateway (net_gateway) and nexthop towards VPN server separately
......................................................................
route: handle default gateway (net_gateway) and nexthop towards VPN server separately
Right now there is the assumption that the gateway used for net_gateway is the same used to reach the VPN server.
However, these two gateways may be different (i.e. when there is a specific hostroute for the VPN server using a different nexthop).
For this reason we must adapt init_route_list() to fetch the two gateways separately.
Change-Id: I16d90221d0a75193035253817ff195f6da9dc0b3
Signed-off-by: Marco Baffo <marco@...2726...>
---
M src/openvpn/route.c
1 file changed, 14 insertions(+), 6 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/22/1222/1
diff --git a/src/openvpn/route.c b/src/openvpn/route.c
index 156a99e..29c7d7c 100644
--- a/src/openvpn/route.c
+++ b/src/openvpn/route.c
@@ -624,10 +624,12 @@
rl->spec.flags |= RTSA_DEFAULT_METRIC;
}
- get_default_gateway(&rl->rgi, remote_host != IPV4_INVALID_ADDR ? remote_host : INADDR_ANY, ctx);
- if (rl->rgi.flags & RGI_ADDR_DEFINED)
+ struct route_gateway_info ngi;
+
+ get_default_gateway(&ngi, INADDR_ANY, ctx);
+ if (ngi.flags & RGI_ADDR_DEFINED)
{
- setenv_route_addr(es, "net_gateway", rl->rgi.gateway.addr, -1);
+ setenv_route_addr(es, "net_gateway", ngi.gateway.addr, -1);
#if defined(ENABLE_DEBUG) && !defined(ENABLE_SMALL)
print_default_gateway(D_ROUTE, &rl->rgi, NULL);
#endif
@@ -637,6 +639,8 @@
dmsg(D_ROUTE, "ROUTE: default_gateway=UNDEF");
}
+ get_default_gateway(&rl->rgi, remote_host != IPV4_INVALID_ADDR ? remote_host : INADDR_ANY, ctx);
+
if (rl->spec.flags & RTSA_REMOTE_HOST)
{
rl->spec.remote_host_local = test_local_addr(remote_host, &rl->rgi);
@@ -778,10 +782,12 @@
msg(D_ROUTE, "GDG6: remote_host_ipv6=%s",
remote_host_ipv6 ? print_in6_addr(*remote_host_ipv6, 0, &gc) : "n/a");
- get_default_gateway_ipv6(&rl6->rgi6, remote_host_ipv6, ctx);
- if (rl6->rgi6.flags & RGI_ADDR_DEFINED)
+ struct route_ipv6_gateway_info ngi6;
+
+ get_default_gateway_ipv6(&ngi6, NULL, ctx);
+ if (ngi6.flags & RGI_ADDR_DEFINED)
{
- setenv_str(es, "net_gateway_ipv6", print_in6_addr(rl6->rgi6.gateway.addr_ipv6, 0, &gc));
+ setenv_str(es, "net_gateway_ipv6", print_in6_addr(ngi6.gateway.addr_ipv6, 0, &gc));
#if defined(ENABLE_DEBUG) && !defined(ENABLE_SMALL)
print_default_gateway(D_ROUTE, NULL, &rl6->rgi6);
#endif
@@ -791,6 +797,8 @@
dmsg(D_ROUTE, "ROUTE6: default_gateway=UNDEF");
}
+ get_default_gateway_ipv6(&rl6->rgi6, remote_host_ipv6, ctx);
+
if (is_route_parm_defined(remote_endpoint))
{
if (inet_pton(AF_INET6, remote_endpoint, &rl6->remote_endpoint_ipv6) == 1)
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1222?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: I16d90221d0a75193035253817ff195f6da9dc0b3
Gerrit-Change-Number: 1222
Gerrit-PatchSet: 1
Gerrit-Owner: mrbff <marco@...2726...>
Gerrit-Reviewer: flichtenheld <frank@...2641...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@lists.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...1227...>
Gerrit-Attention: flichtenheld <frank@...2641...>
Gerrit-MessageType: newchange
[-- Attachment #2: Type: text/html, Size: 6536 bytes --]
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Openvpn-devel] [S] Change in openvpn[master]: route: handle default gateway (net_gateway) and nexthop towards VPN s...
[not found] <gerrit.1740476988000.Ifc54be34101c0eb0f3dc479a9480d7219628cc76@...2715...>
2025-02-25 9:49 ` mrbff (Code Review)
@ 2025-09-26 20:06 ` mrbff (Code Review)
1 sibling, 0 replies; 14+ messages in thread
From: mrbff (Code Review) @ 2025-09-26 20:06 UTC (permalink / raw)
Cc: plaisthos <arne-openvpn@
[-- Attachment #1: Type: text/plain, Size: 841 bytes --]
mrbff has abandoned this change. ( http://gerrit.openvpn.net/c/openvpn/+/902?usp=email )
Change subject: route: handle default gateway (net_gateway) and nexthop towards VPN server separately
......................................................................
Abandoned
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/902?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: Ifc54be34101c0eb0f3dc479a9480d7219628cc76
Gerrit-Change-Number: 902
Gerrit-PatchSet: 1
Gerrit-Owner: mrbff <marco@...2726...>
Gerrit-Reviewer: flichtenheld <frank@...2641...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@lists.sourceforge.net>
Gerrit-MessageType: abandon
[-- Attachment #2: Type: text/html, Size: 1449 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Openvpn-devel] [S] Change in openvpn[master]: route: handle default gateway (net_gateway) and nexthop towards VPN s...
[not found] <gerrit.1758894427000.I16d90221d0a75193035253817ff195f6da9dc0b3@...2715...>
2025-09-26 13:47 ` [Openvpn-devel] [S] Change in openvpn[master]: route: handle default gateway (net_gateway) and nexthop towards VPN s mrbff (Code Review)
@ 2025-11-15 17:07 ` cron2 (Code Review)
2025-11-18 5:57 ` mrbff (Code Review)
` (8 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: cron2 (Code Review) @ 2025-11-15 17:07 UTC (permalink / raw)
To: mrbff <marco@; +Cc: plaisthos <arne-openvpn@
[-- Attachment #1: Type: text/plain, Size: 2863 bytes --]
Attention is currently required from: flichtenheld, mrbff, plaisthos.
cron2 has posted comments on this change by mrbff. ( http://gerrit.openvpn.net/c/openvpn/+/1222?usp=email )
Change subject: route: handle default gateway (net_gateway) and nexthop towards VPN server separately
......................................................................
Patch Set 2: Code-Review-1
(1 comment)
Patchset:
PS2:
This is only half-working for me. Triggered by https://github.com/OpenVPN/openvpn/issues/890 I have built a testbed to reproduce this.
- ssh -R *:12345:conn-test-server.openvpn.org:51194 $linuxserver
- on the linux server, run `openvpn --client --remote 127.0.0.5 51194 tcp ... --route 1.1.1.1 255.255.255.255 net_gateway`
it will do both gateway lookups, and setenv `net_gateway` accordingly
```
2025-11-15 17:57:26 net_route_v4_best_gw query: dst 0.0.0.0
2025-11-15 17:57:26 net_route_v4_best_gw result: via 194.97.140.30 dev enp0s18
2025-11-15 17:57:26 net_route_v4_best_gw query: dst 127.0.0.5
2025-11-15 17:57:26 net_route_v4_best_gw result: via 0.0.0.0 dev lo
2025-11-15 17:57:26 GDG6: remote_host_ipv6=n/a
2025-11-15 17:57:26 net_route_v6_best_gw query: dst ::
2025-11-15 17:57:26 net_route_v6_best_gw result: via 2001:608:0:814::ffff dev enp0s18
2025-11-15 17:57:26 net_route_v6_best_gw query: dst ::
2025-11-15 17:57:26 net_route_v6_best_gw result: via 2001:608:0:814::ffff dev enp0s18
```
but the gateway address used for `net_gateway` is the one from the second lookup
```
2025-11-15 18:03:45 net_route_v4_add: 1.1.1.1/32 via 0.0.0.0 dev [NULL] table 0 metric -1
2025-11-15 18:03:45 sitnl_send: rtnl: generic error (-19): No such device
2025-11-15 18:03:45 ERROR: Linux route add command failed
```
so we might need to store the `ngi` in the `struct route-list` as well, and depending on use case use `rgi` or `ngi` - for the bypass-routes, we want `rgi`, for `get_special_addr()` use case, we want `ngi`...
right?
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1222?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: I16d90221d0a75193035253817ff195f6da9dc0b3
Gerrit-Change-Number: 1222
Gerrit-PatchSet: 2
Gerrit-Owner: mrbff <marco@...2726...>
Gerrit-Reviewer: cron2 <gert@...1296...>
Gerrit-Reviewer: flichtenheld <frank@...2641...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@lists.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...1227...>
Gerrit-Attention: flichtenheld <frank@...2641...>
Gerrit-Attention: mrbff <marco@...2726...>
Gerrit-Comment-Date: Sat, 15 Nov 2025 17:07:03 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
[-- Attachment #2: Type: text/html, Size: 4713 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Openvpn-devel] [S] Change in openvpn[master]: route: handle default gateway (net_gateway) and nexthop towards VPN s...
[not found] <gerrit.1758894427000.I16d90221d0a75193035253817ff195f6da9dc0b3@...2715...>
2025-09-26 13:47 ` [Openvpn-devel] [S] Change in openvpn[master]: route: handle default gateway (net_gateway) and nexthop towards VPN s mrbff (Code Review)
2025-11-15 17:07 ` cron2 (Code Review)
@ 2025-11-18 5:57 ` mrbff (Code Review)
2025-11-18 5:58 ` mrbff (Code Review)
` (7 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: mrbff (Code Review) @ 2025-11-18 5:57 UTC (permalink / raw)
To: plaisthos <arne-openvpn@; +Cc: openvpn-devel
[-- Attachment #1: Type: text/plain, Size: 4894 bytes --]
Attention is currently required from: cron2, flichtenheld, mrbff, plaisthos.
Hello cron2, flichtenheld, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1222?usp=email
to look at the new patch set (#3).
The following approvals got outdated and were removed:
Code-Review-1 by cron2
Change subject: route: handle default gateway (net_gateway) and nexthop towards VPN server separately
......................................................................
route: handle default gateway (net_gateway) and nexthop towards VPN server separately
Right now there is the assumption that the gateway used for net_gateway is the same used to reach the VPN server.
However, these two gateways may be different (i.e. when there is a specific hostroute for the VPN server using a different nexthop).
For this reason we must adapt init_route_list() to fetch the two gateways separately.
Github: fixes OpenVPN/openvpn#890
Change-Id: I16d90221d0a75193035253817ff195f6da9dc0b3
Signed-off-by: Marco Baffo <marco@...2726...>
---
M src/openvpn/route.c
M src/openvpn/route.h
2 files changed, 15 insertions(+), 8 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/22/1222/3
diff --git a/src/openvpn/route.c b/src/openvpn/route.c
index 7d988da..ad4722b 100644
--- a/src/openvpn/route.c
+++ b/src/openvpn/route.c
@@ -257,9 +257,9 @@
{
if (rl)
{
- if (rl->rgi.flags & RGI_ADDR_DEFINED)
+ if (rl->ngi.flags & RGI_ADDR_DEFINED)
{
- *out = rl->rgi.gateway.addr;
+ *out = rl->ngi.gateway.addr;
}
else
{
@@ -624,10 +624,10 @@
rl->spec.flags |= RTSA_DEFAULT_METRIC;
}
- get_default_gateway(&rl->rgi, remote_host != IPV4_INVALID_ADDR ? remote_host : INADDR_ANY, ctx);
- if (rl->rgi.flags & RGI_ADDR_DEFINED)
+ get_default_gateway(&rl->ngi, INADDR_ANY, ctx);
+ if (rl->ngi.flags & RGI_ADDR_DEFINED)
{
- setenv_route_addr(es, "net_gateway", rl->rgi.gateway.addr, -1);
+ setenv_route_addr(es, "net_gateway", rl->ngi.gateway.addr, -1);
#if defined(ENABLE_DEBUG) && !defined(ENABLE_SMALL)
print_default_gateway(D_ROUTE, &rl->rgi, NULL);
#endif
@@ -637,6 +637,8 @@
dmsg(D_ROUTE, "ROUTE: default_gateway=UNDEF");
}
+ get_default_gateway(&rl->rgi, remote_host != IPV4_INVALID_ADDR ? remote_host : INADDR_ANY, ctx);
+
if (rl->spec.flags & RTSA_REMOTE_HOST)
{
rl->spec.remote_host_local = test_local_addr(remote_host, &rl->rgi);
@@ -773,10 +775,12 @@
msg(D_ROUTE, "GDG6: remote_host_ipv6=%s",
remote_host_ipv6 ? print_in6_addr(*remote_host_ipv6, 0, &gc) : "n/a");
- get_default_gateway_ipv6(&rl6->rgi6, remote_host_ipv6, ctx);
- if (rl6->rgi6.flags & RGI_ADDR_DEFINED)
+ struct route_ipv6_gateway_info ngi6;
+
+ get_default_gateway_ipv6(&ngi6, NULL, ctx);
+ if (ngi6.flags & RGI_ADDR_DEFINED)
{
- setenv_str(es, "net_gateway_ipv6", print_in6_addr(rl6->rgi6.gateway.addr_ipv6, 0, &gc));
+ setenv_str(es, "net_gateway_ipv6", print_in6_addr(ngi6.gateway.addr_ipv6, 0, &gc));
#if defined(ENABLE_DEBUG) && !defined(ENABLE_SMALL)
print_default_gateway(D_ROUTE, NULL, &rl6->rgi6);
#endif
@@ -786,6 +790,8 @@
dmsg(D_ROUTE, "ROUTE6: default_gateway=UNDEF");
}
+ get_default_gateway_ipv6(&rl6->rgi6, remote_host_ipv6, ctx);
+
if (is_route_parm_defined(remote_endpoint))
{
if (inet_pton(AF_INET6, remote_endpoint, &rl6->remote_endpoint_ipv6) == 1)
diff --git a/src/openvpn/route.h b/src/openvpn/route.h
index 54fa137..71248dc 100644
--- a/src/openvpn/route.h
+++ b/src/openvpn/route.h
@@ -234,6 +234,7 @@
struct route_special_addr spec;
struct route_gateway_info rgi;
+ struct route_gateway_info ngi;
unsigned int flags; /* RG_x flags */
struct route_ipv4 *routes;
struct gc_arena gc;
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1222?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: I16d90221d0a75193035253817ff195f6da9dc0b3
Gerrit-Change-Number: 1222
Gerrit-PatchSet: 3
Gerrit-Owner: mrbff <marco@...2726...>
Gerrit-Reviewer: cron2 <gert@...1296...>
Gerrit-Reviewer: flichtenheld <frank@...2641...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@lists.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...1227...>
Gerrit-Attention: cron2 <gert@...1296...>
Gerrit-Attention: flichtenheld <frank@...2641...>
Gerrit-Attention: mrbff <marco@...2726...>
[-- Attachment #2: Type: text/html, Size: 8175 bytes --]
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Openvpn-devel] [S] Change in openvpn[master]: route: handle default gateway (net_gateway) and nexthop towards VPN s...
[not found] <gerrit.1758894427000.I16d90221d0a75193035253817ff195f6da9dc0b3@...2715...>
` (2 preceding siblings ...)
2025-11-18 5:57 ` mrbff (Code Review)
@ 2025-11-18 5:58 ` mrbff (Code Review)
2025-11-18 18:42 ` cron2 (Code Review)
` (6 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: mrbff (Code Review) @ 2025-11-18 5:58 UTC (permalink / raw)
Cc: plaisthos <arne-openvpn@
[-- Attachment #1: Type: text/plain, Size: 1408 bytes --]
Attention is currently required from: cron2, flichtenheld, plaisthos.
mrbff has posted comments on this change by mrbff. ( http://gerrit.openvpn.net/c/openvpn/+/1222?usp=email )
Change subject: route: handle default gateway (net_gateway) and nexthop towards VPN server separately
......................................................................
Patch Set 3:
(1 comment)
Patchset:
PS2:
> This is only half-working for me. Triggered by https://github. […]
Done
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1222?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: I16d90221d0a75193035253817ff195f6da9dc0b3
Gerrit-Change-Number: 1222
Gerrit-PatchSet: 3
Gerrit-Owner: mrbff <marco@...2726...>
Gerrit-Reviewer: cron2 <gert@...1296...>
Gerrit-Reviewer: flichtenheld <frank@...2641...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@lists.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...1227...>
Gerrit-Attention: cron2 <gert@...1296...>
Gerrit-Attention: flichtenheld <frank@...2641...>
Gerrit-Comment-Date: Tue, 18 Nov 2025 05:58:46 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: cron2 <gert@...1296...>
[-- Attachment #2: Type: text/html, Size: 2766 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Openvpn-devel] [S] Change in openvpn[master]: route: handle default gateway (net_gateway) and nexthop towards VPN s...
[not found] <gerrit.1758894427000.I16d90221d0a75193035253817ff195f6da9dc0b3@...2715...>
` (3 preceding siblings ...)
2025-11-18 5:58 ` mrbff (Code Review)
@ 2025-11-18 18:42 ` cron2 (Code Review)
2025-11-19 3:22 ` mrbff (Code Review)
` (5 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: cron2 (Code Review) @ 2025-11-18 18:42 UTC (permalink / raw)
To: mrbff <marco@; +Cc: plaisthos <arne-openvpn@
[-- Attachment #1: Type: text/plain, Size: 1609 bytes --]
Attention is currently required from: flichtenheld, mrbff, plaisthos.
cron2 has posted comments on this change by mrbff. ( http://gerrit.openvpn.net/c/openvpn/+/1222?usp=email )
Change subject: route: handle default gateway (net_gateway) and nexthop towards VPN server separately
......................................................................
Patch Set 3:
(1 comment)
Patchset:
PS2:
> Done
I think it would make sense to do the same for IPv6 as well (route_ipv6_list, of course). We do not have such a special target yet, but keeping the infra symmetric sounds like a good idea...?
(The IPv4 part looks good)
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1222?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: I16d90221d0a75193035253817ff195f6da9dc0b3
Gerrit-Change-Number: 1222
Gerrit-PatchSet: 3
Gerrit-Owner: mrbff <marco@...2726...>
Gerrit-Reviewer: cron2 <gert@...1296...>
Gerrit-Reviewer: flichtenheld <frank@...2641...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@lists.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...1227...>
Gerrit-Attention: flichtenheld <frank@...2641...>
Gerrit-Attention: mrbff <marco@...2726...>
Gerrit-Comment-Date: Tue, 18 Nov 2025 18:42:28 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: cron2 <gert@...1296...>
Comment-In-Reply-To: mrbff <marco@...2726...>
[-- Attachment #2: Type: text/html, Size: 3080 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Openvpn-devel] [S] Change in openvpn[master]: route: handle default gateway (net_gateway) and nexthop towards VPN s...
[not found] <gerrit.1758894427000.I16d90221d0a75193035253817ff195f6da9dc0b3@...2715...>
` (4 preceding siblings ...)
2025-11-18 18:42 ` cron2 (Code Review)
@ 2025-11-19 3:22 ` mrbff (Code Review)
2025-11-19 3:23 ` mrbff (Code Review)
` (4 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: mrbff (Code Review) @ 2025-11-19 3:22 UTC (permalink / raw)
To: plaisthos <arne-openvpn@; +Cc: openvpn-devel
[-- Attachment #1: Type: text/plain, Size: 5186 bytes --]
Attention is currently required from: flichtenheld, mrbff, plaisthos.
Hello cron2, flichtenheld, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1222?usp=email
to look at the new patch set (#4).
Change subject: route: handle default gateway (net_gateway) and nexthop towards VPN server separately
......................................................................
route: handle default gateway (net_gateway) and nexthop towards VPN server separately
Right now there is the assumption that the gateway used for net_gateway is the same used to reach the VPN server.
However, these two gateways may be different (i.e. when there is a specific hostroute for the VPN server using a different nexthop).
For this reason we must adapt init_route_list() to fetch the two gateways separately.
Github: fixes OpenVPN/openvpn#890
Change-Id: I16d90221d0a75193035253817ff195f6da9dc0b3
Signed-off-by: Marco Baffo <marco@...2726...>
---
M src/openvpn/route.c
M src/openvpn/route.h
2 files changed, 16 insertions(+), 10 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/22/1222/4
diff --git a/src/openvpn/route.c b/src/openvpn/route.c
index 7d988da..770300a 100644
--- a/src/openvpn/route.c
+++ b/src/openvpn/route.c
@@ -257,9 +257,9 @@
{
if (rl)
{
- if (rl->rgi.flags & RGI_ADDR_DEFINED)
+ if (rl->ngi.flags & RGI_ADDR_DEFINED)
{
- *out = rl->rgi.gateway.addr;
+ *out = rl->ngi.gateway.addr;
}
else
{
@@ -624,10 +624,10 @@
rl->spec.flags |= RTSA_DEFAULT_METRIC;
}
- get_default_gateway(&rl->rgi, remote_host != IPV4_INVALID_ADDR ? remote_host : INADDR_ANY, ctx);
- if (rl->rgi.flags & RGI_ADDR_DEFINED)
+ get_default_gateway(&rl->ngi, INADDR_ANY, ctx);
+ if (rl->ngi.flags & RGI_ADDR_DEFINED)
{
- setenv_route_addr(es, "net_gateway", rl->rgi.gateway.addr, -1);
+ setenv_route_addr(es, "net_gateway", rl->ngi.gateway.addr, -1);
#if defined(ENABLE_DEBUG) && !defined(ENABLE_SMALL)
print_default_gateway(D_ROUTE, &rl->rgi, NULL);
#endif
@@ -637,6 +637,8 @@
dmsg(D_ROUTE, "ROUTE: default_gateway=UNDEF");
}
+ get_default_gateway(&rl->rgi, remote_host != IPV4_INVALID_ADDR ? remote_host : INADDR_ANY, ctx);
+
if (rl->spec.flags & RTSA_REMOTE_HOST)
{
rl->spec.remote_host_local = test_local_addr(remote_host, &rl->rgi);
@@ -773,10 +775,10 @@
msg(D_ROUTE, "GDG6: remote_host_ipv6=%s",
remote_host_ipv6 ? print_in6_addr(*remote_host_ipv6, 0, &gc) : "n/a");
- get_default_gateway_ipv6(&rl6->rgi6, remote_host_ipv6, ctx);
- if (rl6->rgi6.flags & RGI_ADDR_DEFINED)
+ get_default_gateway_ipv6(&rl6->ngi6, NULL, ctx);
+ if (rl6->ngi6.flags & RGI_ADDR_DEFINED)
{
- setenv_str(es, "net_gateway_ipv6", print_in6_addr(rl6->rgi6.gateway.addr_ipv6, 0, &gc));
+ setenv_str(es, "net_gateway_ipv6", print_in6_addr(rl6->ngi6.gateway.addr_ipv6, 0, &gc));
#if defined(ENABLE_DEBUG) && !defined(ENABLE_SMALL)
print_default_gateway(D_ROUTE, NULL, &rl6->rgi6);
#endif
@@ -786,6 +788,8 @@
dmsg(D_ROUTE, "ROUTE6: default_gateway=UNDEF");
}
+ get_default_gateway_ipv6(&rl6->rgi6, remote_host_ipv6, ctx);
+
if (is_route_parm_defined(remote_endpoint))
{
if (inet_pton(AF_INET6, remote_endpoint, &rl6->remote_endpoint_ipv6) == 1)
diff --git a/src/openvpn/route.h b/src/openvpn/route.h
index 54fa137..3d19dbd 100644
--- a/src/openvpn/route.h
+++ b/src/openvpn/route.h
@@ -234,7 +234,8 @@
struct route_special_addr spec;
struct route_gateway_info rgi;
- unsigned int flags; /* RG_x flags */
+ struct route_gateway_info ngi; /* net_gateway */
+ unsigned int flags; /* RG_x flags */
struct route_ipv4 *routes;
struct gc_arena gc;
};
@@ -249,7 +250,8 @@
int default_metric;
struct route_ipv6_gateway_info rgi6;
- unsigned int flags; /* RG_x flags, see route_option_list */
+ struct route_ipv6_gateway_info ngi6; /* net_gateway_ipv6 */
+ unsigned int flags; /* RG_x flags, see route_option_list */
struct route_ipv6 *routes_ipv6;
struct gc_arena gc;
};
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1222?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: I16d90221d0a75193035253817ff195f6da9dc0b3
Gerrit-Change-Number: 1222
Gerrit-PatchSet: 4
Gerrit-Owner: mrbff <marco@...2726...>
Gerrit-Reviewer: cron2 <gert@...1296...>
Gerrit-Reviewer: flichtenheld <frank@...2641...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@lists.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...1227...>
Gerrit-Attention: flichtenheld <frank@...2641...>
Gerrit-Attention: mrbff <marco@...2726...>
[-- Attachment #2: Type: text/html, Size: 8690 bytes --]
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Openvpn-devel] [S] Change in openvpn[master]: route: handle default gateway (net_gateway) and nexthop towards VPN s...
[not found] <gerrit.1758894427000.I16d90221d0a75193035253817ff195f6da9dc0b3@...2715...>
` (5 preceding siblings ...)
2025-11-19 3:22 ` mrbff (Code Review)
@ 2025-11-19 3:23 ` mrbff (Code Review)
2025-11-19 11:40 ` cron2 (Code Review)
` (3 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: mrbff (Code Review) @ 2025-11-19 3:23 UTC (permalink / raw)
Cc: plaisthos <arne-openvpn@
[-- Attachment #1: Type: text/plain, Size: 1487 bytes --]
Attention is currently required from: cron2, flichtenheld, plaisthos.
mrbff has posted comments on this change by mrbff. ( http://gerrit.openvpn.net/c/openvpn/+/1222?usp=email )
Change subject: route: handle default gateway (net_gateway) and nexthop towards VPN server separately
......................................................................
Patch Set 4:
(1 comment)
Patchset:
PS2:
> I think it would make sense to do the same for IPv6 as well (route_ipv6_list, of course). […]
yes, ok np
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1222?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: I16d90221d0a75193035253817ff195f6da9dc0b3
Gerrit-Change-Number: 1222
Gerrit-PatchSet: 4
Gerrit-Owner: mrbff <marco@...2726...>
Gerrit-Reviewer: cron2 <gert@...1296...>
Gerrit-Reviewer: flichtenheld <frank@...2641...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@lists.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...1227...>
Gerrit-Attention: cron2 <gert@...1296...>
Gerrit-Attention: flichtenheld <frank@...2641...>
Gerrit-Comment-Date: Wed, 19 Nov 2025 03:23:07 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: cron2 <gert@...1296...>
Comment-In-Reply-To: mrbff <marco@...2726...>
[-- Attachment #2: Type: text/html, Size: 2886 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Openvpn-devel] [S] Change in openvpn[master]: route: handle default gateway (net_gateway) and nexthop towards VPN s...
[not found] <gerrit.1758894427000.I16d90221d0a75193035253817ff195f6da9dc0b3@...2715...>
` (6 preceding siblings ...)
2025-11-19 3:23 ` mrbff (Code Review)
@ 2025-11-19 11:40 ` cron2 (Code Review)
2025-11-19 11:40 ` [Openvpn-devel] [PATCH v4] route: handle default gateway (net_gateway) and nexthop towards VPN server separately Gert Doering
` (2 subsequent siblings)
10 siblings, 0 replies; 14+ messages in thread
From: cron2 (Code Review) @ 2025-11-19 11:40 UTC (permalink / raw)
To: mrbff <marco@; +Cc: plaisthos <arne-openvpn@
[-- Attachment #1: Type: text/plain, Size: 1260 bytes --]
Attention is currently required from: flichtenheld, mrbff, plaisthos.
cron2 has posted comments on this change by mrbff. ( http://gerrit.openvpn.net/c/openvpn/+/1222?usp=email )
Change subject: route: handle default gateway (net_gateway) and nexthop towards VPN server separately
......................................................................
Patch Set 4: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1222?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: I16d90221d0a75193035253817ff195f6da9dc0b3
Gerrit-Change-Number: 1222
Gerrit-PatchSet: 4
Gerrit-Owner: mrbff <marco@...2726...>
Gerrit-Reviewer: cron2 <gert@...1296...>
Gerrit-Reviewer: flichtenheld <frank@...2641...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@lists.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...1227...>
Gerrit-Attention: flichtenheld <frank@...2641...>
Gerrit-Attention: mrbff <marco@...2726...>
Gerrit-Comment-Date: Wed, 19 Nov 2025 11:40:26 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
[-- Attachment #2: Type: text/html, Size: 2280 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Openvpn-devel] [PATCH v4] route: handle default gateway (net_gateway) and nexthop towards VPN server separately
[not found] <gerrit.1758894427000.I16d90221d0a75193035253817ff195f6da9dc0b3@...2715...>
` (7 preceding siblings ...)
2025-11-19 11:40 ` cron2 (Code Review)
@ 2025-11-19 11:40 ` Gert Doering
2025-11-19 13:41 ` [Openvpn-devel] [PATCH applied] " Gert Doering
2025-11-19 13:41 ` [Openvpn-devel] [S] Change in openvpn[master]: route: handle default gateway (net_gateway) and nexthop towards VPN s cron2 (Code Review)
2025-11-19 13:41 ` cron2 (Code Review)
10 siblings, 1 reply; 14+ messages in thread
From: Gert Doering @ 2025-11-19 11:40 UTC (permalink / raw)
To: openvpn-devel
From: Marco Baffo <marco@...2726...>
Right now there is the assumption that the gateway used for net_gateway is the same used to reach the VPN server.
However, these two gateways may be different (i.e. when there is a specific hostroute for the VPN server using a different nexthop).
For this reason we must adapt init_route_list() to fetch the two gateways separately.
Github: fixes OpenVPN/openvpn#890
Change-Id: I16d90221d0a75193035253817ff195f6da9dc0b3
Signed-off-by: Marco Baffo <marco@...2726...>
Acked-by: Gert Doering <gert@...1296...>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1222
---
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/+/1222
This mail reflects revision 4 of this Change.
Acked-by according to Gerrit (reflected above):
Gert Doering <gert@...1296...>
diff --git a/src/openvpn/route.c b/src/openvpn/route.c
index 7d988da..770300a 100644
--- a/src/openvpn/route.c
+++ b/src/openvpn/route.c
@@ -257,9 +257,9 @@
{
if (rl)
{
- if (rl->rgi.flags & RGI_ADDR_DEFINED)
+ if (rl->ngi.flags & RGI_ADDR_DEFINED)
{
- *out = rl->rgi.gateway.addr;
+ *out = rl->ngi.gateway.addr;
}
else
{
@@ -624,10 +624,10 @@
rl->spec.flags |= RTSA_DEFAULT_METRIC;
}
- get_default_gateway(&rl->rgi, remote_host != IPV4_INVALID_ADDR ? remote_host : INADDR_ANY, ctx);
- if (rl->rgi.flags & RGI_ADDR_DEFINED)
+ get_default_gateway(&rl->ngi, INADDR_ANY, ctx);
+ if (rl->ngi.flags & RGI_ADDR_DEFINED)
{
- setenv_route_addr(es, "net_gateway", rl->rgi.gateway.addr, -1);
+ setenv_route_addr(es, "net_gateway", rl->ngi.gateway.addr, -1);
#if defined(ENABLE_DEBUG) && !defined(ENABLE_SMALL)
print_default_gateway(D_ROUTE, &rl->rgi, NULL);
#endif
@@ -637,6 +637,8 @@
dmsg(D_ROUTE, "ROUTE: default_gateway=UNDEF");
}
+ get_default_gateway(&rl->rgi, remote_host != IPV4_INVALID_ADDR ? remote_host : INADDR_ANY, ctx);
+
if (rl->spec.flags & RTSA_REMOTE_HOST)
{
rl->spec.remote_host_local = test_local_addr(remote_host, &rl->rgi);
@@ -773,10 +775,10 @@
msg(D_ROUTE, "GDG6: remote_host_ipv6=%s",
remote_host_ipv6 ? print_in6_addr(*remote_host_ipv6, 0, &gc) : "n/a");
- get_default_gateway_ipv6(&rl6->rgi6, remote_host_ipv6, ctx);
- if (rl6->rgi6.flags & RGI_ADDR_DEFINED)
+ get_default_gateway_ipv6(&rl6->ngi6, NULL, ctx);
+ if (rl6->ngi6.flags & RGI_ADDR_DEFINED)
{
- setenv_str(es, "net_gateway_ipv6", print_in6_addr(rl6->rgi6.gateway.addr_ipv6, 0, &gc));
+ setenv_str(es, "net_gateway_ipv6", print_in6_addr(rl6->ngi6.gateway.addr_ipv6, 0, &gc));
#if defined(ENABLE_DEBUG) && !defined(ENABLE_SMALL)
print_default_gateway(D_ROUTE, NULL, &rl6->rgi6);
#endif
@@ -786,6 +788,8 @@
dmsg(D_ROUTE, "ROUTE6: default_gateway=UNDEF");
}
+ get_default_gateway_ipv6(&rl6->rgi6, remote_host_ipv6, ctx);
+
if (is_route_parm_defined(remote_endpoint))
{
if (inet_pton(AF_INET6, remote_endpoint, &rl6->remote_endpoint_ipv6) == 1)
diff --git a/src/openvpn/route.h b/src/openvpn/route.h
index 54fa137..3d19dbd 100644
--- a/src/openvpn/route.h
+++ b/src/openvpn/route.h
@@ -234,7 +234,8 @@
struct route_special_addr spec;
struct route_gateway_info rgi;
- unsigned int flags; /* RG_x flags */
+ struct route_gateway_info ngi; /* net_gateway */
+ unsigned int flags; /* RG_x flags */
struct route_ipv4 *routes;
struct gc_arena gc;
};
@@ -249,7 +250,8 @@
int default_metric;
struct route_ipv6_gateway_info rgi6;
- unsigned int flags; /* RG_x flags, see route_option_list */
+ struct route_ipv6_gateway_info ngi6; /* net_gateway_ipv6 */
+ unsigned int flags; /* RG_x flags, see route_option_list */
struct route_ipv6 *routes_ipv6;
struct gc_arena gc;
};
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Openvpn-devel] [PATCH applied] Re: route: handle default gateway (net_gateway) and nexthop towards VPN server separately
2025-11-19 11:40 ` [Openvpn-devel] [PATCH v4] route: handle default gateway (net_gateway) and nexthop towards VPN server separately Gert Doering
@ 2025-11-19 13:41 ` Gert Doering
0 siblings, 0 replies; 14+ messages in thread
From: Gert Doering @ 2025-11-19 13:41 UTC (permalink / raw)
To: Marco Baffo <marco@; +Cc: openvpn-devel
In it goes, at last... I was wondering for a long time if we really need
this, but it turns out that we have users that do stuff like "talk openvpn
via a proxy on 127.0.0.5" plus "--route 1.1.1.1 net_gateway" and this now
broke with 2.7* (see GH #890). The initial patch fixed $env{net_gateway}
but not "--route net_gateway" - for that we really need to store the
two different sorts of gateway in the "route_list" / "route_ipv6_list"
structures.
The log will look a bit redundant now
2025-11-19 12:40:14 net_route_v4_best_gw query: dst 0.0.0.0
2025-11-19 12:40:14 net_route_v4_best_gw result: via 194.97.140.30 dev enp0s18
2025-11-19 12:40:14 net_route_v4_best_gw query: dst 0.0.0.0
2025-11-19 12:40:14 net_route_v4_best_gw result: via 194.97.140.30 dev enp0s18
2025-11-19 12:40:14 net_route_v6_best_gw query: dst ::
2025-11-19 12:40:14 net_route_v6_best_gw result: via 2001:608:0:814::ffff dev enp0s18
2025-11-19 12:40:14 net_route_v6_best_gw query: dst ::1
2025-11-19 12:40:14 net_route_v6_best_gw result: via :: dev lo
(this was "--remote ::1") - but adding another clause to "only call the
other gateway query if the address is different" or more #ifdefs to
"only do this on Linux and Windows where it makes a difference" would
have been a bit excessive...
Now let's see if we'll hit even more corner cases :-) - it passes all
my normal tests, plus the things I've learned from #860.
Your patch has been applied to the master branch.
commit 2777cdd3783776a91514804233c5e2b715d11d64 (master)
Author: Marco Baffo
Date: Wed Nov 19 12:40:35 2025 +0100
route: handle default gateway (net_gateway) and nexthop towards VPN server separately
Signed-off-by: Marco Baffo <marco@...2726...>
Acked-by: Gert Doering <gert@...1296...>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1222
Message-Id: <20251119114041.17665-1-gert@...1296...>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg34529.html
Signed-off-by: Gert Doering <gert@...1296...>
--
kind regards,
Gert Doering
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Openvpn-devel] [S] Change in openvpn[master]: route: handle default gateway (net_gateway) and nexthop towards VPN s...
[not found] <gerrit.1758894427000.I16d90221d0a75193035253817ff195f6da9dc0b3@...2715...>
` (8 preceding siblings ...)
2025-11-19 11:40 ` [Openvpn-devel] [PATCH v4] route: handle default gateway (net_gateway) and nexthop towards VPN server separately Gert Doering
@ 2025-11-19 13:41 ` cron2 (Code Review)
2025-11-19 13:41 ` cron2 (Code Review)
10 siblings, 0 replies; 14+ messages in thread
From: cron2 (Code Review) @ 2025-11-19 13:41 UTC (permalink / raw)
To: mrbff <marco@; +Cc: openvpn-devel
[-- Attachment #1: Type: text/plain, Size: 5281 bytes --]
cron2 has uploaded a new patch set (#5) to the change originally created by mrbff. ( http://gerrit.openvpn.net/c/openvpn/+/1222?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by cron2
Change subject: route: handle default gateway (net_gateway) and nexthop towards VPN server separately
......................................................................
route: handle default gateway (net_gateway) and nexthop towards VPN server separately
Right now there is the assumption that the gateway used for net_gateway is the same used to reach the VPN server.
However, these two gateways may be different (i.e. when there is a specific hostroute for the VPN server using a different nexthop).
For this reason we must adapt init_route_list() to fetch the two gateways separately.
Github: fixes OpenVPN/openvpn#890
Change-Id: I16d90221d0a75193035253817ff195f6da9dc0b3
Signed-off-by: Marco Baffo <marco@...2726...>
Acked-by: Gert Doering <gert@...1296...>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1222
Message-Id: <20251119114041.17665-1-gert@...1296...>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg34529.html
Signed-off-by: Gert Doering <gert@...1296...>
---
M src/openvpn/route.c
M src/openvpn/route.h
2 files changed, 16 insertions(+), 10 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/22/1222/5
diff --git a/src/openvpn/route.c b/src/openvpn/route.c
index 7d988da..770300a 100644
--- a/src/openvpn/route.c
+++ b/src/openvpn/route.c
@@ -257,9 +257,9 @@
{
if (rl)
{
- if (rl->rgi.flags & RGI_ADDR_DEFINED)
+ if (rl->ngi.flags & RGI_ADDR_DEFINED)
{
- *out = rl->rgi.gateway.addr;
+ *out = rl->ngi.gateway.addr;
}
else
{
@@ -624,10 +624,10 @@
rl->spec.flags |= RTSA_DEFAULT_METRIC;
}
- get_default_gateway(&rl->rgi, remote_host != IPV4_INVALID_ADDR ? remote_host : INADDR_ANY, ctx);
- if (rl->rgi.flags & RGI_ADDR_DEFINED)
+ get_default_gateway(&rl->ngi, INADDR_ANY, ctx);
+ if (rl->ngi.flags & RGI_ADDR_DEFINED)
{
- setenv_route_addr(es, "net_gateway", rl->rgi.gateway.addr, -1);
+ setenv_route_addr(es, "net_gateway", rl->ngi.gateway.addr, -1);
#if defined(ENABLE_DEBUG) && !defined(ENABLE_SMALL)
print_default_gateway(D_ROUTE, &rl->rgi, NULL);
#endif
@@ -637,6 +637,8 @@
dmsg(D_ROUTE, "ROUTE: default_gateway=UNDEF");
}
+ get_default_gateway(&rl->rgi, remote_host != IPV4_INVALID_ADDR ? remote_host : INADDR_ANY, ctx);
+
if (rl->spec.flags & RTSA_REMOTE_HOST)
{
rl->spec.remote_host_local = test_local_addr(remote_host, &rl->rgi);
@@ -773,10 +775,10 @@
msg(D_ROUTE, "GDG6: remote_host_ipv6=%s",
remote_host_ipv6 ? print_in6_addr(*remote_host_ipv6, 0, &gc) : "n/a");
- get_default_gateway_ipv6(&rl6->rgi6, remote_host_ipv6, ctx);
- if (rl6->rgi6.flags & RGI_ADDR_DEFINED)
+ get_default_gateway_ipv6(&rl6->ngi6, NULL, ctx);
+ if (rl6->ngi6.flags & RGI_ADDR_DEFINED)
{
- setenv_str(es, "net_gateway_ipv6", print_in6_addr(rl6->rgi6.gateway.addr_ipv6, 0, &gc));
+ setenv_str(es, "net_gateway_ipv6", print_in6_addr(rl6->ngi6.gateway.addr_ipv6, 0, &gc));
#if defined(ENABLE_DEBUG) && !defined(ENABLE_SMALL)
print_default_gateway(D_ROUTE, NULL, &rl6->rgi6);
#endif
@@ -786,6 +788,8 @@
dmsg(D_ROUTE, "ROUTE6: default_gateway=UNDEF");
}
+ get_default_gateway_ipv6(&rl6->rgi6, remote_host_ipv6, ctx);
+
if (is_route_parm_defined(remote_endpoint))
{
if (inet_pton(AF_INET6, remote_endpoint, &rl6->remote_endpoint_ipv6) == 1)
diff --git a/src/openvpn/route.h b/src/openvpn/route.h
index 54fa137..3d19dbd 100644
--- a/src/openvpn/route.h
+++ b/src/openvpn/route.h
@@ -234,7 +234,8 @@
struct route_special_addr spec;
struct route_gateway_info rgi;
- unsigned int flags; /* RG_x flags */
+ struct route_gateway_info ngi; /* net_gateway */
+ unsigned int flags; /* RG_x flags */
struct route_ipv4 *routes;
struct gc_arena gc;
};
@@ -249,7 +250,8 @@
int default_metric;
struct route_ipv6_gateway_info rgi6;
- unsigned int flags; /* RG_x flags, see route_option_list */
+ struct route_ipv6_gateway_info ngi6; /* net_gateway_ipv6 */
+ unsigned int flags; /* RG_x flags, see route_option_list */
struct route_ipv6 *routes_ipv6;
struct gc_arena gc;
};
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1222?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: I16d90221d0a75193035253817ff195f6da9dc0b3
Gerrit-Change-Number: 1222
Gerrit-PatchSet: 5
Gerrit-Owner: mrbff <marco@...2726...>
Gerrit-Reviewer: cron2 <gert@...1296...>
Gerrit-Reviewer: flichtenheld <frank@...2641...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@lists.sourceforge.net>
[-- Attachment #2: Type: text/html, Size: 8749 bytes --]
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [Openvpn-devel] [S] Change in openvpn[master]: route: handle default gateway (net_gateway) and nexthop towards VPN s...
[not found] <gerrit.1758894427000.I16d90221d0a75193035253817ff195f6da9dc0b3@...2715...>
` (9 preceding siblings ...)
2025-11-19 13:41 ` [Openvpn-devel] [S] Change in openvpn[master]: route: handle default gateway (net_gateway) and nexthop towards VPN s cron2 (Code Review)
@ 2025-11-19 13:41 ` cron2 (Code Review)
10 siblings, 0 replies; 14+ messages in thread
From: cron2 (Code Review) @ 2025-11-19 13:41 UTC (permalink / raw)
To: mrbff <marco@; +Cc: plaisthos <arne-openvpn@
[-- Attachment #1: Type: text/plain, Size: 5070 bytes --]
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1222?usp=email )
Change subject: route: handle default gateway (net_gateway) and nexthop towards VPN server separately
......................................................................
route: handle default gateway (net_gateway) and nexthop towards VPN server separately
Right now there is the assumption that the gateway used for net_gateway is the same used to reach the VPN server.
However, these two gateways may be different (i.e. when there is a specific hostroute for the VPN server using a different nexthop).
For this reason we must adapt init_route_list() to fetch the two gateways separately.
Github: fixes OpenVPN/openvpn#890
Change-Id: I16d90221d0a75193035253817ff195f6da9dc0b3
Signed-off-by: Marco Baffo <marco@...2726...>
Acked-by: Gert Doering <gert@...1296...>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1222
Message-Id: <20251119114041.17665-1-gert@...1296...>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg34529.html
Signed-off-by: Gert Doering <gert@...1296...>
---
M src/openvpn/route.c
M src/openvpn/route.h
2 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/src/openvpn/route.c b/src/openvpn/route.c
index 7d988da..770300a 100644
--- a/src/openvpn/route.c
+++ b/src/openvpn/route.c
@@ -257,9 +257,9 @@
{
if (rl)
{
- if (rl->rgi.flags & RGI_ADDR_DEFINED)
+ if (rl->ngi.flags & RGI_ADDR_DEFINED)
{
- *out = rl->rgi.gateway.addr;
+ *out = rl->ngi.gateway.addr;
}
else
{
@@ -624,10 +624,10 @@
rl->spec.flags |= RTSA_DEFAULT_METRIC;
}
- get_default_gateway(&rl->rgi, remote_host != IPV4_INVALID_ADDR ? remote_host : INADDR_ANY, ctx);
- if (rl->rgi.flags & RGI_ADDR_DEFINED)
+ get_default_gateway(&rl->ngi, INADDR_ANY, ctx);
+ if (rl->ngi.flags & RGI_ADDR_DEFINED)
{
- setenv_route_addr(es, "net_gateway", rl->rgi.gateway.addr, -1);
+ setenv_route_addr(es, "net_gateway", rl->ngi.gateway.addr, -1);
#if defined(ENABLE_DEBUG) && !defined(ENABLE_SMALL)
print_default_gateway(D_ROUTE, &rl->rgi, NULL);
#endif
@@ -637,6 +637,8 @@
dmsg(D_ROUTE, "ROUTE: default_gateway=UNDEF");
}
+ get_default_gateway(&rl->rgi, remote_host != IPV4_INVALID_ADDR ? remote_host : INADDR_ANY, ctx);
+
if (rl->spec.flags & RTSA_REMOTE_HOST)
{
rl->spec.remote_host_local = test_local_addr(remote_host, &rl->rgi);
@@ -773,10 +775,10 @@
msg(D_ROUTE, "GDG6: remote_host_ipv6=%s",
remote_host_ipv6 ? print_in6_addr(*remote_host_ipv6, 0, &gc) : "n/a");
- get_default_gateway_ipv6(&rl6->rgi6, remote_host_ipv6, ctx);
- if (rl6->rgi6.flags & RGI_ADDR_DEFINED)
+ get_default_gateway_ipv6(&rl6->ngi6, NULL, ctx);
+ if (rl6->ngi6.flags & RGI_ADDR_DEFINED)
{
- setenv_str(es, "net_gateway_ipv6", print_in6_addr(rl6->rgi6.gateway.addr_ipv6, 0, &gc));
+ setenv_str(es, "net_gateway_ipv6", print_in6_addr(rl6->ngi6.gateway.addr_ipv6, 0, &gc));
#if defined(ENABLE_DEBUG) && !defined(ENABLE_SMALL)
print_default_gateway(D_ROUTE, NULL, &rl6->rgi6);
#endif
@@ -786,6 +788,8 @@
dmsg(D_ROUTE, "ROUTE6: default_gateway=UNDEF");
}
+ get_default_gateway_ipv6(&rl6->rgi6, remote_host_ipv6, ctx);
+
if (is_route_parm_defined(remote_endpoint))
{
if (inet_pton(AF_INET6, remote_endpoint, &rl6->remote_endpoint_ipv6) == 1)
diff --git a/src/openvpn/route.h b/src/openvpn/route.h
index 54fa137..3d19dbd 100644
--- a/src/openvpn/route.h
+++ b/src/openvpn/route.h
@@ -234,7 +234,8 @@
struct route_special_addr spec;
struct route_gateway_info rgi;
- unsigned int flags; /* RG_x flags */
+ struct route_gateway_info ngi; /* net_gateway */
+ unsigned int flags; /* RG_x flags */
struct route_ipv4 *routes;
struct gc_arena gc;
};
@@ -249,7 +250,8 @@
int default_metric;
struct route_ipv6_gateway_info rgi6;
- unsigned int flags; /* RG_x flags, see route_option_list */
+ struct route_ipv6_gateway_info ngi6; /* net_gateway_ipv6 */
+ unsigned int flags; /* RG_x flags, see route_option_list */
struct route_ipv6 *routes_ipv6;
struct gc_arena gc;
};
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1222?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I16d90221d0a75193035253817ff195f6da9dc0b3
Gerrit-Change-Number: 1222
Gerrit-PatchSet: 5
Gerrit-Owner: mrbff <marco@...2726...>
Gerrit-Reviewer: cron2 <gert@...1296...>
Gerrit-Reviewer: flichtenheld <frank@...2641...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@lists.sourceforge.net>
[-- Attachment #2: Type: text/html, Size: 8498 bytes --]
^ permalink raw reply related [flat|nested] 14+ messages in thread
end of thread, other threads:[~2025-11-19 13:41 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <gerrit.1758894427000.I16d90221d0a75193035253817ff195f6da9dc0b3@...2715...>
2025-09-26 13:47 ` [Openvpn-devel] [S] Change in openvpn[master]: route: handle default gateway (net_gateway) and nexthop towards VPN s mrbff (Code Review)
2025-11-15 17:07 ` cron2 (Code Review)
2025-11-18 5:57 ` mrbff (Code Review)
2025-11-18 5:58 ` mrbff (Code Review)
2025-11-18 18:42 ` cron2 (Code Review)
2025-11-19 3:22 ` mrbff (Code Review)
2025-11-19 3:23 ` mrbff (Code Review)
2025-11-19 11:40 ` cron2 (Code Review)
2025-11-19 11:40 ` [Openvpn-devel] [PATCH v4] route: handle default gateway (net_gateway) and nexthop towards VPN server separately Gert Doering
2025-11-19 13:41 ` [Openvpn-devel] [PATCH applied] " Gert Doering
2025-11-19 13:41 ` [Openvpn-devel] [S] Change in openvpn[master]: route: handle default gateway (net_gateway) and nexthop towards VPN s cron2 (Code Review)
2025-11-19 13:41 ` cron2 (Code Review)
[not found] <gerrit.1740476988000.Ifc54be34101c0eb0f3dc479a9480d7219628cc76@...2715...>
2025-02-25 9:49 ` mrbff (Code Review)
2025-09-26 20:06 ` mrbff (Code Review)
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.