From patchwork Wed Jun 13 02:28:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 371 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director12.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net (Dovecot) with LMTP id oz8yIFQOIVu4LwAAIUCqbw for ; Wed, 13 Jun 2018 08:30:12 -0400 Received: from proxy1.mail.ord1d.rsapps.net ([172.30.191.6]) by director12.mail.ord1d.rsapps.net (Dovecot) with LMTP id OfWzBlQOIVvbcQAAIasKDg ; Wed, 13 Jun 2018 08:30:12 -0400 Received: from smtp19.gate.ord1d ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy1.mail.ord1d.rsapps.net with LMTP id kMeDH1QOIVuoNAAAasrz9Q ; Wed, 13 Jun 2018 08:30:12 -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: smtp19.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=unstable.cc X-Suspicious-Flag: YES X-Classification-ID: 8388ca7a-6f05-11e8-8c2e-525400d67fa8-1-1 Received: from [216.105.38.7] ([216.105.38.7:38381] helo=lists.sourceforge.net) by smtp19.gate.ord1d.rsapps.net (envelope-from ) (ecelerity 4.2.1.56364 r(Core:4.2.1.14)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id FF/B0-02316-35E012B5; Wed, 13 Jun 2018 08:30:11 -0400 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.90_1) (envelope-from ) id 1fT4tq-0006QD-PW; Wed, 13 Jun 2018 12:29:18 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1fT4tn-0006Pg-PK for openvpn-devel@lists.sourceforge.net; Wed, 13 Jun 2018 12:29:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: 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=CO5c6GZXIUxQ02iiVT7vqSEe21e6DaEOnwyxsJIR+24=; b=ak4QlOUKi+Vrp7NDA5OXTjFVga dmDw86RqvQ/Elzx7N5Qio1Yo7UwnfzQBl0ECw+Iis4XgMvl+mh0N473Y6taMAoGZjX+ASnxyV/HEs E+tTLN5h6by5xXSRVLJhBz9tsD7+Lw97IzW0sIghE9hcFSIHcu+v/4yk8KL4kopnQ3S8=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To :MIME-Version:Content-Type:Content-Transfer-Encoding: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=CO5c6GZXIUxQ02iiVT7vqSEe21e6DaEOnwyxsJIR+24=; b=fWnngV6S5j5OjtuguWnkKU89ks pX1G5XCeyhkEOsUclmTB3nqie2AnEThb/Pvqtf/5ppuEnRZy1EeE6s/lCLysPX7J15KCKWH8zPlK7 2dAe5FTR/SJTP5yCC1wjl1djODbxVAqeH51Orq4ikm2G/NzBENID2nDzlbSs+C0XjBlA=; Received: from s2.neomailbox.net ([5.148.176.60]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) id 1fT4tm-007MJz-BQ for openvpn-devel@lists.sourceforge.net; Wed, 13 Jun 2018 12:29:15 +0000 From: Antonio Quartulli To: openvpn-devel@lists.sourceforge.net Date: Wed, 13 Jun 2018 20:28:24 +0800 Message-Id: <20180613122824.4207-4-a@unstable.cc> In-Reply-To: <20180613122824.4207-1-a@unstable.cc> References: <20180613122824.4207-1-a@unstable.cc> X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [5.148.176.60 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.1 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1fT4tm-007MJz-BQ Subject: [Openvpn-devel] [PATCH v2 3/3] tun: get rid of tt->did_ifconfig member 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: , Cc: Antonio Quartulli MIME-Version: 1.0 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox From: Antonio Quartulli tt->did_ifconfig is currently only read by the Linux platform, but it is currently uselessly set also by every other system. The Linux platform does not actually even need this member and can directly rely on tt->did_ifconfig_setup. For the reasons above, remove the tt->did_ifconfig at all and use tt->did_ifconfig_setup where needed (close_tun() on Linux). Signed-off-by: Antonio Quartulli Acked-by: Gert Doering --- Changes from v1: - fix typ0 in commit message src/openvpn/tun.c | 12 +----------- src/openvpn/tun.h | 1 - 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index 12b33ae7..48e7cc2e 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -987,7 +987,6 @@ do_ifconfig(struct tuntap *tt, argv_msg(M_INFO, &argv); openvpn_execve_check(&argv, es, S_FATAL, "Linux ip -6 addr add failed"); } - tt->did_ifconfig = true; #else /* ifdef ENABLE_IPROUTE */ if (tun) { @@ -1026,7 +1025,6 @@ do_ifconfig(struct tuntap *tt, argv_msg(M_INFO, &argv); openvpn_execve_check(&argv, es, S_FATAL, "Linux ifconfig inet6 failed"); } - tt->did_ifconfig = true; #endif /*ENABLE_IPROUTE*/ #elif defined(TARGET_ANDROID) @@ -1186,8 +1184,6 @@ do_ifconfig(struct tuntap *tt, add_route(&r, tt, 0, NULL, es); } - tt->did_ifconfig = true; - #elif defined(TARGET_OPENBSD) in_addr_t remote_end; /* for "virtual" subnet topology */ @@ -1265,7 +1261,6 @@ do_ifconfig(struct tuntap *tt, /* and, hooray, we explicitely need to add a route... */ add_route_connected_v6_net(tt, es); } - tt->did_ifconfig = true; #elif defined(TARGET_NETBSD) @@ -1327,7 +1322,6 @@ do_ifconfig(struct tuntap *tt, /* and, hooray, we explicitely need to add a route... */ add_route_connected_v6_net(tt, es); } - tt->did_ifconfig = true; #elif defined(TARGET_DARWIN) /* @@ -1384,7 +1378,6 @@ do_ifconfig(struct tuntap *tt, argv_msg(M_INFO, &argv); openvpn_execve_check(&argv, es, S_FATAL, "Mac OS X ifconfig failed"); - tt->did_ifconfig = true; /* Add a network route for the local tun interface */ if (!tun && tt->topology == TOP_SUBNET) @@ -1457,7 +1450,6 @@ do_ifconfig(struct tuntap *tt, argv_msg(M_INFO, &argv); openvpn_execve_check(&argv, es, S_FATAL, "FreeBSD ifconfig failed"); - tt->did_ifconfig = true; /* Add a network route for the local tun interface */ if (!tun && tt->topology == TOP_SUBNET) @@ -1507,7 +1499,6 @@ do_ifconfig(struct tuntap *tt, argv_msg(M_INFO, &argv); openvpn_execve_check(&argv, aix_es, S_FATAL, "AIX ifconfig failed"); - tt->did_ifconfig = true; if (do_ipv6) { @@ -1545,7 +1536,6 @@ do_ifconfig(struct tuntap *tt, break; } - tt->did_ifconfig = true; } if (do_ipv6) @@ -2104,7 +2094,7 @@ close_tun(struct tuntap *tt) { ASSERT(tt); - if (tt->type != DEV_TYPE_NULL && tt->did_ifconfig) + if (tt->type != DEV_TYPE_NULL && tt->did_ifconfig_setup) { struct argv argv = argv_new(); struct gc_arena gc = gc_new(); diff --git a/src/openvpn/tun.h b/src/openvpn/tun.h index 6c57ad0d..9495d602 100644 --- a/src/openvpn/tun.h +++ b/src/openvpn/tun.h @@ -138,7 +138,6 @@ struct tuntap bool did_ifconfig_setup; bool did_ifconfig_ipv6_setup; - bool did_ifconfig; bool persistent_if; /* if existed before, keep on program end */