From patchwork Sun Aug 7 09:35:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 2637 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director14.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net with LMTP id MCYPGFkU8GLRYgAAIUCqbw (envelope-from ) for ; Sun, 07 Aug 2022 15:36:57 -0400 Received: from proxy10.mail.ord1d.rsapps.net ([172.30.191.6]) by director14.mail.ord1d.rsapps.net with LMTP id 4ArzF1kU8GJqfQAAeJ7fFg (envelope-from ) for ; Sun, 07 Aug 2022 15:36:57 -0400 Received: from smtp17.gate.ord1d ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy10.mail.ord1d.rsapps.net with LMTPS id OBzLF1kU8GInYgAAfSg8FQ (envelope-from ) for ; Sun, 07 Aug 2022 15:36:57 -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: smtp17.gate.ord1d.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; dmarc=none (p=nil; dis=none) header.from=greenie.muc.de X-Suspicious-Flag: YES X-Classification-ID: 4be16792-1688-11ed-9693-5254008de1cb-1-1 Received: from [216.105.38.7] ([216.105.38.7:55230] helo=lists.sourceforge.net) by smtp17.gate.ord1d.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id C8/36-01072-85410F26; Sun, 07 Aug 2022 15:36:56 -0400 Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.94.2) (envelope-from ) id 1oKm3z-00039v-Ti; Sun, 07 Aug 2022 19:35:50 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1oKm3x-00039o-Ol for openvpn-devel@lists.sourceforge.net; Sun, 07 Aug 2022 19:35:48 +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: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:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=jaQUgrNz2B1OUEH6Cltu7Y/C+SL7TWGF7pqQPqk3NY8=; b=nUQ8eh+sJFviUzF/0aMqQhVUaN JRBQND/v52j3Ax2RS8M36WgORsKKOCuNKlUnPk5zHy2vcXAENOandbHV6vzhF9ZwnobHU3OXU0Ki6 qJC2+w06+WwOcQopLmwLCsTbTJ7YAp4lL8uKIcMv3Zvl7N6SAl8Y0ONXpAcW7lCQ4UmI=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version: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:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=jaQUgrNz2B1OUEH6Cltu7Y/C+SL7TWGF7pqQPqk3NY8=; b=a ZFV+Q7uxL0dOWLpTPRIdwWOo/PbF9IjtZb0Y6kXA6rOvNNNfXgGJndjap0CbVf+RqhkQzQGXDZzLZ gHgiYLWy8jCOnVFT5E8rZWjHvnrhUMHIKEp46aTnoCR0Jqbu9KBh7t7BoFBMLomgbb5qu6NnUu3wm c6F8db3G2J91Gtw0=; Received: from dhcp-174.greenie.muc.de ([193.149.48.174] 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.94.2) id 1oKm3u-006zyv-77 for openvpn-devel@lists.sourceforge.net; Sun, 07 Aug 2022 19:35:48 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.17.1/8.17.1) with ESMTP id 277JZbOj015394 for ; Sun, 7 Aug 2022 21:35:37 +0200 Received: (from gert@localhost) by blue.greenie.muc.de (8.17.1/8.17.1/Submit) id 277JZbBK015393 for openvpn-devel@lists.sourceforge.net; Sun, 7 Aug 2022 21:35:37 +0200 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Sun, 7 Aug 2022 21:35:35 +0200 Message-Id: <20220807193535.15377-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.35.1 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: All callers of open_tun_generic() always set dynamic=true - so just get rid of it. While at it, move "int i" into the for() loop. Signed-off-by: Gert Doering --- src/openvpn/tun.c | 23 +++++++++++ 1 file changed, 11 insertions(+), 12 deletions(-) Content analysis details: (-0.0 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record X-Headers-End: 1oKm3u-006zyv-77 Subject: [Openvpn-devel] [PATCH] Cleanup: get rid of 'dynamic' argument of open_tun_generic() 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 All callers of open_tun_generic() always set dynamic=true - so just get rid of it. While at it, move "int i" into the for() loop. Signed-off-by: Gert Doering Acked-by: Antonio Quartulli --- src/openvpn/tun.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index 659bd245..6e7c0197 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -1736,7 +1736,7 @@ tun_dco_enabled(struct tuntap *tt) #if !(defined(_WIN32) || defined(TARGET_LINUX)) static void open_tun_generic(const char *dev, const char *dev_type, const char *dev_node, - bool dynamic, struct tuntap *tt) + struct tuntap *tt) { char tunname[256]; char dynamic_name[256]; @@ -1767,7 +1767,7 @@ open_tun_generic(const char *dev, const char *dev_type, const char *dev_node, * opening /dev/tap and then querying the system about the * actual device name (tap0, tap1, ...) assigned */ - if (dynamic && strcmp( dev, "tap" ) == 0) + if (strcmp( dev, "tap" ) == 0) { struct ifreq ifr; if ((tt->fd = open( "/dev/tap", O_RDWR)) < 0) @@ -1786,10 +1786,9 @@ open_tun_generic(const char *dev, const char *dev_type, const char *dev_node, else #endif - if (dynamic && !tun_name_is_fixed(dev)) + if (!tun_name_is_fixed(dev)) { - int i; - for (i = 0; i < 256; ++i) + for (int i = 0; i < 256; ++i) { openvpn_snprintf(tunname, sizeof(tunname), "/dev/%s%d", dev, i); @@ -2682,7 +2681,7 @@ void open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tuntap *tt, openvpn_net_ctx_t *ctx) { - open_tun_generic(dev, dev_type, dev_node, true, tt); + open_tun_generic(dev, dev_type, dev_node, tt); /* Enable multicast on the interface */ if (tt->fd >= 0) @@ -2777,7 +2776,7 @@ void open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tuntap *tt, openvpn_net_ctx_t *ctx) { - open_tun_generic(dev, dev_type, dev_node, true, tt); + open_tun_generic(dev, dev_type, dev_node, tt); if (tt->fd >= 0) { @@ -2918,7 +2917,7 @@ void open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tuntap *tt, openvpn_net_ctx_t *ctx) { - open_tun_generic(dev, dev_type, dev_node, true, tt); + open_tun_generic(dev, dev_type, dev_node, tt); if (tt->fd >= 0 && tt->type == DEV_TYPE_TUN) { @@ -3047,7 +3046,7 @@ void open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tuntap *tt, openvpn_net_ctx_t *ctx) { - open_tun_generic(dev, dev_type, dev_node, true, tt); + open_tun_generic(dev, dev_type, dev_node, tt); if (tt->fd >= 0) { @@ -3300,7 +3299,7 @@ open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tun { /* No explicit utun and utun failed, try the generic way) */ msg(M_INFO, "Failed to open utun device. Falling back to /dev/tun device"); - open_tun_generic(dev, dev_type, NULL, true, tt); + open_tun_generic(dev, dev_type, NULL, tt); } else { @@ -3323,7 +3322,7 @@ open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tun dev_node = NULL; } - open_tun_generic(dev, dev_type, dev_node, true, tt); + open_tun_generic(dev, dev_type, dev_node, tt); } } @@ -7004,7 +7003,7 @@ void open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tuntap *tt, openvpn_net_ctx_t *ctx) { - open_tun_generic(dev, dev_type, dev_node, true, tt); + open_tun_generic(dev, dev_type, dev_node, tt); } void