From patchwork Sun Aug 21 23:28:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kristof Provost X-Patchwork-Id: 2709 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director13.mail.ord1d.rsapps.net ([172.31.255.6]) by backend30.mail.ord1d.rsapps.net with LMTP id uDbLGI5MA2NuZAAAIUCqbw (envelope-from ) for ; Mon, 22 Aug 2022 05:29:50 -0400 Received: from proxy7.mail.iad3b.rsapps.net ([172.31.255.6]) by director13.mail.ord1d.rsapps.net with LMTP id 0L6KGI5MA2ODJwAA91zNiA (envelope-from ) for ; Mon, 22 Aug 2022 05:29:50 -0400 Received: from smtp34.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy7.mail.iad3b.rsapps.net with LMTPS id 0FFkEI5MA2NQWAAAQkQ5tQ (envelope-from ) for ; Mon, 22 Aug 2022 05:29:50 -0400 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp34.gate.iad3b.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dkim=fail (signature verification failed) header.d=netgate.com; dmarc=pass (p=none; dis=none) header.from=lists.sourceforge.net X-Suspicious-Flag: YES X-Classification-ID: f7d58996-21fc-11ed-a2d6-5254005e8ddb-1-1 Received: from [216.105.38.7] ([216.105.38.7:51618] helo=lists.sourceforge.net) by smtp34.gate.iad3b.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 00/79-12219-D8C43036; Mon, 22 Aug 2022 05:29:49 -0400 Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1oQ3jq-0006c7-HQ; Mon, 22 Aug 2022 09:28:54 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1oQ3jm-0006bx-3Y for openvpn-devel@lists.sourceforge.net; Mon, 22 Aug 2022 09:28:50 +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=fGZUUrdOYu6YK8j0W+O4fz4Sj1UELrsUxm+B9oCp/Pg=; b=clBfGtZqQEEa6qJnKDD9V8NLZN GfH9YFJc5Cwh4QUfu7/z6ayueX1H3YPCt5kjkZh4vbUv6VUW72xgtNGsRJrua/4CMI19ytweaMEJ+ v7I0RcGatBoHFX/GUVmspzYGONiDsjqNS8R4P5avwX332PDb41JOWul4RujU3GdpEmnU=; 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=fGZUUrdOYu6YK8j0W+O4fz4Sj1UELrsUxm+B9oCp/Pg=; b=NeibgyyrPUejl5WMNDl7LGVV1h 2AzS7eu7ubw1XgHCEv5+IzC67IEaKyejN0COW2+9Xi+aqtuhK4j/c79v6Z6usL5+mHeHoaQpL87oe FpLnHZBule0tHdOBMr92hmsS7ScWAxcBdvamfOtYGzrQ61cp6wjOJ7YYoUZvtxnEBb6Y=; Received: from mail-ej1-f46.google.com ([209.85.218.46]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1oQ3jh-00CxJA-Ig for openvpn-devel@lists.sourceforge.net; Mon, 22 Aug 2022 09:28:50 +0000 Received: by mail-ej1-f46.google.com with SMTP id w19so19930439ejc.7 for ; Mon, 22 Aug 2022 02:28:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netgate.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc; bh=fGZUUrdOYu6YK8j0W+O4fz4Sj1UELrsUxm+B9oCp/Pg=; b=SCvI3O3iS6eHqsFuTyaoMygvli9kpW7DvuWFsvz+9F7v79DDK1zXE7hK+9q/JNY4rY bjiO9jOLNCvRkzlr7KiTj4hSG9TlZG4iQBkBBfXIldIK6ndIdYy6rrE4SKrdsqv3yIoB kReztUm8IEuFe3i5aLajOXNa7r5nd4bMp8SLA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc; bh=fGZUUrdOYu6YK8j0W+O4fz4Sj1UELrsUxm+B9oCp/Pg=; b=bF105d2SjwCr+Ip2oiOc9qlMEPKkKIVOEkTX16x8mqk4cVZgpS1k7ED1gZm2MWm6bo ylc+y9HcEKrtcv1IYXqwNiZ088ehToOARDQ6dT7eELaeEQYrLeoumK1L+ru/CHIU533I 2p4RcxDi2zXFBbDp1NiUQqkM3T5pem/DiGgReHEw5Q7egtnRboHJNtZaZ4vjWsv6f4gL hiJBtbWjmSyL6DWdG1gycKqWtX/iuSNau0R0Xji9CeLDbfjlru42N0Z2s+vIQ3YQL2FW xkd7w34ZZWYoBKODYdgZAloadKBugaAUfeiEGWX0+gxEZd+eQUN6Kvyxa8lYJiyWKO+f AiEQ== X-Gm-Message-State: ACgBeo2bvc4aDmI4890QfCP6BTyqtSYSq3v8xFT4c4xdgSV9s4cyZqKG KKGEZjg8gV/+KLfSR5gqu9/gpVLG/moKXg== X-Google-Smtp-Source: AA6agR5bhf2IaStYvhssacSQNr3CsC2GZCOVM36t4N37D78c79LRabua6ZN71QT9+CsWKn7b3uwblQ== X-Received: by 2002:a17:907:1614:b0:73d:7c02:e090 with SMTP id hb20-20020a170907161400b0073d7c02e090mr3260440ejc.166.1661160518850; Mon, 22 Aug 2022 02:28:38 -0700 (PDT) Received: from nut.jupiter.sigsegv.be (ptr-8ripfq6ujrcnucff0d4.18120a2.ip6.access.telenet.be. [2a02:1811:2419:3500:f602:70ff:feae:6e98]) by smtp.googlemail.com with ESMTPSA id kx19-20020a170907775300b0073d7ab84375sm1778472ejc.92.2022.08.22.02.28.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Aug 2022 02:28:38 -0700 (PDT) To: openvpn-devel Date: Mon, 22 Aug 2022 11:28:34 +0200 Message-Id: <20220822092834.14231-2-kprovost@netgate.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220822092834.14231-1-kprovost@netgate.com> References: <20220812134154.16729-3-kprovost@netgate.com> <20220822092834.14231-1-kprovost@netgate.com> MIME-Version: 1.0 X-Spam-Report: Spam detection software, running on the system "util-spamd-1.v13.lw.sourceforge.com", 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: Kristof Provost Address a few minor code review remarks: - use constants for the inet_ntop() buffers - replace argv_printf() + argv_printf_cat() with a single argv_printf() - net_route_v4/6 both add and remove, so adjust the error message to reflect that. Content analysis details: (-0.2 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.218.46 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.218.46 listed in wl.mailspike.net] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-Headers-End: 1oQ3jh-00CxJA-Ig Subject: [Openvpn-devel] [PATCH] FreeBSD networking cleanup 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: , X-Patchwork-Original-From: Kristof Provost via Openvpn-devel From: Kristof Provost Reply-To: Kristof Provost Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox From: Kristof Provost Address a few minor code review remarks: - use constants for the inet_ntop() buffers - replace argv_printf() + argv_printf_cat() with a single argv_printf() - net_route_v4/6 both add and remove, so adjust the error message to reflect that. Signed-off-by: Kristof Provost Acked-by: Gert Doering --- src/openvpn/networking_freebsd.c | 34 +++++++++++++++----------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/openvpn/networking_freebsd.c b/src/openvpn/networking_freebsd.c index 5fcb738e..0633dce7 100644 --- a/src/openvpn/networking_freebsd.c +++ b/src/openvpn/networking_freebsd.c @@ -15,7 +15,7 @@ net_route_v4(const char *op, const in_addr_t *dst, int prefixlen, const in_addr_t *gw, const char *iface, uint32_t table, int metric) { - char buf1[16], buf2[16]; + char buf1[INET_ADDRSTRLEN], buf2[INET_ADDRSTRLEN]; in_addr_t _dst, _gw; struct argv argv = argv_new(); bool status; @@ -23,17 +23,16 @@ net_route_v4(const char *op, const in_addr_t *dst, int prefixlen, _dst = ntohl(*dst); _gw = ntohl(*gw); - argv_printf(&argv, "%s %s", - ROUTE_PATH, op); - argv_printf_cat(&argv, "-net %s/%d %s -fib %d", - inet_ntop(AF_INET, &_dst, buf1, sizeof(buf1)), - prefixlen, - inet_ntop(AF_INET, &_gw, buf2, sizeof(buf2)), - table); + 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); argv_msg(M_INFO, &argv); status = openvpn_execve_check(&argv, NULL, 0, - "ERROR: FreeBSD route add command failed"); + "ERROR: FreeBSD route command failed"); argv_free(&argv); @@ -45,21 +44,20 @@ net_route_v6(const char *op, const struct in6_addr *dst, int prefixlen, const struct in6_addr *gw, const char *iface, uint32_t table, int metric) { - char buf1[64], buf2[64]; + char buf1[INET6_ADDRSTRLEN], buf2[INET6_ADDRSTRLEN]; struct argv argv = argv_new(); bool status; - argv_printf(&argv, "%s -6 %s", - ROUTE_PATH, op); - argv_printf_cat(&argv, "-net %s/%d %s -fib %d", - inet_ntop(AF_INET6, dst, buf1, sizeof(buf1)), - prefixlen, - inet_ntop(AF_INET6, gw, buf2, sizeof(buf2)), - table); + 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); argv_msg(M_INFO, &argv); status = openvpn_execve_check(&argv, NULL, 0, - "ERROR: FreeBSD route add command failed"); + "ERROR: FreeBSD route command failed"); argv_free(&argv);