From: "mrbff (Code Review)" Date: Fri, 14 Feb 2025 10:08:42 +0000 References: Reply-To: marco@...2726..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <0dba758edd244d445ee3d428b13cb034333ba62b-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="keNDuZrOi4Q="; charset=UTF-8 Subject: [Openvpn-devel] [XS] Change in openvpn[master]: get_dafault_gateway(): Make sure the get_default_gateway() function n... List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --keNDuZrOi4Q= 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/+/898?usp=3Demail to review the following change. Change subject: get_dafault_gateway(): Make sure the get_default_gateway() = function never receives IPV4_INVALID_ADDR as a destination. ...................................................................... get_dafault_gateway(): Make sure the get_default_gateway() function never r= eceives IPV4_INVALID_ADDR as a destination. Change-Id: I02afe6817433ca21aae76671c35151ec6a066933 Signed-off-by: Marco Baffo --- M src/openvpn/options.c M src/openvpn/route.c 2 files changed, 2 insertions(+), 2 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/98/898/1 diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 218d8a6..8b7fee4 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -5872,7 +5872,7 @@ get_ipv6_addr(p[1], &remote_ipv6, NULL, M_WARN); } net_ctx_init(NULL, &net_ctx); - get_default_gateway(&rgi, remote_ipv4, &net_ctx); + get_default_gateway(&rgi, remote_ipv4 !=3D IPV4_INVALID_ADDR ? rem= ote_ipv4 : INADDR_ANY, &net_ctx); get_default_gateway_ipv6(&rgi6, &remote_ipv6, &net_ctx); print_default_gateway(M_INFO, &rgi, &rgi6); openvpn_exit(OPENVPN_EXIT_STATUS_GOOD); /* exit point */ diff --git a/src/openvpn/route.c b/src/openvpn/route.c index d895e1c..bc41492 100644 --- a/src/openvpn/route.c +++ b/src/openvpn/route.c @@ -655,7 +655,7 @@ rl->spec.flags |=3D RTSA_DEFAULT_METRIC; } - get_default_gateway(&rl->rgi, remote_host, ctx); + get_default_gateway(&rl->rgi, remote_host !=3D IPV4_INVALID_ADDR ? rem= ote_host : INADDR_ANY, ctx); if (rl->rgi.flags & RGI_ADDR_DEFINED) { setenv_route_addr(es, "net_gateway", rl->rgi.gateway.addr, -1); -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/898?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: I02afe6817433ca21aae76671c35151ec6a066933 Gerrit-Change-Number: 898 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 --keNDuZrOi4Q= 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

get_dafault_gateway(): Make sure the get_default_gateway() fu=
nction never receives IPV4_INVALID_ADDR as a destination.

Change-Id:= I02afe6817433ca21aae76671c35151ec6a066933
Signed-off-by: Marco Baffo &l= t;marco@...2726...>
---
M src/openvpn/options.c
M src/openvpn/r= oute.c
2 files changed, 2 insertions(+), 2 deletions(-)

git pu= ll ssh://gerrit.openvpn.net:29418/openvpn refs/changes/98/898/1
dif=
f --git a/src/openvpn/options.c b/src/openvpn/options.c
ind= ex 218d8a6..8b7fee4 100644
--- a/src/openvpn/options.c
+++ b/src/openvpn/options.c
@@ -5872,7 +5872,7 = @@
get_ipv6_addr(p[1], &remote_ipv6, NULL,= M_WARN);
}
net_ctx_init(= NULL, &net_ctx);
- = get_default_gateway(&rgi, remote_ipv4, &net_ctx);
= + get_default_gateway(&a= mp;rgi, remote_ipv4 !=3D IPV4_INVALID_ADDR ? remote_ipv4 : INADDR_ANY, &= ;net_ctx);
get_default_gateway_ipv6(&rgi6, &am= p;remote_ipv6, &net_ctx);
print_default_gatewa= y(M_INFO, &rgi, &rgi6);
openvpn_exit(OPENV= PN_EXIT_STATUS_GOOD); /* exit point */
diff --git a/src/ope= nvpn/route.c b/src/openvpn/route.c
index d895e1c..bc41492 1= 00644
--- a/src/openvpn/route.c
+++ b/src/o= penvpn/route.c
@@ -655,7 +655,7 @@
= rl->spec.flags |=3D RTSA_DEFAULT_METRIC;
}<= br>
- get_def= ault_gateway(&rl->rgi, remote_host, ctx);
+ get_default_gateway(&rl->rgi, remot= e_host !=3D IPV4_INVALID_ADDR ? remote_host : INADDR_ANY, ctx);
<= span> if (rl->rgi.flags & RGI_ADDR_DEFINED)

= {
setenv_route_addr(es, "net_gateway", = rl->rgi.gateway.addr, -1);

To view, = visit cha= nge 898. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I02afe6817433ca21aae76671c35= 151ec6a066933
Gerrit-Change-Number: 898
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
--keNDuZrOi4Q=--