From: "cron2 (Code Review)" Date: Mon, 6 Oct 2025 16:57:13 +0000 In-Reply-To: References: Reply-To: gert@...1296..., 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="htTEc6cmQ0I="; charset=UTF-8 Subject: [Openvpn-devel] [M] 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: plaisthos , flichtenheld Cc: openvpn-devel --htTEc6cmQ0I= 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= plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1193?usp=3Demail ) 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 Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1193 Message-Id: <20251006145844.27794-1-gert@...1296...> URL: https://sourceforge.net/p/openvpn/mailman/message/59242876/ Signed-off-by: Gert Doering --- M src/openvpn/networking_freebsd.c 1 file changed, 40 insertions(+), 11 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/93/1193/5 diff --git a/src/openvpn/networking_freebsd.c b/src/openvpn/networking_free= bsd.c index b47444c..04051a6 100644 --- a/src/openvpn/networking_freebsd.c +++ b/src/openvpn/networking_freebsd.c @@ -15,17 +15,31 @@ 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 we have a gateway (GW !=3D NULL) install route to gateway IP + * if not, install "connected" route to interface + * (needed to make 'ifconfig-push IPs outside server subnet' work) + */ + 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 +52,29 @@ { char buf1[INET6_ADDRSTRLEN], buf2[INET6_ADDRSTRLEN]; struct argv argv =3D argv_new(); - bool status; - 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 we have a gateway (GW !=3D NULL) install route to gateway IP + * if not, install "connected" route to interface + * (needed to make 'ifconfig-push IPs outside server subnet' work) + */ + 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); + } + 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: 5 Gerrit-Owner: plaisthos Gerrit-Reviewer: cron2 Gerrit-Reviewer: flichtenheld Gerrit-CC: openvpn-devel --htTEc6cmQ0I= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 upl= oaded patch set #5 to the change originally created by plaisthos.<= /p>

Vi= ew Change

Allowing installing FreeBSD routes with inte=
rface instead of next-hop

This matches the Linux behaviour of the ne= t_route add/delete commands

Change-Id: I88e16e15fad065cb310d38f09924= 053efc3a6ce5
Signed-off-by: Arne Schwabe <arne@...1227...>
Gerr= it URL: https://gerrit.openvpn.net/c/openvpn/+/1193
Message-Id: <2025= 1006145844.27794-1-gert@...1296...>
URL: https://sourceforge.net/p/op= envpn/mailman/message/59242876/
Signed-off-by: Gert Doering <gert@...493...= 1296...>
---
M src/openvpn/networking_freebsd.c
1 file changed,= 40 insertions(+), 11 deletions(-)

git pull ssh:=
//gerrit.openvpn.net:29418/openvpn refs/changes/93/1193/5
diff --=
git a/src/openvpn/networking_freebsd.c b/src/openvpn/networking_freebsd.c
index b47444c..04051a6 100644
--- a/src/open= vpn/networking_freebsd.c
+++ b/src/openvpn/networking_freeb= sd.c
@@ -15,17 +15,31 @@
char buf1[INE= T_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 we have a gateway (= GW !=3D NULL) install route to gateway IP
+ * if not, install "connected" route to= interface
+ * (n= eeded to make 'ifconfig-push IPs outside server subnet' work)
+ */
+ 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, si= zeof(buf1)), prefixlen,
+ inet_ntop(AF_INET, &_gw, buf2, sizeof(buf2)), t= able);
+ }<= br>+ else
+ {
+ argv_printf(&argv, "%s %s -net %s/%= d -iface %s -fib %d", ROUTE_PATH, op,
+ inet_ntop(AF_INET, &_dst, bu= f1, sizeof(buf1)), prefixlen,
+ iface, table);
+ }

argv_= msg(M_INFO, &argv);
- status =3D openvpn_execve_check(&argv, NULL, 0, "ERROR: Free= BSD route command failed");
+ bool status =3D openvpn_execve_check(&argv, NULL, 0, &= quot;ERROR: FreeBSD route command failed");
argv_free(&argv);

@@ -38= ,14 +52,29 @@
{
char buf1[INET6_ADDRS= TRLEN], buf2[INET6_ADDRSTRLEN];
struct argv argv =3D a= rgv_new();
- bool st= atus;

- argv_printf(&argv, "%s -6 %s -net %s/%d %s -fib %d", RO= UTE_PATH, op,
- = inet_ntop(AF_INET6, dst, buf1, sizeof(buf1)), prefixlen,
= - inet_ntop(AF_INE= T6, gw, buf2, sizeof(buf2)), table);
+ ASSERT(gw || iface);
+
+ * if not, instal= l "connected" route to interface
+ * (needed to make 'ifconfig-push IPs outsid= e server subnet' work)
+ */
+ i= f (gw)
+ {<= br>+ argv_printf(&ar= gv, "%s -6 %s -net %s/%d %s -fib %d", ROUTE_PATH, op,
<= span style=3D"color: hsl(120, 100%, 40%);">+ inet_ntop(A= F_INET6, dst, buf1, sizeof(buf1)), prefixlen,

+ inet_ntop(AF_INET6, gw, buf2,= sizeof(buf2)), table);
+ }
+ else
+ {
+ argv_printf(&argv, &quo= t;%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 openvpn_execve_check(&argv, NULL, 0, "ERROR: FreeBSD = route command failed");
+ bool status =3D openvpn_execve_check(&argv, NULL, 0, "= ;ERROR: FreeBSD route command failed");

argv_free(&argv);

To view, visit change 1193. To unsubscribe, or for help writing mail = filters, visit s= ettings.

=
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I88e16e15fad065cb310d38f0992= 4053efc3a6ce5
Gerrit-Change-Number: 1193
Gerrit-PatchSet: 5
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>
= --htTEc6cmQ0I=--