From patchwork Wed Nov 17 06:54:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maximilian Fillinger X-Patchwork-Id: 2078 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director14.mail.ord1d.rsapps.net ([172.27.255.50]) by backend30.mail.ord1d.rsapps.net with LMTP id kNgXNGFClWFkTQAAIUCqbw (envelope-from ) for ; Wed, 17 Nov 2021 12:56:49 -0500 Received: from proxy13.mail.iad3a.rsapps.net ([172.27.255.50]) by director14.mail.ord1d.rsapps.net with LMTP id cGTKM2FClWGoSwAAeJ7fFg (envelope-from ) for ; Wed, 17 Nov 2021 12:56:49 -0500 Received: from smtp35.gate.iad3a ([172.27.255.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy13.mail.iad3a.rsapps.net with LMTPS id 4AgcLWFClWGjQgAAwhxzoA (envelope-from ) for ; Wed, 17 Nov 2021 12:56:49 -0500 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: smtp35.gate.iad3a.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 (key not found in DNS) header.d=foxcrypto.com; dmarc=fail (p=none; dis=none) header.from=foxcrypto.com X-Suspicious-Flag: YES X-Classification-ID: bc7b9d98-47cf-11ec-9bc5-52540083445f-1-1 Received: from [216.105.38.7] ([216.105.38.7:35132] helo=lists.sourceforge.net) by smtp35.gate.iad3a.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id AF/6B-02491-16245916; Wed, 17 Nov 2021 12:56:49 -0500 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 1mnP9b-0002Wj-C3; Wed, 17 Nov 2021 17:55:27 +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 1mnP9Z-0002Wd-LX for openvpn-devel@lists.sourceforge.net; Wed, 17 Nov 2021 17:55:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:Content-Transfer-Encoding:MIME-Version :Message-ID:Date:Subject:CC:To:From:Sender:Reply-To: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=3y4F2pOKHSUgZUa7IRpwbjPiD3tuftX2Vz/H8p+5Q8g=; b=mnNiIoo93Jo9wfZzxzpIpO/7kI 2b0ZzNR3xfqxeqAegjMaoQD9QBqWTAi844/MDIPRsT23rqizpcu6WC5c8eWbO7LUh6IEkUDB2ecZg 8w/SLvo+sjwK06bYiZ8tfv+sjfZOVmx7f40R7FvuUl9tbjRE81CtHx4H+ewGUg5IO6SI=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:Content-Transfer-Encoding:MIME-Version:Message-ID:Date: Subject:CC:To:From:Sender:Reply-To: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=3y4F2pOKHSUgZUa7IRpwbjPiD3tuftX2Vz/H8p+5Q8g=; b=P F2Q1bRGcWYuK+ONYgczrps92tnBfulqoftukLbftQNsz0utCFjZwPN3VR5umEV4rPj8u4kCWTfh22 omT28PAu968FkYxkDe8gQPIdf6LsTL5tQrNXtSSbk0cAmR/S486nlC+jaDt5h+SuYoP9NBwxIChGf fQuO28DGtlKI22LE=; Received: from nl-dft-mx-01.fox-it.com ([178.250.144.135]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.3) id 1mnP9S-00GZar-WC for openvpn-devel@lists.sourceforge.net; Wed, 17 Nov 2021 17:55:25 +0000 From: Max Fillinger To: Date: Wed, 17 Nov 2021 18:54:24 +0100 Message-ID: <20211117175424.17195-1-maximilian.fillinger@foxcrypto.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-ClientProxiedBy: FOXDFT1EX01.FOX.local (10.0.0.129) To FOXDFT1EX01.FOX.local (10.0.0.129) X-FE-Policy-ID: 13:3:2:SYSTEM DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; d=foxcrypto.com; s=NL-DFT-MX-01; c=relaxed/relaxed; h=from:to:cc:subject:date:message-id:mime-version:content-type; bh=3y4F2pOKHSUgZUa7IRpwbjPiD3tuftX2Vz/H8p+5Q8g=; b=amxZ3P5yOxxW+BMraOYQ80u7Xi3FeAikT+p7zGd5E89LsI9xmGnmsND2JwD/VQOOSwmpCewfc+aX PB80gV1InDuSpekuv/z+B2Kh0Srv4jklrSZX7LISj1NmJTfDuDNePT5ltGOyMLUl3xG7R3V+oHyB ygCMgH0k1FNA04chs96G8C1j4JH95iyVHzV7uKzdzm7UaETv/xYoDbpeSQBFifr6iNEV2xBOtK9v vpn6Z1rlB9/X5zsKnyumdgisvfM5vzbFayn9Q17xL2pw+sDbMneAD5wJ4ZQmTTXVetAwvaFORs6N Wyq+S+QcSZ+hy4BoUzJ663CZQ597krdv6DVvwg== 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: When running with --ifconfig-noexec on Linux, OpenVPN may still delete the ip address from the tun interface on exit, because it tries to undo the ifconfig that did not actually happen. This commit reintroduces the did_ifconfig member to struct tuntap so that we can check if ifconfig was actually done before trying to undo it. It's behind an #ifdef because it's only used on Linux, an [...] Content analysis details: (0.2 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.1 DKIM_INVALID DKIM or DK signature exists, but is not valid X-Headers-End: 1mnP9S-00GZar-WC Subject: [Openvpn-devel] [PATCH] Don't "undo" ifconfig when given --ifconfig-noexec 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 When running with --ifconfig-noexec on Linux, OpenVPN may still delete the ip address from the tun interface on exit, because it tries to undo the ifconfig that did not actually happen. This commit reintroduces the did_ifconfig member to struct tuntap so that we can check if ifconfig was actually done before trying to undo it. It's behind an #ifdef because it's only used on Linux, and that was the reason why it was removed before. Signed-off-by: Max Fillinger --- src/openvpn/tun.c | 6 +++++- src/openvpn/tun.h | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index 75d5eaf7..32e739fc 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -1601,6 +1601,10 @@ do_ifconfig(struct tuntap *tt, const char *ifname, int tun_mtu, do_ifconfig_ipv6(tt, ifname, tun_mtu, es, ctx); } +#ifdef TARGET_LINUX + tt->did_ifconfig = true; +#endif + /* release resources potentially allocated during interface setup */ net_ctx_free(ctx); } @@ -2190,7 +2194,7 @@ close_tun(struct tuntap *tt, openvpn_net_ctx_t *ctx) { ASSERT(tt); - if (tt->type != DEV_TYPE_NULL) + if (tt->type != DEV_TYPE_NULL && tt->did_ifconfig) { if (tt->did_ifconfig_setup) { diff --git a/src/openvpn/tun.h b/src/openvpn/tun.h index aa1e47b5..1f579e34 100644 --- a/src/openvpn/tun.h +++ b/src/openvpn/tun.h @@ -162,6 +162,9 @@ struct tuntap bool did_ifconfig_setup; bool did_ifconfig_ipv6_setup; +#ifdef TARGET_LINUX + bool did_ifconfig; +#endif bool persistent_if; /* if existed before, keep on program end */