From patchwork Thu Dec 3 16:10:52 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 5845 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:6022:311b:b0:11b:d6c:f273 with SMTP id e27csp306053laa; Thu, 3 Dec 2026 08:11:11 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErFF8/fLp7DiPJC4VyOwCc4HL5yg8cM1+Z1c+Rue4X0U9LltORmhnxVG2yCtn+tCmElTUFkxJENR2Cw=@openvpn.net X-Received: by 2002:a05:701a:ccdb:10b0:1b5:9b36:eb04 with SMTP id a92af1059eb24-1b59b36ebbfmr21142100c88.41.1796314271199; Thu, 03 Dec 2026 08:11:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1796314271; cv=none; d=google.com; s=arc-20260327; b=mxCNNqSN18zpv0E/Yos13IbP2BIexvf+G2RGn8Keu22rGMdoUUzP+hVLkRsCspKGnM 9/jvcgR3LPl0aRxB4FiEMvGTsp7NAu7YAbG4zMRymYP4YWSZUU1Oi5kTt09qZ7iIQun5 ETCLIfBkdDB5K3D8nLvD8dvYiEzDwdYExfDlENEiXrMIE9i9EBvJ5nNNmRwhPzJuqKrJ OmK/IjYqOlHNSGeKK8hE9R9jE9qOCFjndTEKabCQLglACNgdGLC56COTepx2LXWww4RV vbd8LeRrBznVtaRRGeyBjLm8Nq/QwQnomu5M5Yew/snyQXDv1dhH9sqUmtUFp4n0zilq l0bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature:dkim-signature; bh=ZRAeG1olT0Mv2K9QtUGsl/XTV9OmWPxi+e9jKw+cPQo=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=FgiVr2QwlMZ4i/2C09DI0HqqsotxNVv1rMBFR6m4M/lL1lS9JxQL+YR6AOCN3r3Gxe noE+hu27/I9ETKYUSi53gJi4Y0WmXyAw5nd8Kh+W4iblQyWy4pu/Iko+mF+Uy7znJQxo yGPxDLkB3QdxiS4ZZ9opsjmdPubMpTNT92/wRLtvUXkrtijmgpDYBvqrA6OPT07qCUGF jSXMNszaiV8AlR9fzVLNOjTcz6bs9xd+UqJ/EhlFkfoQu7vWXc7WsZq23JrSNeXYkmy3 t1kGKGhBKVwyu5poWFJi61KHqUd1dU2cAcw2YlN78zwT3YjPBmuDrHK9Cijww4AXUE4Q c0+A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=fQjdUReb; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=kOI2Q8jC; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=mkrhj8rr; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id a92af1059eb24-1b5567a8669si100710026c88.10.2026.12.03.08.11.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Dec 2026 08:11:11 -0800 (PST) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=fQjdUReb; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=kOI2Q8jC; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=mkrhj8rr; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Subject:MIME-Version:References:In-Reply-To:Message-ID:Date:To:From:Sender: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=ZRAeG1olT0Mv2K9QtUGsl/XTV9OmWPxi+e9jKw+cPQo=; b=fQjdURebJVw1ie YwHvC+xRpLz+L/O/EF2J0hEHlGDXBiNVEdcKp8PgoYiXUsT7wsnYGsF5VnbPtDiXjSNS1BeeM7RSe 04inY+4Dsu8r/DniI9HAET8789olr5yRfq3k3Iw2CozUeTcO1EVYmPHD/PDGNE9ddxJFCJmv+7JUS 3iU=; Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.100.1) (envelope-from ) id 1xZ9Om-000000002lE-3FDt; Thu, 03 Dec 2026 16:11:08 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.100.1) (envelope-from ) id 1xZ9Ok-000000002l6-3aAq for openvpn-devel@lists.sourceforge.net; Thu, 03 Dec 2026 16:11:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Unsubscribe-Post:List-Subscribe:List-Post:List-Owner:List-Archive; bh=AM/I8V2SdApr3wwYxLNjhQB0EILOthunznDc+nc9tLE=; b=kOI2Q8jC2w8/mq8cBsO3UQCIz1 u2kbbHAndyBM2PU8lj7AYQVhDWvU5S7JYxd+ubxM6SjxqPY1PMSunmsCpGIRXfzoI0gwxnNoXAm7W 8Dhmybp9v2cRsZoP1DV3mRhvt4c2nk7ImWNZ9exhfciokdtxccX+VsgA1mwgeS9+VD38=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Unsubscribe-Post: List-Subscribe:List-Post:List-Owner:List-Archive; bh=AM/I8V2SdApr3wwYxLNjhQB0EILOthunznDc+nc9tLE=; b=mkrhj8rrZGp3LyV5hdB2WEWoRY nGkMyHGtnX7Bp6EtuIKvcumwuM9O66WyBMeociDqe4nb0uxMzZGO6X8iu0Sojj3tGN58RBiAV5T02 CuBjtDORtyHYUPT3mhN6R9G1j8ANk9To0UzVL4x7fJOzc9bBcLsXTWfum2kUslxCBYvg=; Received: from [193.149.48.129] (helo=blue.greenie.muc.de) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.100.1) id 1xZ9Oi-000000003N4-2zXg for openvpn-devel@lists.sourceforge.net; Thu, 03 Dec 2026 16:11:06 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.18.1/8.18.1) with ESMTP id 6B3GAvWi011318 for ; Thu, 3 Dec 2026 17:10:57 +0100 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.2/8.18.1/Submit) id 6B3GAvpr011317 for openvpn-devel@lists.sourceforge.net; Thu, 3 Dec 2026 17:10:57 +0100 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Thu, 3 Dec 2026 17:10:52 +0100 Message-ID: <20261203161057.11303-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Score: 1.3 (+) X-Spam-Report: Spam detection software, running on the system "sfi-spamd-1.hosts.colo.sdot.me", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Razvan Cojocaru Add and delete IPv4 and IPv6 routes through net_route_v4/v6_add/del() on FreeBSD and DragonFly, as on Linux, instead of running route(8) from route.c. Build networking_freebsd.c for DragonFly as well; [...] Content analysis details: (1.3 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS X-Headers-End: 1xZ9Oi-000000003N4-2zXg Subject: [Openvpn-devel] [PATCH v8] route: use the net_ API for routes on FreeBSD and DragonFly X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: 1883572033177211375 X-GMAIL-MSGID: 1883572033177211375 From: Razvan Cojocaru Add and delete IPv4 and IPv6 routes through net_route_v4/v6_add/del() on FreeBSD and DragonFly, as on Linux, instead of running route(8) from route.c. Build networking_freebsd.c for DragonFly as well; -fib is only passed on FreeBSD, where --route-table is now supported. A non-contiguous IPv4 netmask now gets an error instead of an invalid prefix length. networking_freebsd.c logs route commands at D_ROUTE, as route.c did. The shared error messages lose their "Linux" prefix. Change-Id: I601454a511c9aac4f37d8629b1692266cdbd6885 Signed-off-by: Razvan Cojocaru Acked-by: Antonio Quartulli Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2154 --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2154 This mail reflects revision 8 of this Change. Acked-by according to Gerrit (reflected above): Antonio Quartulli diff --git a/doc/man-sections/vpn-network-options.rst b/doc/man-sections/vpn-network-options.rst index 960c6ad..f282982 100644 --- a/doc/man-sections/vpn-network-options.rst +++ b/doc/man-sections/vpn-network-options.rst @@ -399,7 +399,10 @@ table of the operating system, but with this option, a user defined routing table can be used instead. - (Supported on Linux only, on other platforms this is a no-op). + On FreeBSD, the table id is the FIB number. Without this option, routes + go to the FIB OpenVPN runs in (see :code:`setfib(1)`). + + (Supported on Linux and FreeBSD only, on other platforms this is a no-op). --route args Add route to routing table after connection is established. Multiple diff --git a/src/openvpn/networking.h b/src/openvpn/networking.h index f42ef4b..0cb5565 100644 --- a/src/openvpn/networking.h +++ b/src/openvpn/networking.h @@ -33,7 +33,7 @@ #include "networking_sitnl.h" #elif ENABLE_IPROUTE #include "networking_iproute2.h" -#elif defined(TARGET_FREEBSD) +#elif defined(TARGET_FREEBSD) || defined(TARGET_DRAGONFLY) typedef void *openvpn_net_ctx_t; typedef char openvpn_net_iface_t; #else /* ifdef ENABLE_SITNL */ @@ -239,7 +239,8 @@ #endif /* ENABLE_SITNL || ENABLE_IPROUTE */ -#if defined(ENABLE_SITNL) || defined(ENABLE_IPROUTE) || defined(TARGET_FREEBSD) +#if defined(ENABLE_SITNL) || defined(ENABLE_IPROUTE) || defined(TARGET_FREEBSD) \ + || defined(TARGET_DRAGONFLY) /** * Add a route for an IPv4 address/network * @@ -308,7 +309,7 @@ const struct in6_addr *gw, const openvpn_net_iface_t *iface, int table, int metric); -#endif /* ENABLE_SITNL || ENABLE_IPROUTE || TARGET_FREEBSD */ +#endif /* ENABLE_SITNL || ENABLE_IPROUTE || TARGET_FREEBSD || TARGET_DRAGONFLY */ #if defined(ENABLE_SITNL) || defined(ENABLE_IPROUTE) diff --git a/src/openvpn/networking_freebsd.c b/src/openvpn/networking_freebsd.c index abcc026..1727bb5 100644 --- a/src/openvpn/networking_freebsd.c +++ b/src/openvpn/networking_freebsd.c @@ -6,7 +6,7 @@ #include "run_command.h" #include "networking.h" -#if defined(TARGET_FREEBSD) +#if defined(TARGET_FREEBSD) || defined(TARGET_DRAGONFLY) static int net_route_v4(const char *op, const in_addr_t *dst, int prefixlen, const in_addr_t *gw, @@ -33,14 +33,16 @@ { argv_printf_cat(&argv, "-iface %s", iface); } +#if defined(TARGET_FREEBSD) /* DragonFly has no multiple FIB support */ /* without -fib, route(8) uses the FIB of the process */ if (table >= 0) { argv_printf_cat(&argv, "-fib %d", table); } +#endif - argv_msg(M_INFO, &argv); - bool status = openvpn_execve_check(&argv, NULL, 0, "ERROR: FreeBSD route command failed"); + argv_msg(D_ROUTE, &argv); + const bool status = openvpn_execve_check(&argv, NULL, 0, "ERROR: route command failed"); argv_free(&argv); @@ -75,13 +77,15 @@ { argv_printf_cat(&argv, "-iface %s", iface); } +#if defined(TARGET_FREEBSD) /* DragonFly has no multiple FIB support */ if (table >= 0) { argv_printf_cat(&argv, "-fib %d", table); } +#endif - argv_msg(M_INFO, &argv); - bool status = openvpn_execve_check(&argv, NULL, 0, "ERROR: FreeBSD route command failed"); + argv_msg(D_ROUTE, &argv); + const bool status = openvpn_execve_check(&argv, NULL, 0, "ERROR: route command failed"); argv_free(&argv); @@ -116,4 +120,4 @@ return net_route_v6("delete", dst, prefixlen, gw, iface, table, metric); } -#endif /* if defined(TARGET_FREEBSD) */ +#endif /* if defined(TARGET_FREEBSD) || defined(TARGET_DRAGONFLY) */ diff --git a/src/openvpn/options.c b/src/openvpn/options.c index e51ece7..adff841 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -226,7 +226,7 @@ " pass --ifconfig parms by environment to scripts.\n" "--ifconfig-nowarn : Don't warn if the --ifconfig option on this side of the\n" " connection doesn't match the remote side.\n" -#ifdef TARGET_LINUX +#if defined(TARGET_LINUX) || defined(TARGET_FREEBSD) "--route-table table_id : Specify a custom routing table for use with --route(-ipv6).\n" " If not specified, the id of the default routing table will be used.\n" #endif @@ -5293,8 +5293,8 @@ } else if (streq(p[0], "route-table") && p[1] && !p[2]) { -#ifndef ENABLE_SITNL - msg(M_WARN, "NOTE: --route-table is supported only on Linux when SITNL is built-in"); +#if !defined(ENABLE_SITNL) && !defined(TARGET_FREEBSD) + msg(M_WARN, "NOTE: --route-table is supported only on FreeBSD, and on Linux when SITNL is built-in"); #endif VERIFY_PERMISSION(OPT_P_ROUTE_TABLE); if (!atoi_constrained(p[1], &options->route_default_table_id, p[0], 0, INT_MAX, diff --git a/src/openvpn/route.c b/src/openvpn/route.c index 82cb7f0..8b5f968 100644 --- a/src/openvpn/route.c +++ b/src/openvpn/route.c @@ -103,6 +103,11 @@ #define RTA_SUCCESS 1 /* route addition succeeded */ #define RTA_EEXIST 2 /* route not added as it already exists */ +/* Platforms that add and delete routes through the net_ API (networking.h) */ +#if defined(TARGET_LINUX) || defined(TARGET_FREEBSD) || defined(TARGET_DRAGONFLY) +#define ROUTE_NET_API +#endif + #ifndef TARGET_ANDROID static bool add_bypass_address(struct route_bypass *rb, const in_addr_t a) @@ -1433,7 +1438,7 @@ /* Return true if the "on-link" form of the route should be used. This is when the gateway for * a route is specified as an interface rather than an address. */ -#if defined(TARGET_LINUX) || defined(_WIN32) || defined(TARGET_DARWIN) +#if defined(ROUTE_NET_API) || defined(_WIN32) || defined(TARGET_DARWIN) static inline bool is_on_link(const struct route_ipv4 *r, const unsigned int flags, const struct route_gateway_info *rgi) @@ -1459,7 +1464,7 @@ struct argv argv = argv_new(); struct gc_arena gc = gc_new(); -#if !defined(TARGET_LINUX) +#if !defined(ROUTE_NET_API) const char *network = print_in_addr_t(r->network, 0, &gc); #if !defined(TARGET_AIX) const char *netmask = print_in_addr_t(r->netmask, 0, &gc); @@ -1468,7 +1473,7 @@ #endif -#if defined(TARGET_LINUX) +#if defined(ROUTE_NET_API) const char *iface = NULL; int metric = -1; @@ -1482,20 +1487,29 @@ metric = r->metric; } - - status = RTA_SUCCESS; - int ret = net_route_v4_add(ctx, &r->network, netmask_to_netbits2(r->netmask), &r->gateway, - iface, r->table_id, metric); - if (ret == -EEXIST) + const int netbits = netmask_to_netbits2(r->netmask); + if (netbits < 0) { - msg(D_ROUTE, "NOTE: Linux route add command failed because route exists"); - status = RTA_EEXIST; - } - else if (ret < 0) - { - msg(M_WARN, "ERROR: Linux route add command failed"); + msg(M_WARN, "ERROR: cannot add route with non-contiguous netmask %s", + print_in_addr_t(r->netmask, 0, &gc)); status = RTA_ERROR; } + else + { + status = RTA_SUCCESS; + const int ret = net_route_v4_add(ctx, &r->network, netbits, &r->gateway, iface, + r->table_id, metric); + if (ret == -EEXIST) + { + msg(D_ROUTE, "NOTE: route add command failed because route exists"); + status = RTA_EEXIST; + } + else if (ret < 0) + { + msg(M_WARN, "ERROR: route add command failed"); + status = RTA_ERROR; + } + } #elif defined(TARGET_ANDROID) char out[128]; @@ -1597,44 +1611,6 @@ bool ret = openvpn_execve_check(&argv, es, 0, "ERROR: Solaris route add command failed"); status = ret ? RTA_SUCCESS : RTA_ERROR; -#elif defined(TARGET_FREEBSD) - - argv_printf(&argv, "%s add", ROUTE_PATH); - -#if 0 - if (r->flags & RT_METRIC_DEFINED) - { - argv_printf_cat(&argv, "-rtt %d", r->metric); - } -#endif - - argv_printf_cat(&argv, "-net %s %s %s", network, gateway, netmask); - - /* FIXME -- add on-link support for FreeBSD */ - - argv_msg(D_ROUTE, &argv); - bool ret = openvpn_execve_check(&argv, es, 0, "ERROR: FreeBSD route add command failed"); - status = ret ? RTA_SUCCESS : RTA_ERROR; - -#elif defined(TARGET_DRAGONFLY) - - argv_printf(&argv, "%s add", ROUTE_PATH); - -#if 0 - if (r->flags & RT_METRIC_DEFINED) - { - argv_printf_cat(&argv, "-rtt %d", r->metric); - } -#endif - - argv_printf_cat(&argv, "-net %s %s %s", network, gateway, netmask); - - /* FIXME -- add on-link support for Dragonfly */ - - argv_msg(D_ROUTE, &argv); - bool ret = openvpn_execve_check(&argv, es, 0, "ERROR: DragonFly route add command failed"); - status = ret ? RTA_SUCCESS : RTA_ERROR; - #elif defined(TARGET_DARWIN) argv_printf(&argv, "%s add", ROUTE_PATH); @@ -1700,10 +1676,10 @@ bool ret = openvpn_execve_check(&argv, es, 0, "ERROR: Haiku inet route add command failed"); status = ret ? RTA_SUCCESS : RTA_ERROR; -#else /* if defined(TARGET_LINUX) */ +#else /* if defined(ROUTE_NET_API) */ msg(M_FATAL, "Sorry, but I don't know how to do 'route' commands on this operating system. Try putting your routes in a --route-up script"); -#endif /* if defined(TARGET_LINUX) */ +#endif /* if defined(ROUTE_NET_API) */ if (status == RTA_SUCCESS) { @@ -1777,8 +1753,7 @@ const char *network = print_in6_addr(r6->network, 0, &gc); const char *gateway = print_in6_addr(r6->gateway, 0, &gc); -#if defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_DRAGONFLY) \ - || defined(TARGET_OPENBSD) || defined(TARGET_NETBSD) +#if defined(TARGET_DARWIN) || defined(TARGET_OPENBSD) || defined(TARGET_NETBSD) /* the BSD platforms cannot specify gateway and interface independently, * but for link-local destinations, we MUST specify the interface, so @@ -1830,7 +1805,7 @@ goto done; } -#if defined(TARGET_LINUX) +#if defined(ROUTE_NET_API) int metric = -1; if ((r6->flags & RT_METRIC_DEFINED) && (r6->metric > 0)) { @@ -1842,12 +1817,12 @@ device, r6->table_id, metric); if (ret == -EEXIST) { - msg(D_ROUTE, "NOTE: Linux route add command failed because route exists"); + msg(D_ROUTE, "NOTE: route add command failed because route exists"); status = RTA_EEXIST; } else if (ret < 0) { - msg(M_WARN, "ERROR: Linux route add command failed"); + msg(M_WARN, "ERROR: route add command failed"); status = RTA_ERROR; } @@ -1893,23 +1868,6 @@ bool ret = openvpn_execve_check(&argv, es, 0, "ERROR: Solaris route add -inet6 command failed"); status = ret ? RTA_SUCCESS : RTA_ERROR; -#elif defined(TARGET_FREEBSD) || defined(TARGET_DRAGONFLY) - - argv_printf(&argv, "%s add -inet6 %s/%d", ROUTE_PATH, network, r6->netbits); - - if (gateway_needed) - { - argv_printf_cat(&argv, "%s", gateway); - } - else - { - argv_printf_cat(&argv, "-iface %s", device); - } - - argv_msg(D_ROUTE, &argv); - bool ret = openvpn_execve_check(&argv, es, 0, "ERROR: *BSD route add -inet6 command failed"); - status = ret ? RTA_SUCCESS : RTA_ERROR; - #elif defined(TARGET_DARWIN) argv_printf(&argv, "%s add -inet6 %s -prefixlen %d", ROUTE_PATH, network, r6->netbits); @@ -1960,10 +1918,10 @@ bool ret = openvpn_execve_check(&argv, es, 0, "ERROR: Haiku inet6 route add command failed"); status = ret ? RTA_SUCCESS : RTA_ERROR; -#else /* if defined(TARGET_LINUX) */ +#else /* if defined(ROUTE_NET_API) */ msg(M_FATAL, "Sorry, but I don't know how to do 'route ipv6' commands on this operating system. Try putting your routes in a --route-up script"); -#endif /* if defined(TARGET_LINUX) */ +#endif /* if defined(ROUTE_NET_API) */ done: if (status == RTA_SUCCESS) @@ -1986,13 +1944,13 @@ delete_route(struct route_ipv4 *r, const struct tuntap *tt, unsigned int flags, const struct route_gateway_info *rgi, const struct env_set *es, openvpn_net_ctx_t *ctx) { -#if !defined(TARGET_LINUX) +#if !defined(ROUTE_NET_API) const char *network; #if !defined(TARGET_AIX) const char *netmask; #endif const char *gateway; -#else /* if !defined(TARGET_LINUX) */ +#else /* if !defined(ROUTE_NET_API) */ int metric; #endif @@ -2004,7 +1962,7 @@ struct gc_arena gc = gc_new(); struct argv argv = argv_new(); -#if !defined(TARGET_LINUX) +#if !defined(ROUTE_NET_API) network = print_in_addr_t(r->network, 0, &gc); #if !defined(TARGET_AIX) netmask = print_in_addr_t(r->netmask, 0, &gc); @@ -2013,7 +1971,7 @@ #endif -#if defined(TARGET_LINUX) +#if defined(ROUTE_NET_API) metric = -1; if (r->flags & RT_METRIC_DEFINED) { @@ -2024,7 +1982,7 @@ r->table_id, metric) < 0) { - msg(M_WARN, "ERROR: Linux route delete command failed"); + msg(M_WARN, "ERROR: route delete command failed"); } #elif defined(_WIN32) @@ -2074,20 +2032,6 @@ argv_msg(D_ROUTE, &argv); openvpn_execve_check(&argv, es, 0, "ERROR: Solaris route delete command failed"); -#elif defined(TARGET_FREEBSD) - - argv_printf(&argv, "%s delete -net %s %s %s", ROUTE_PATH, network, gateway, netmask); - - argv_msg(D_ROUTE, &argv); - openvpn_execve_check(&argv, es, 0, "ERROR: FreeBSD route delete command failed"); - -#elif defined(TARGET_DRAGONFLY) - - argv_printf(&argv, "%s delete -net %s %s %s", ROUTE_PATH, network, gateway, netmask); - - argv_msg(D_ROUTE, &argv); - openvpn_execve_check(&argv, es, 0, "ERROR: DragonFly route delete command failed"); - #elif defined(TARGET_DARWIN) if (is_on_link(r, flags, rgi)) @@ -2135,10 +2079,10 @@ argv_msg(D_ROUTE, &argv); openvpn_execve_check(&argv, es, 0, "ERROR: Haiku inet route delete command failed"); -#else /* if defined(TARGET_LINUX) */ +#else /* if defined(ROUTE_NET_API) */ msg(M_FATAL, "Sorry, but I don't know how to do 'route' commands on this operating system. Try putting your routes in a --route-up script"); -#endif /* if defined(TARGET_LINUX) */ +#endif /* if defined(ROUTE_NET_API) */ r->flags &= ~RT_ADDED; argv_free(&argv); @@ -2159,7 +2103,7 @@ } #if !defined(_WIN32) -#if !defined(TARGET_LINUX) +#if !defined(ROUTE_NET_API) const char *gateway; #endif #if !defined(TARGET_SOLARIS) @@ -2186,12 +2130,11 @@ struct argv argv = argv_new(); network = print_in6_addr(r6->network, 0, &gc); -#if !defined(TARGET_LINUX) && !defined(_WIN32) +#if !defined(ROUTE_NET_API) && !defined(_WIN32) gateway = print_in6_addr(r6->gateway, 0, &gc); #endif -#if defined(TARGET_DARWIN) || defined(TARGET_FREEBSD) || defined(TARGET_DRAGONFLY) \ - || defined(TARGET_OPENBSD) || defined(TARGET_NETBSD) +#if defined(TARGET_DARWIN) || defined(TARGET_OPENBSD) || defined(TARGET_NETBSD) /* the BSD platforms cannot specify gateway and interface independently, * but for link-local destinations, we MUST specify the interface, so @@ -2209,7 +2152,7 @@ msg(D_ROUTE, "delete_route_ipv6(%s/%u)", network, r6->netbits); -#if defined(TARGET_LINUX) +#if defined(ROUTE_NET_API) int metric = -1; if ((r6->flags & RT_METRIC_DEFINED) && (r6->metric > 0)) { @@ -2220,7 +2163,7 @@ device, r6->table_id, metric) < 0) { - msg(M_WARN, "ERROR: Linux route v6 delete command failed"); + msg(M_WARN, "ERROR: route v6 delete command failed"); } #elif defined(_WIN32) @@ -2242,22 +2185,6 @@ argv_msg(D_ROUTE, &argv); openvpn_execve_check(&argv, es, 0, "ERROR: Solaris route delete -inet6 command failed"); -#elif defined(TARGET_FREEBSD) || defined(TARGET_DRAGONFLY) - - argv_printf(&argv, "%s delete -inet6 %s/%d", ROUTE_PATH, network, r6->netbits); - - if (gateway_needed) - { - argv_printf_cat(&argv, "%s", gateway); - } - else - { - argv_printf_cat(&argv, "-iface %s", device); - } - - argv_msg(D_ROUTE, &argv); - openvpn_execve_check(&argv, es, 0, "ERROR: *BSD route delete -inet6 command failed"); - #elif defined(TARGET_DARWIN) argv_printf(&argv, "%s delete -inet6 %s -prefixlen %d", ROUTE_PATH, network, r6->netbits); @@ -2310,10 +2237,10 @@ argv_msg(D_ROUTE, &argv); openvpn_execve_check(&argv, es, 0, "ERROR: Haiku inet6 route delete command failed"); -#else /* if defined(TARGET_LINUX) */ +#else /* if defined(ROUTE_NET_API) */ msg(M_FATAL, "Sorry, but I don't know how to do 'route ipv6' commands on this operating system. Try putting your routes in a --route-down script"); -#endif /* if defined(TARGET_LINUX) */ +#endif /* if defined(ROUTE_NET_API) */ argv_free(&argv); gc_free(&gc);