From: "plaisthos (Code Review)" Date: Mon, 6 Oct 2025 13:22:11 +0000 In-Reply-To: References: Reply-To: arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641..., gert@...1296... Message-ID: <9680e7bb0cd590ea50c5ffe817c53deb79d130da-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="MdGVL8jBDAM="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: Allowing installing FreeBSD routes with interface instead of next-hop List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld Cc: openvpn-devel --MdGVL8jBDAM= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: cron2, flichtenheld, plaisthos. Hello cron2, flichtenheld, I'd like you to reexamine a change. Please visit http://gerrit.openvpn.net/c/openvpn/+/1193?usp=3Demail to look at the new patch set (#4). The following approvals got outdated and were removed: Code-Review-1 by cron2 Change subject: Allowing installing FreeBSD routes with interface instead o= f next-hop ...................................................................... Allowing installing FreeBSD routes with interface instead of next-hop This matches the Linux behaviour of the net_route add/delete commands Change-Id: I88e16e15fad065cb310d38f09924053efc3a6ce5 Signed-off-by: Arne Schwabe --- M src/openvpn/networking_freebsd.c 1 file changed, 35 insertions(+), 11 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/93/1193/4 diff --git a/src/openvpn/networking_freebsd.c b/src/openvpn/networking_free= bsd.c index b47444c..b020f51 100644 --- a/src/openvpn/networking_freebsd.c +++ b/src/openvpn/networking_freebsd.c @@ -15,17 +15,29 @@ char buf1[INET_ADDRSTRLEN], buf2[INET_ADDRSTRLEN]; in_addr_t _dst, _gw; struct argv argv =3D argv_new(); - bool status; + + ASSERT(gw || iface); _dst =3D ntohl(*dst); - _gw =3D ntohl(*gw); - argv_printf(&argv, "%s %s -net %s/%d %s -fib %d", ROUTE_PATH, op, - inet_ntop(AF_INET, &_dst, buf1, sizeof(buf1)), prefixlen, - inet_ntop(AF_INET, &_gw, buf2, sizeof(buf2)), table); + /* if gw is NULL we are installing a route with the interface as + * target instead */ + if (gw) + { + _gw =3D ntohl(*gw); + argv_printf(&argv, "%s %s -net %s/%d %s -fib %d", ROUTE_PATH, op, + inet_ntop(AF_INET, &_dst, buf1, sizeof(buf1)), prefixl= en, + inet_ntop(AF_INET, &_gw, buf2, sizeof(buf2)), table); + } + else + { + argv_printf(&argv, "%s %s -net %s/%d -iface %s -fib %d", ROUTE_PAT= H, op, + inet_ntop(AF_INET, &_dst, buf1, sizeof(buf1)), prefixl= en, + iface, table); + } argv_msg(M_INFO, &argv); - status =3D openvpn_execve_check(&argv, NULL, 0, "ERROR: FreeBSD route = command failed"); + bool status =3D openvpn_execve_check(&argv, NULL, 0, "ERROR: FreeBSD r= oute command failed"); argv_free(&argv); @@ -38,14 +50,26 @@ { char buf1[INET6_ADDRSTRLEN], buf2[INET6_ADDRSTRLEN]; struct argv argv =3D argv_new(); - bool status; =20 - argv_printf(&argv, "%s -6 %s -net %s/%d %s -fib %d", ROUTE_PATH, op, - inet_ntop(AF_INET6, dst, buf1, sizeof(buf1)), prefixlen, - inet_ntop(AF_INET6, gw, buf2, sizeof(buf2)), table); + ASSERT(gw || iface); + /* if gw is NULL, we are installing a route with the interface as targ= et + * instead */ + if (gw) + { + argv_printf(&argv, "%s -6 %s -net %s/%d %s -fib %d", ROUTE_PATH, o= p, + inet_ntop(AF_INET6, dst, buf1, sizeof(buf1)), prefixle= n, + inet_ntop(AF_INET6, gw, buf2, sizeof(buf2)), table); + } + else + { + argv_printf(&argv, "%s -6 %s -net %s/%d -iface %s -fib %d", ROUTE_= PATH, op, + inet_ntop(AF_INET6, dst, buf1, sizeof(buf1)), prefixle= n, + iface, table); + } + =20 argv_msg(M_INFO, &argv); - status =3D openvpn_execve_check(&argv, NULL, 0, "ERROR: FreeBSD route = command failed"); + bool status =3D openvpn_execve_check(&argv, NULL, 0, "ERROR: FreeBSD r= oute command failed"); argv_free(&argv); -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1193?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: I88e16e15fad065cb310d38f09924053efc3a6ce5 Gerrit-Change-Number: 1193 Gerrit-PatchSet: 4 Gerrit-Owner: plaisthos Gerrit-Reviewer: cron2 Gerrit-Reviewer: flichtenheld Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: cron2 Gerrit-Attention: flichtenheld --MdGVL8jBDAM= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: cron2, flichtenheld, plaisthos.

plaisthos uploaded patch set #4 to this change.

<= a href=3D"http://gerrit.openvpn.net/c/openvpn/+/1193?usp=3Demail">View Chan= ge

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

Allowing installing FreeBSD routes =
with interface instead of next-hop

This matches the Linux behaviour = of the net_route add/delete commands

Change-Id: I88e16e15fad065cb310= d38f09924053efc3a6ce5
Signed-off-by: Arne Schwabe <arne@...1227...>= ;
---
M src/openvpn/networking_freebsd.c
1 file changed, 35 insert= ions(+), 11 deletions(-)

git pull ssh://gerrit.o=
penvpn.net:29418/openvpn refs/changes/93/1193/4
diff --git a/src/op=
envpn/networking_freebsd.c b/src/openvpn/networking_freebsd.c
index b47444c..b020f51 100644
--- a/src/openvpn/networki= ng_freebsd.c
+++ b/src/openvpn/networking_freebsd.c<= br>@@ -15,17 +15,29 @@
char buf1[INET_ADDRSTRLEN= ], buf2[INET_ADDRSTRLEN];
in_addr_t _dst, _gw;<= br> struct argv argv =3D argv_new();
- bool status;
+
- _gw = =3D ntohl(*gw);

- argv_printf(&argv, "%s %s -net %s/%d %s -fib %d&qu= ot;, ROUTE_PATH, op,
- = inet_ntop(AF_INET, &_dst, buf1, sizeof(buf1)), prefixlen= ,
- inet= _ntop(AF_INET, &_gw, buf2, sizeof(buf2)), table);
+ /* if gw is NULL we are installing a = route with the interface as
+ * target instead */
+ if (gw)
+ {
+ _= gw =3D ntohl(*gw);
+ = argv_printf(&argv, "%s %s -net %s/%d %s -fib %d", ROUT= E_PATH, op,
+ = inet_ntop(AF_INET, &_dst, buf1, sizeof(buf1)), prefixlen,
+ i= net_ntop(AF_INET, &_gw, buf2, sizeof(buf2)), table);
+ }
+ else
+ {
+ = argv_printf(&argv, "%s %s -net %s/%d -iface %s -fib %d"= , ROUTE_PATH, op,
+ = inet_ntop(AF_INET, &_dst, buf1, sizeof(buf1)), prefix= len,
+ = iface, table);
+= }

argv_msg(M_INFO, &argv);
- status =3D openvpn_= execve_check(&argv, NULL, 0, "ERROR: FreeBSD route command failed&= quot;);
+ bool sta= tus =3D openvpn_execve_check(&argv, NULL, 0, "ERROR: FreeBSD route= command failed");

argv_free(&a= mp;argv);

@@ -38,14 +50,26 @@
<= span> {

char buf1[INET6_ADDRSTRLEN], buf2[INET6_ADDRST= RLEN];
struct argv argv =3D argv_new();
- bool status;


- argv_printf(&ar= gv, "%s -6 %s -net %s/%d %s -fib %d", ROUTE_PATH, op,
<= span style=3D"color: hsl(0, 100%, 40%);">- inet_ntop(AF_INET= 6, dst, buf1, sizeof(buf1)), prefixlen,

- inet_ntop(AF_INET6, gw, buf2, sizeof(buf2= )), table);
+ ASSE= RT(gw || iface);
+ = /* if gw is NULL, we are installing a route with the interface as target
+ * instead */

+ if (gw)
<= span style=3D"color: hsl(120, 100%, 40%);">+ {
+ argv_printf(&argv, "%s -6 %s= -net %s/%d %s -fib %d", ROUTE_PATH, op,
+ inet_ntop(AF_INET6, dst, buf1= , sizeof(buf1)), prefixlen,
+ inet_ntop(AF_INET6, gw, buf2, sizeof(buf2)), ta= ble);
+ }+ else
+ {
+ argv_printf(&argv, "%s -6 %s -net %s= /%d -iface %s -fib %d", ROUTE_PATH, op,
+ inet_ntop(AF_INET6, dst, buf1,= sizeof(buf1)), prefixlen,
+ iface, table);
+ }
+

argv_msg(M_INFO, &argv)= ;
- status =3D openv= pn_execve_check(&argv, NULL, 0, "ERROR: FreeBSD route command fail= ed");
+ bool = status =3D openvpn_execve_check(&argv, NULL, 0, "ERROR: FreeBSD ro= ute command failed");

argv_free= (&argv);


To view,= visit c= hange 1193. To unsubscribe, or for help writing mail filters, visit settings.

<= meta itemprop=3D"name" content=3D"View Change"/>
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I88e16e15fad065cb310d38f0992= 4053efc3a6ce5
Gerrit-Change-Number: 1193
Gerrit-PatchSet: 4
Gerrit-Owner: plaisthos <arne-openvpn@...1711...= 27...>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: cron2 <gert@...1296...>= ;
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
= --MdGVL8jBDAM=--