From patchwork Wed Dec 20 13:36:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Lichtenheld X-Patchwork-Id: 3533 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7301:d588:b0:100:28a5:529c with SMTP id ev8csp1547844dyc; Wed, 20 Dec 2023 05:37:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IE2tzohlm+HigzbzqtuKobvuH99lW4ojdl+wBVPxpjdLRRu1xEHe4m2AOerw9DpEIE65Gc7 X-Received: by 2002:a17:902:fe01:b0:1d3:e001:5953 with SMTP id g1-20020a170902fe0100b001d3e0015953mr4946627plj.5.1703079439187; Wed, 20 Dec 2023 05:37:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703079439; cv=none; d=google.com; s=arc-20160816; b=BWfIv1Lk4Kkym0PlxUSbfHu/HJMDwEwhox6lUEKyA/0ULnciLflGvfdNOkGXSpzT0M DRlCz1TCGzMrPTXeOQ/HMNgAn+x2GsD0H4utks5HDpsy1Nn/ey9dGFf7QKaiuWs56Jn+ TUFYO/bF6cTcZHSKeI5u1pVybBSqcOujbvZeq6CCXelu0wlO+LORy0FoPuV+VEtUZOTQ /vSnCk9DVizezQf0v4tMjqoM5mP+WHEMmwSMmBQzvFdlLm2vaNmuoY9IWHHUeGYOnJAN LAzSjmV2pAQBa07smLco5UZsaWbxWX3VWMt5R1GL1urSi47yUO/CCr95ouOgwk4ySEfL MP9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:content-transfer-encoding:cc: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=oEieNkklE9rP8DeWO8c+19fl394RvDwzcwiPxgiMrGE=; fh=ZRBZ3p4fvLYBwsG7McdxRCx2fnmH9YCsPK+JAqT+6LA=; b=ctjlW8IrO0tg1s7iGy5civdaCDA3jQ5PqUKe/R1LHimnf1JiiZTbMVvNxS9/oxcDpA u3RLdB2wsMzOPAQtNNWf1eg/DY/m0sw5Thktwve590fb18XlnV1cwRSM00EhUoXV4heZ CIKs4hL0VTPmNmtNBVDBJIo5zEIdqDvnraVsZfeEQw+zCIgSwLiPHm4b0mnTMCq172Fa ytaEsFF9bPqICMQBhNoV4BOeT6GFxfoMidR636iAZLBGLE1VeRYg4eLzFItmXODMyJgN pzbcLh/KrLFH3Sdyvd4K0LFLiaKyWYtOX5euwTPJol0MiIDSKlYCAeY/9E0gdKEFImkd oL1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=K3wEjbp7; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=SDIhpeIF; dkim=neutral (body hash did not verify) header.i=@lichtenheld.com header.s=MBO0001 header.b=rNlvZ48V; 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 Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id p8-20020a1709026b8800b001d3482dc1b4si13482022plk.369.2023.12.20.05.37.19 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Dec 2023 05:37:19 -0800 (PST) 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=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=K3wEjbp7; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=SDIhpeIF; dkim=neutral (body hash did not verify) header.i=@lichtenheld.com header.s=MBO0001 header.b=rNlvZ48V; 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 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 1rFwks-0008DI-UF; Wed, 20 Dec 2023 13:36:57 +0000 Received: from [172.30.20.202] (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 1rFwkr-0008D8-7x for openvpn-devel@lists.sourceforge.net; Wed, 20 Dec 2023 13:36:56 +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:Cc:To:From:Sender:Reply-To: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=u+DafgP+60/gOngQQw20MoNqYmL9F6vtPItBUxAsEIM=; b=K3wEjbp7up6eORU2d+omzttsUd jugy0k+VnfkisVuBQaPWZe9kvH2aD8oT44TwUwngsFYntwrBqHBF7ezwoEOdGuSx+OrIq38iqGkv0 BHy28QJkQCmCRWYVGUDJA8mRZwA2d2vXOtVmSu5CJFQRAbYUZKjZJ4mwnyJgLt/jokPw=; 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:Cc:To:From:Sender:Reply-To: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=u+DafgP+60/gOngQQw20MoNqYmL9F6vtPItBUxAsEIM=; b=SDIhpeIFEwopq8+rtQTrLp9eaS AyDd5EjZKY2VbJnW0lbBWnNHa3n/dVyLV+y4zvjbXMDf+NXwupfPUGvOFQ7ClU3kwtDEGeDgVbXpE jYDvA4fhWSBoWM7E4m00P1CRxE5TYfwhWIHbGMLbZ63CJ3daZDhPCvmc5VjOe+HuokyU=; Received: from mout-p-202.mailbox.org ([80.241.56.172]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1rFwkk-0008W6-Fj for openvpn-devel@lists.sourceforge.net; Wed, 20 Dec 2023 13:36:55 +0000 Received: from smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4SwF2t5kyMz9spn; Wed, 20 Dec 2023 14:36:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lichtenheld.com; s=MBO0001; t=1703079398; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u+DafgP+60/gOngQQw20MoNqYmL9F6vtPItBUxAsEIM=; b=rNlvZ48VTkXOV1KjM+XX05Z///9jtiPgGzP4vHpPEL9PVCIejgy1lVZpt83gBOOcL4s2I/ J7WJDlyIwxd9eYcz56QZMPCzvEjtvMp7xoqGOYr+5tRIP7YDaCCL7NgZWsI9MLHDSATECm uQKe/CsTlJr8tCPeCAX6kCHZeI6nX+eGA+ibQQrUlcL6oQfdFh7u99lBXskmKYwZlbJqXg cIUw5KC0Lau6HsYt6H1B8YqcbT1giZSsClEpFdZTO8QvvFxuePgwO4bU401QOtY7hz0Eaz mKvAWJYiobr4PlTwetqiy6+F8LHdN+dkSbiknThDNLfvms1H0T+DVuTodqiwag== From: Frank Lichtenheld To: openvpn-devel@lists.sourceforge.net Date: Wed, 20 Dec 2023 14:36:37 +0100 Message-Id: <20231220133637.60996-1-frank@lichtenheld.com> In-Reply-To: References: MIME-Version: 1.0 X-Spam-Score: -0.9 (/) 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: Lev Stipakov Commits 1c4a47f7 ("wintun: set adapter properties via interactive service") 18826de5 ("Set WINS servers via interactice service") Content analysis details: (-0.9 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [80.241.56.172 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H5 RBL: Excellent reputation (+5) [80.241.56.172 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders -0.0 T_SCC_BODY_TEXT_LINE No description available. X-Headers-End: 1rFwkk-0008W6-Fj Subject: [Openvpn-devel] [PATCH v2] tun.c: don't attempt to delete DNS and WINS servers if they're not set 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: Lev Stipakov Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1785808226150795308?= X-GMAIL-MSGID: =?utf-8?q?1785808226150795308?= From: Lev Stipakov Commits 1c4a47f7 ("wintun: set adapter properties via interactive service") 18826de5 ("Set WINS servers via interactice service") added functionality of add/remove DNS/WINS via interactive service, which is used mostly by dco-win and wintun (tap-windows6 normally uses DHCP). There is a check in code - if DNS/WINS addresses are not pushed, nothing is added. However, due to bug we always attempted to remove DNS/WINS, even if nothing was added. Removing WINS, for example, could take up to 3 seconds. This change fixes this by improving check "has DNS/WINS been pushed?". While on it, convert do_XXX_service() functions to "void" from "bool", since we never check their return values. Change-Id: I21a36d24f8e213c780f55acbe3e4df555c93542a Signed-off-by: Lev Stipakov Acked-by: Frank Lichtenheld --- 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/+/482 This mail reflects revision 2 of this Change. Acked-by according to Gerrit (reflected above): Frank Lichtenheld diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index f1b8699..8e96149 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -147,17 +147,16 @@ return ret; } -static bool +static void do_dns_domain_service(bool add, const struct tuntap *tt) { - bool ret = false; ack_message_t ack; struct gc_arena gc = gc_new(); HANDLE pipe = tt->options.msg_channel; if (!tt->options.domain) /* no domain to add or delete */ { - return true; + goto out; } /* Use dns_cfg_msg with addr_len = 0 for setting only the DOMAIN */ @@ -195,17 +194,14 @@ } msg(M_INFO, "DNS domain %s using service", (add ? "set" : "deleted")); - ret = true; out: gc_free(&gc); - return ret; } -static bool +static void do_dns_service(bool add, const short family, const struct tuntap *tt) { - bool ret = false; ack_message_t ack; struct gc_arena gc = gc_new(); HANDLE pipe = tt->options.msg_channel; @@ -213,9 +209,10 @@ int addr_len = add ? len : 0; const char *ip_proto_name = family == AF_INET6 ? "IPv6" : "IPv4"; - if (addr_len == 0 && add) /* no addresses to add */ + if (len == 0) { - return true; + /* nothing to do */ + goto out; } /* Use dns_cfg_msg with domain = "" for setting only the DNS servers */ @@ -272,26 +269,23 @@ } msg(M_INFO, "%s dns servers %s using service", ip_proto_name, (add ? "set" : "deleted")); - ret = true; out: gc_free(&gc); - return ret; } -static bool +static void do_wins_service(bool add, const struct tuntap *tt) { - bool ret = false; ack_message_t ack; struct gc_arena gc = gc_new(); HANDLE pipe = tt->options.msg_channel; - int len = tt->options.wins_len; - int addr_len = add ? len : 0; + int addr_len = add ? tt->options.wins_len : 0; - if (addr_len == 0 && add) /* no addresses to add */ + if (tt->options.wins_len == 0) { - return true; + /* nothing to do */ + goto out; } wins_cfg_message_t wins = { @@ -338,11 +332,9 @@ } msg(M_INFO, "WINS servers %s using service", (add ? "set" : "deleted")); - ret = true; out: gc_free(&gc); - return ret; } static bool @@ -7019,10 +7011,7 @@ { do_dns_domain_service(false, tt); } - if (tt->options.dns6_len > 0) - { - do_dns_service(false, AF_INET6, tt); - } + do_dns_service(false, AF_INET6, tt); delete_route_connected_v6_net(tt); do_address_service(false, AF_INET6, tt); }