From patchwork Mon Oct 6 14:58:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 4465 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:7505:b0:72f:f16c:e055 with SMTP id r5csp6891593mai; Mon, 6 Oct 2025 07:59:04 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVtFhO65+wFgRoWcKizIvLxKwN7aLYthsrGrU/XUN6ouEwj1BFt2mR1HLEhLXAvJYYOBaQI5qimSvo=@openvpn.net X-Google-Smtp-Source: AGHT+IGLguoJJcOo+awTFzkmE1vKf7qmTpUgLGhAriQw66cMG8zY+bSuz2/9uCnz45AzkAuHH/6/ X-Received: by 2002:a05:6808:1442:b0:43f:64c0:8e4c with SMTP id 5614622812f47-43fc182e619mr5998567b6e.31.1759762744055; Mon, 06 Oct 2025 07:59:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1759762744; cv=none; d=google.com; s=arc-20240605; b=hidlHFeAwd7iRoml2mrjAoNtREyXBDgfI6HuugQv2pbBiv4Kkw9zADKFu8ALQxoO7J /W601j9pcj9cllZZhBG3oiJx6h6FjoWIN82amNzmyHWTzCbCZD3NxuzLCAKUDBfUn3Ao wFOFCHTNn/VrzvjBMMrt6ujFsAKbvMeUFIThl2qO1MvxtxCcdC7m2sgrktrIqBfi7UdS MWP/fejrhGgWHM2JKgNzvndI/ic3+5byQ/ydY9MA7Oco27JP+Otnv8gCElP0M4h27JG/ wzObuQsz0aGRnqzt8cMQ/0LDTkoX+N6e5TQLhFuhBF3yGaon9ubOJlpSDgQhhGuXGme6 dQVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=DyFvDJdI2/Dok8iJthTtRtBp8hQt5YkZShl2mEeKZYY=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=KxlqEtfrg9+V6cbfzZ9DEiveEOJTbHkNohh+M3CU9InSpVl/jR/DxnZKl3sIvCf821 7rWkYpZ6cAohYd6YQW0D/xyl8xI3cJYrdjHw3MkR4Uwyj/7IsPBaaWOELNc1+qPQYPC8 ejUMVnJJV1kTRe4jBChXB0H48vSJW1zkS0ehtJzPW0yF4tN57KXGULxWMfzBwsNJqu4m z+pmjZ0ukXx/o/yGKJkL8NrCZ4/lLiCUMt9eM7utSWXwtZXZWwaenADhS/G6Zs3gUnwb S8X1Y//m+4IMP3Nji1QeYKF6yVHeIKbQaQ8AABqV9rhEV5jhK3IdGJlvfzqsyucSCvYt OtQg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=TJVsGVJA; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=SvEWEtG3; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=Ii8sJP+P; 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 5614622812f47-43fc195ada2si2526415b6e.253.2025.10.06.07.59.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Oct 2025 07:59:03 -0700 (PDT) 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=TJVsGVJA; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=SvEWEtG3; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=Ii8sJP+P; 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-Owner; bh=DyFvDJdI2/Dok8iJthTtRtBp8hQt5YkZShl2mEeKZYY=; b=TJVsGVJAvjVv6ZYrmDBaEy/t4t BIVJfBu6G/iW241vZW5xndTmxgBiSzVrXWbFXmXUFMKEF25k8vKe2hM/EMv246Q00irUcoNZAgA71 rKYM7UNj+o5rnjDtZgiRelt6DouMX7+xSTh+RcCH0dtfy9y5S34MbElDpQfx8YuTl6AU=; 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.95) (envelope-from ) id 1v5mfz-0007bu-Cq; Mon, 06 Oct 2025 14:58:59 +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.95) (envelope-from ) id 1v5mfy-0007bo-2a for openvpn-devel@lists.sourceforge.net; Mon, 06 Oct 2025 14:58:58 +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-Subscribe:List-Post:List-Owner:List-Archive; bh=wrIlfY9tMmkgligiEikxca01rIlpFM+h6SqAF4vhN9g=; b=SvEWEtG3YFoiFtJExWcs+5J+R8 huNsKj09M23jmyZLCclFd0f4sNWWnqUpznsCcbTc23zZzqM2e8ObV54cLfprYtm1stOjBPi/dMiwk hPu7VkX0RxAC/EdBPVI4oVSyf1gQSoB6TW3enol5nRglP6chwK09ccTpv97jjkrBHq4o=; 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-Subscribe: List-Post:List-Owner:List-Archive; bh=wrIlfY9tMmkgligiEikxca01rIlpFM+h6SqAF4vhN9g=; b=Ii8sJP+POodgw8ybK6XpB44J0h xIwXf2dKgvYTY271c7hJej1T3cR07VgKVj/9VmQ8qk/3UvpkpxofsJalRBZ4k7e7jRf0hR6DN7+or s8op81mTD7pQvlGcD0SULyGbe52pequ3e9kDj63BySXXWw2POamEC10MRqdqDsIEqnX4=; Received: from [193.149.48.134] (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.95) id 1v5mfw-0000ZA-OV for openvpn-devel@lists.sourceforge.net; Mon, 06 Oct 2025 14:58:58 +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 596Ewif3027810 for ; Mon, 6 Oct 2025 16:58:44 +0200 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.1/8.18.1/Submit) id 596EwiHg027809 for openvpn-devel@lists.sourceforge.net; Mon, 6 Oct 2025 16:58:44 +0200 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Mon, 6 Oct 2025 16:58:37 +0200 Message-ID: <20251006145844.27794-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.49.1 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: Arne Schwabe 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 --- 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: 1v5mfw-0000ZA-OV Subject: [Openvpn-devel] [PATCH v4] Allowing installing FreeBSD routes with interface instead of next-hop 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: =?utf-8?q?1845244978969798286?= X-GMAIL-MSGID: =?utf-8?q?1845244978969798286?= From: Arne Schwabe 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 --- 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/+/1193 This mail reflects revision 4 of this Change. Acked-by according to Gerrit (reflected above): diff --git a/src/openvpn/networking_freebsd.c b/src/openvpn/networking_freebsd.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 = argv_new(); - bool status; + + ASSERT(gw || iface); _dst = ntohl(*dst); - _gw = 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 = 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); + } + else + { + argv_printf(&argv, "%s %s -net %s/%d -iface %s -fib %d", ROUTE_PATH, op, + inet_ntop(AF_INET, &_dst, buf1, sizeof(buf1)), prefixlen, + iface, table); + } argv_msg(M_INFO, &argv); - status = openvpn_execve_check(&argv, NULL, 0, "ERROR: FreeBSD route command failed"); + bool status = openvpn_execve_check(&argv, NULL, 0, "ERROR: FreeBSD route command failed"); argv_free(&argv); @@ -38,14 +50,26 @@ { char buf1[INET6_ADDRSTRLEN], buf2[INET6_ADDRSTRLEN]; struct argv argv = 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 gw is NULL, we are installing a route with the interface as target + * instead */ + if (gw) + { + 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); + } + 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 = openvpn_execve_check(&argv, NULL, 0, "ERROR: FreeBSD route command failed"); + bool status = openvpn_execve_check(&argv, NULL, 0, "ERROR: FreeBSD route command failed"); argv_free(&argv);