From patchwork Sat Nov 21 17:48:03 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 5762 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:6022:91c9:10b0:11b:d6c:f273 with SMTP id tl9-n1csp816514lad; Sat, 21 Nov 2026 09:48:21 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErG04C3lQvpmUTHh+XMuaL+1loqNOf9dFg1Sf4w98VTWZ7pxNowgYYKvY2D/Aliwdt1R+Um9azXLAd8=@openvpn.net X-Received: by 2002:a05:6820:4402:b0:715:21d1:b87 with SMTP id 006d021491bc7-71b39032a8emr3833466eaf.0.1795283301135; Sat, 21 Nov 2026 09:48:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1795283301; cv=none; d=google.com; s=arc-20260327; b=J8Ljo7Rp22YhHgkbMKK8M8hgsjjq51JHWeASERdmJQRnh8bljn1Mn15cYFNu1HY7U5 kZp0LW5wEK57Pcw+1vcLElPzowSfrxrn50D7nl6KPcQy6K81axJ+j1hu8ksEPHHZfvwP csbApwNLkjD5VozkLN2hCGhEUkS8ZBSShkiS9BBgb8AkNKNcFDynfi/VzVgxpZPb3Eg3 V7F5134QmKoTbiHmGGgxpc6huYSSVdhL7UScxUs89S1aGX+buyHOZWUaH5whwwevCHb6 +0PqYFoT3Bt47kOsQKBA8GtiYkv6qV8jNA/sxBZvPXw8MQICmKBoW9mUUhWlSl7dttGw Q4zA== 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=cA0JOp6NYvDOS+QbExdditTHeiFI/aEnA9fSZdf/CXQ=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=pqCh33oSXmTn0KgInsNPfLplBqifDwHR0uMyL7YF2kj2VEKUPpIuG5eJhO9GnwSCK4 CMCn3EeVFw9eCpIZQSO9T4irDHr2QyJOhRrrYPlzd3m6Dh6oTkOV1NCAlr7TlTlYwlFm REpQiRwKuFK5g80p2uP1gohNVj+e2ypKIIP9wrzW5ucw2GwlKPQT7PGq10yR09Vf6+7v heXPvY3SRjLeFzpqnI1FZZ/sGQ1yu/bnEF/BYiBmiSNM5rAZNmV29+W+Q+R+Naqlchrc V1RvRPttLhhqRAwhOx1z30zG7Y4vbzxdJZ797XYTzx5H42ZhcTn1uC3+Qne6UoiUKvlS /SBQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=HOm0G+M9; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=CzXFD6P5; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=gYXGdsOw; 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 006d021491bc7-71b38330e39si9055309eaf.91.2026.11.21.09.48.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 21 Nov 2026 09:48:21 -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=HOm0G+M9; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=CzXFD6P5; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=gYXGdsOw; 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=cA0JOp6NYvDOS+QbExdditTHeiFI/aEnA9fSZdf/CXQ=; b=HOm0G+M9q4qato zgykNsC0TDOUycHEUFuz15DO2v1QY7445JezOuuoUyyoeNk9quv9srAhOcVS4cfcHFkcFl00TrLTU OOdNjx+8fXn+u4t0hhIHbXSgLqPLDglmXR5yhV0HssnIS4zLwo31b983tvYjithxCLFjg3OuDDRRr /Ik=; Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.100.1) (envelope-from ) id 1xUpCF-000000003XC-2oGO; Sat, 21 Nov 2026 17:48:19 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.100.1) (envelope-from ) id 1xUpCF-000000003X6-0cEA for openvpn-devel@lists.sourceforge.net; Sat, 21 Nov 2026 17:48:19 +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=qZ4ZIWP2RFyy86gycvmSpuOyrOB7cnaq57zaqD/hq1U=; b=CzXFD6P5mQJvjNvmhEqJJ8Z7tC JF06vpg0ZEfl37tZhGuuxmgU/VsenOGems0zDZkNwME+xTPJeGBOM/YjsUV9CrzbpsY3IpSf/FqhS zugSQ3Srml+sLnhPmSM3DJVU0AW7+n/pgT9MYhZbrpMpKrUqHnKsx3yGQ6Ewdn3or5qA=; 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=qZ4ZIWP2RFyy86gycvmSpuOyrOB7cnaq57zaqD/hq1U=; b=gYXGdsOwxgm+W1JkbbYojqVjJQ j2tn/oUoWQNwMEH36w8dqvOHY1OQigFj6Dee3zAHxXemhznJAfYjbD4mTuDngXn6DmsrIz1BdKVz8 UixamXsjyYdwy7rfiJQB6vLlS7fsC2tE6f8kjbz0ZxC8H+QXzPLeBlFAwtbg4POwebz4=; Received: from [193.149.48.129] (helo=blue.greenie.muc.de) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.100.1) id 1xUpCE-000000007pr-11QP for openvpn-devel@lists.sourceforge.net; Sat, 21 Nov 2026 17:48:19 +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 6ALHmBlN012279 for ; Sat, 21 Nov 2026 18:48:11 +0100 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.2/8.18.1/Submit) id 6ALHmBFb012278 for openvpn-devel@lists.sourceforge.net; Sat, 21 Nov 2026 18:48:11 +0100 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Sat, 21 Nov 2026 18:48:03 +0100 Message-ID: <20261121174810.12250-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-2.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 - Return -1 on failure, as networking.h documents, instead of 1. - Add the interface as scope to link-local IPv6 gateways. - Use "delete" and "-inet6", as route.c does. DragonFly's route(8) has no "de [...] 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: 1xUpCE-000000007pr-11QP Subject: [Openvpn-devel] [PATCH v6] networking_freebsd: fix route command and return value details 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: 1882490982872840376 X-GMAIL-MSGID: 1882490982872840376 From: Razvan Cojocaru - Return -1 on failure, as networking.h documents, instead of 1. - Add the interface as scope to link-local IPv6 gateways. - Use "delete" and "-inet6", as route.c does. DragonFly's route(8) has no "del" or "-6". All current callers (DCO iroutes) ignore the return value. Change-Id: I3e6043178935fdd05e6ea78c411dac5decb7ac64 Signed-off-by: Razvan Cojocaru Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2153 --- 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/+/2153 This mail reflects revision 6 of this Change. Acked-by according to Gerrit (reflected above): Gert Doering diff --git a/src/openvpn/networking_freebsd.c b/src/openvpn/networking_freebsd.c index 8ba6326..abcc026 100644 --- a/src/openvpn/networking_freebsd.c +++ b/src/openvpn/networking_freebsd.c @@ -12,30 +12,26 @@ net_route_v4(const char *op, const in_addr_t *dst, int prefixlen, const in_addr_t *gw, const char *iface, int table, int metric) { - char buf1[INET_ADDRSTRLEN], buf2[INET_ADDRSTRLEN]; - in_addr_t _dst, _gw; + char buf[INET_ADDRSTRLEN]; + in_addr_t _dst = ntohl(*dst); struct argv argv = argv_new(); ASSERT(gw || iface); - _dst = ntohl(*dst); - /* if we have a gateway (GW != NULL) install route to gateway IP * if not, install "connected" route to interface * (needed to make 'ifconfig-push IPs outside server subnet' work) */ + argv_printf(&argv, "%s %s -net %s/%d", ROUTE_PATH, op, + inet_ntop(AF_INET, &_dst, buf, sizeof(buf)), prefixlen); if (gw) { - _gw = ntohl(*gw); - argv_printf(&argv, "%s %s -net %s/%d %s", ROUTE_PATH, op, - inet_ntop(AF_INET, &_dst, buf1, sizeof(buf1)), prefixlen, - inet_ntop(AF_INET, &_gw, buf2, sizeof(buf2))); + in_addr_t _gw = ntohl(*gw); + argv_printf_cat(&argv, "%s", inet_ntop(AF_INET, &_gw, buf, sizeof(buf))); } else { - argv_printf(&argv, "%s %s -net %s/%d -iface %s", ROUTE_PATH, op, - inet_ntop(AF_INET, &_dst, buf1, sizeof(buf1)), prefixlen, - iface); + argv_printf_cat(&argv, "-iface %s", iface); } /* without -fib, route(8) uses the FIB of the process */ if (table >= 0) @@ -48,14 +44,14 @@ argv_free(&argv); - return (!status); + return status ? 0 : -1; } static int net_route_v6(const char *op, const struct in6_addr *dst, int prefixlen, const struct in6_addr *gw, const char *iface, int table, int metric) { - char buf1[INET6_ADDRSTRLEN], buf2[INET6_ADDRSTRLEN]; + char buf[INET6_ADDRSTRLEN]; struct argv argv = argv_new(); ASSERT(gw || iface); @@ -64,30 +60,32 @@ * if not, install "connected" route to interface * (needed to make 'ifconfig-push IPs outside server subnet' work) */ - if (gw) + argv_printf(&argv, "%s %s -inet6 %s/%d", ROUTE_PATH, op, + inet_ntop(AF_INET6, dst, buf, sizeof(buf)), prefixlen); + if (gw && iface && IN6_IS_ADDR_LINKLOCAL(gw)) { - argv_printf(&argv, "%s -6 %s -net %s/%d %s", ROUTE_PATH, op, - inet_ntop(AF_INET6, dst, buf1, sizeof(buf1)), prefixlen, - inet_ntop(AF_INET6, gw, buf2, sizeof(buf2))); + /* a link-local gateway needs the interface as scope */ + argv_printf_cat(&argv, "%s%%%s", inet_ntop(AF_INET6, gw, buf, sizeof(buf)), iface); + } + else if (gw) + { + argv_printf_cat(&argv, "%s", inet_ntop(AF_INET6, gw, buf, sizeof(buf))); } else { - argv_printf(&argv, "%s -6 %s -net %s/%d -iface %s", ROUTE_PATH, op, - inet_ntop(AF_INET6, dst, buf1, sizeof(buf1)), prefixlen, - iface); + argv_printf_cat(&argv, "-iface %s", iface); } if (table >= 0) { argv_printf_cat(&argv, "-fib %d", table); } - argv_msg(M_INFO, &argv); bool status = openvpn_execve_check(&argv, NULL, 0, "ERROR: FreeBSD route command failed"); argv_free(&argv); - return (!status); + return status ? 0 : -1; } int @@ -108,14 +106,14 @@ net_route_v4_del(const openvpn_net_ctx_t *ctx, const in_addr_t *dst, int prefixlen, const in_addr_t *gw, const char *iface, int table, int metric) { - return net_route_v4("del", dst, prefixlen, gw, iface, table, metric); + return net_route_v4("delete", dst, prefixlen, gw, iface, table, metric); } int net_route_v6_del(const openvpn_net_ctx_t *ctx, const struct in6_addr *dst, int prefixlen, const struct in6_addr *gw, const char *iface, int table, int metric) { - return net_route_v6("del", dst, prefixlen, gw, iface, table, metric); + return net_route_v6("delete", dst, prefixlen, gw, iface, table, metric); } #endif /* if defined(TARGET_FREEBSD) */