From: "mrbff (Code Review)"
Date: Tue, 25 Feb 2025 09:49:49 +0000
References:
Reply-To: marco@...2726..., arne-openvpn@...1227...,
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="674wSEu9mm4="; 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: plaisthos , flichtenheld
Cc: openvpn-devel
--674wSEu9mm4=
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
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=3Demail
to review the following change.
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.
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 |=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)
+ 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=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);
@@ -818,10 +822,12 @@
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)
+ 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.gatewa=
y.addr_ipv6, 0, &gc));
+ setenv_str(es, "net_gateway_ipv6", print_in6_addr(ngi6.gateway.add=
r_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=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,
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/902?usp=3Demail
To unsubscribe, or for help writing mail filters, visit http://gerrit.openv=
pn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ifc54be34101c0eb0f3dc479a9480d7219628cc76
Gerrit-Change-Number: 902
Gerrit-PatchSet: 1
Gerrit-Owner: mrbff
Gerrit-Reviewer: flichtenheld
Gerrit-Reviewer: plaisthos
Gerrit-CC: openvpn-devel
Gerrit-Attention: plaisthos
Gerrit-Attention: flichtenheld
Gerrit-MessageType: newchange
--674wSEu9mm4=
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Attention is currently required from: flichtenheld, plaisthos.
mrbff would like plaisthos and flichtenheld to review t=
his change.
Vi=
ew Change
route: handle default gateway (net_gateway) and nexthop towar=
ds 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. H=
owever, 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. <=
br>Change-Id: Ifc54be34101c0eb0f3dc479a9480d7219628cc76 --- M src/ope=
nvpn/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.ci=
ndex bc41492..3ddc333 100644 --- a/src/openvpn/route.c+++ b/src/openvpn/route.c @@ -655,10 +655,12 @@=
rl->spec.flags |=3D RTSA_DEFAULT_METRIC; } - get_default_gateway(&rl->rgi, remote_host !=3D IPV=
4_INVALID_ADDR ? remote_host : INADDR_ANY, ctx); - if (rl->rgi.flags & RGI_ADDR_DEFINED)=
+ struct route_ga=
teway_info ngi; + + get_default_gateway=
(&ngi, INADDR_ANY, ctx); + if (ngi.flags & RGI_ADDR_DEFINED) {=
span>- setenv_route_ad=
dr(es, "net_gateway", rl->rgi.gateway.addr, -1); + setenv_route_addr(es, &qu=
ot;net_gateway", ngi.gateway.addr, -1); #if defined(E=
NABLE_DEBUG) && !defined(ENABLE_SMALL) pri=
nt_default_gateway(D_ROUTE, &rl->rgi, NULL); #endif=
@@ -668,6 +670,8 @@ dmsg(D_ROUTE,=
"ROUTE: default_gateway=3DUNDEF"); } =
+ get_=
default_gateway(&rl->rgi, remote_host !=3D IPV4_INVALID_ADDR ? remot=
e_host : INADDR_ANY, ctx); + if (rl->spec.flags & RTSA_REMOTE_HOST)<=
/span> { rl->spec.remote_host_loc=
al =3D test_local_addr(remote_host, &rl->rgi); @@ -8=
18,10 +822,12 @@ msg(D_ROUTE, "GDG6: remote_host_=
ipv6=3D%s", remote_host_ipv6 ? print_in6_add=
r(*remote_host_ipv6, 0, &gc) : "n/a" ); - get_default_gateway_i=
pv6(&rl6->rgi6, remote_host_ipv6, ctx); - if (rl6->rgi6.flags & RGI_ADDR_DEFINED)=
+ struct route_ip=
v6_gateway_info ngi6; + + get_default_g=
ateway_ipv6(&ngi6, NULL, ctx); + if (ngi6.flags & RGI_ADDR_DEFINED) =
{ - setenv_s=
tr(es, "net_gateway_ipv6", print_in6_addr(rl6->rgi6.gateway.ad=
dr_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, "RO=
UTE6: 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, To view, visit change 902 . To unsubscribe, or for help writing mail filters=
, visit settings .
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ifc54be34101c0eb0f3dc479a948=
0d7219628cc76
Gerrit-Change-Number: 902
Gerrit-PatchSet: 1
Gerrit-Owner: mrbff <marco@...2726...> <=
/div>
Gerrit-Reviewer: flichtenheld <frank@...2716...=
1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...=
.1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...=
ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...=
..1227...>
Gerrit-Attention: flichtenheld <frank@...2375...=
41...>
Gerrit-MessageType: newchange
--674wSEu9mm4=--