From: "cron2 (Code Review)"
Date: Wed, 19 Nov 2025 13:41:31 +0000
In-Reply-To:
References:
Reply-To: gert@...1296..., arne-openvpn@...1227..., marco@...2726...,
openvpn-devel@lists.sourceforge.net, frank@...2641...
Message-ID:
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Disposition: inline
Content-Type: multipart/alternative; boundary="DVcON877xeQ="; charset=UTF-8
Subject: [Openvpn-devel] [S] Change in openvpn[master]: route: handle
default gateway (net_gateway) and nexthop towards VPN s...
List-Id:
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
To: mrbff , plaisthos , flichtenheld
Cc: openvpn-devel
--DVcON877xeQ=
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
cron2 has uploaded a new patch set (#5) to the change originally created by=
mrbff. ( http://gerrit.openvpn.net/c/openvpn/+/1222?usp=3Demail )
The following approvals got outdated and were removed:
Code-Review+2 by cron2
Change subject: route: handle default gateway (net_gateway) and nexthop tow=
ards 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 s=
eparately.
Github: fixes OpenVPN/openvpn#890
Change-Id: I16d90221d0a75193035253817ff195f6da9dc0b3
Signed-off-by: Marco Baffo
Acked-by: Gert Doering
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/msg34=
529.html
Signed-off-by: Gert Doering
---
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 =3D rl->rgi.gateway.addr;
+ *out =3D rl->ngi.gateway.addr;
}
else
{
@@ -624,10 +624,10 @@
rl->spec.flags |=3D RTSA_DEFAULT_METRIC;
}
- get_default_gateway(&rl->rgi, remote_host !=3D IPV4_INVALID_ADDR ? rem=
ote_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=3DUNDEF");
}
+ get_default_gateway(&rl->rgi, remote_host !=3D IPV4_INVALID_ADDR ? rem=
ote_host : INADDR_ANY, ctx);
+
if (rl->spec.flags & RTSA_REMOTE_HOST)
{
rl->spec.remote_host_local =3D test_local_addr(remote_host, &rl->r=
gi);
@@ -773,10 +775,10 @@
msg(D_ROUTE, "GDG6: remote_host_ipv6=3D%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.gatewa=
y.addr_ipv6, 0, &gc));
+ setenv_str(es, "net_gateway_ipv6", print_in6_addr(rl6->ngi6.gatewa=
y.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=3DUNDEF");
}
+ 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_ipv=
6) =3D=3D 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_l=
ist */
struct route_ipv6 *routes_ipv6;
struct gc_arena gc;
};
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1222?usp=3Demail
To unsubscribe, or for help writing mail filters, visit http://gerrit.openv=
pn.net/settings?usp=3Demail
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I16d90221d0a75193035253817ff195f6da9dc0b3
Gerrit-Change-Number: 1222
Gerrit-PatchSet: 5
Gerrit-Owner: mrbff
Gerrit-Reviewer: cron2
Gerrit-Reviewer: flichtenheld
Gerrit-Reviewer: plaisthos
Gerrit-CC: openvpn-devel
--DVcON877xeQ=
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
cron2 upl=
oaded patch set #5 to the change originally created by mrbff.
<=
p>View C=
hange
The following approvals got outdated and were removed:
Code-Review+2 by cron2
route: handle default gateway (net_=
gateway) and nexthop towards VPN server separately
Right now there i=
s 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 ne=
xthop).
For this reason we must adapt init_route_list() to fetch the two=
gateways separately.
Github: fixes OpenVPN/openvpn#890
Chang=
e-Id: I16d90221d0a75193035253817ff195f6da9dc0b3
Signed-off-by: Marco Baf=
fo <marco@...2726...>
Acked-by: Gert Doering <gert@...1296...&g=
t;
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1222
Message-Id=
: <20251119114041.17665-1-gert@...1296...>
URL: https://www.mail-a=
rchive.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/openvp=
n refs/changes/22/1222/5
diff --git a/src/openvpn/route.c b/src/ope=
nvpn/route.c
index 7d988da..770300a 100644
=
--- a/src/openvpn/route.c
+++ b/src/openvpn/route.c<=
br>@@ -257,9 +257,9 @@
{
=
if (rl)
{
- if (rl->rgi.flags & RGI_ADDR_DEFINED)
+ if (rl->=
ngi.flags & RGI_ADDR_DEFINED)
{
=
- *out =3D rl->=
rgi.gateway.addr;
+ =
*out =3D rl->ngi.gateway.addr;
=
}
else
{=
@@ -624,10 +624,10 @@
rl->spec.flags =
|=3D RTSA_DEFAULT_METRIC;
}
- get_default_gateway(&r=
l->rgi, remote_host !=3D IPV4_INVALID_ADDR ? remote_host : INADDR_ANY, c=
tx);
- if (rl->rg=
i.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&q=
uot;, rl->rgi.gateway.addr, -1);
+ setenv_route_addr(es, "net_gateway", rl-&=
gt;ngi.gateway.addr, -1);
#if defined(ENABLE_DEBUG) &&=
amp; !defined(ENABLE_SMALL)
print_default_gateway(=
D_ROUTE, &rl->rgi, NULL);
#endif
@@=
-637,6 +637,8 @@
dmsg(D_ROUTE, "ROUTE: defau=
lt_gateway=3DUNDEF");
}
<=
br>+ get_default_gateway(&am=
p;rl->rgi, remote_host !=3D IPV4_INVALID_ADDR ? remote_host : INADDR_ANY=
, ctx);
+
<=
span> if (rl->spec.flags & RTSA_REMOTE_HOST)
=
{
rl->spec.remote_host_local =3D test_local_a=
ddr(remote_host, &rl->rgi);
@@ -773,10 +775,10 @@
msg(D_ROUTE, "GDG6: remote_host_ipv6=3D%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-&g=
t;ngi6, NULL, ctx);
+=
if (rl6->ngi6.flags & RGI_ADDR_DEFINED)
{=
span>
- 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->ngi=
6.gateway.addr_ipv6, 0, &gc));
#if defined(ENABLE_DEBU=
G) && !defined(ENABLE_SMALL)
print_default=
_gateway(D_ROUTE, NULL, &rl6->rgi6);
#endif<=
br>@@ -786,6 +788,8 @@
dmsg(D_ROUTE, "R=
OUTE6: default_gateway=3DUNDEF");
}
+ get_default=
_gateway_ipv6(&rl6->rgi6, remote_host_ipv6, ctx);
+
if (is_route_par=
m_defined(remote_endpoint))
{
=
if (inet_pton(AF_INET6, remote_endpoint, &rl6->remote_endpoint_ipv6=
) =3D=3D 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 fla=
gs */
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_optio=
n_list */
+ struct=
route_ipv6_gateway_info ngi6; /* net_gateway_ipv6 */
+ unsigned int flags; =
/* RG_x flags, see route_option_list */
struct route_i=
pv6 *routes_ipv6;
struct gc_arena gc;
=
};
To view, visit change 1222. To unsubscr=
ibe, or for help writing mail filters, visit settings.
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I16d90221d0a75193035253817ff=
195f6da9dc0b3
Gerrit-Change-Number: 1222
Gerrit-PatchSet: 5
Gerrit-Owner: mrbff <marco@...2726...> <=
/div>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: flichtenheld <frank@...2716...=
1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...=
.1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...=
ts.sourceforge.net>
=
--DVcON877xeQ=--