From patchwork Fri Feb 3 19:14: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: 3044 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7300:c95:b0:82:e4b3:40a0 with SMTP id p21csp1375973dyk; Fri, 3 Feb 2023 11:15:47 -0800 (PST) X-Google-Smtp-Source: AK7set/ZTjJYJZSgx0Fh5cv6ap64IDfj5PSmC68zRfwCRzFpq2Lo9/Q0nydCiCuHfLRP9u08/R5J X-Received: by 2002:a17:90b:38cc:b0:22c:61c:2d5b with SMTP id nn12-20020a17090b38cc00b0022c061c2d5bmr11923754pjb.20.1675451746964; Fri, 03 Feb 2023 11:15:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675451746; cv=none; d=google.com; s=arc-20160816; b=yVMp/n65tWORreEP7pJOdsuAgSXoDEkgolAFO54durx0XyAlcvlOdMavx3ne0ob7cj rIhMEoVoA1hpJfU0QpONbM6Z0t3fEUEbkzBpezi39loApKG6bMPsblluop1ees0Mm3fg 68lnhrG29W3ypSEiKo62oPn32Irs0LLnb+/BBBlpEhRGGLgH/hrgMS0t/ZI/6jwbOb56 kkm1ALKl2lJkj/fLB6e3DCp182zEt8A9CqkZuEvoFkATFau3kEyRWs88CEKEaP98vxRj s/jurHBtn6QDvxqaaHjaQRSiFF9VKLvBNPAgeVmeWMNwGFJGOoraAm9ql6tYzUe+OWpd sbbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:content-transfer-encoding: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; bh=PnojtCagxZbO4dg3q8xaZYobkf1RmMrQ0YT2eKPTjng=; b=czSPRwqoJauQFCngfR/uv1Y8u1X3Ema4vLb7mogPhyq9v8g1qzw1aMIqJez1fw6VTo ztqR93S/MdVQFkW6H4SGEe2/64FrqHVU2CtXAeKvHxbLP8AKdH+o0W8Iiqs2MIr/dLpQ ajI1NKGyfXagtblvvQEmyCtrCkA3+rgpjpNvgjy2k/a6Y41PIiDiSoiY7IC1MMIs1OUL wy7P3oaW3/LLOd771cWValeKJcVWfCECjY3AgX7sJoLMqlX3S6tNobbXklL9gpmQDgeK QGegWa+P/DfyZk/B/5+gTaLXyapq0Tq2Gnv7QONGidjIk0v6pLKhHm3ZuQggiZROGa4/ lw4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=lv++4KZ5; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=LrqgloAq; 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 d19-20020a17090ad3d300b0022c4ddf8413si8245299pjw.8.2023.02.03.11.15.46 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Feb 2023 11:15:46 -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=lv++4KZ5; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=LrqgloAq; 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-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1pO1WZ-0004rM-K4; Fri, 03 Feb 2023 19:15:02 +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.95) (envelope-from ) id 1pO1WU-0004qs-VO for openvpn-devel@lists.sourceforge.net; Fri, 03 Feb 2023 19:14:57 +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=Fkh59I6YnYXnfK5zlrVFF9B0jPZE1n6NUcy5xsTwwqc=; b=lv++4KZ5W5ColuUNQ6sdiFuDk7 mgIYu807jlQaNkvQLgGMw0rCfk4fQeSRu85hQVzOBmvx3xwq0Zo+e6eJjJfakkawslnWCSzFx/ynu ANhWzA4LVt9FFDge6j6l5SmDsDeVhbdVVLbTT56pXylAwRpV/451qbSQ/3be3hDz/Uy8=; 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=Fkh59I6YnYXnfK5zlrVFF9B0jPZE1n6NUcy5xsTwwqc=; b=LrqgloAq3Kwp73paBVQazVd09c ZLR4AJFyngwJ4iVioMKFZQo6Qz1eu+/Ghuix6nTr42m74DgbSRTBG9/P9xgr030+R3Q7P+Q2WalYh Ixr9v434X9CsUEw15sG3UKVdBTcvFRFeQ2EU0fYMUUrTCaixqdEoGkjiPgp/oC/6XGNM=; Received: from mout-p-202.mailbox.org ([80.241.56.172]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1pO1WS-00AMfa-I9 for openvpn-devel@lists.sourceforge.net; Fri, 03 Feb 2023 19:14:57 +0000 Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4P7lhf5Wxhz9sxf for ; Fri, 3 Feb 2023 20:14:42 +0100 (CET) From: Frank Lichtenheld To: openvpn-devel@lists.sourceforge.net Date: Fri, 3 Feb 2023 20:14:37 +0100 Message-Id: <20230203191440.136050-3-frank@lichtenheld.com> In-Reply-To: <20230203191440.136050-1-frank@lichtenheld.com> References: <20230203191440.136050-1-frank@lichtenheld.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 4P7lhf5Wxhz9sxf X-Spam-Score: -0.7 (/) 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: At this point it might be easier to create a dedicated function for Windows... Signed-off-by: Frank Lichtenheld --- src/openvpn/route.c | 32 ++++++++++++++++ 1 file changed, 16 insertions(+), 16 deletions(-) Content analysis details: (-0.7 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 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record X-Headers-End: 1pO1WS-00AMfa-I9 Subject: [Openvpn-devel] [PATCH 2/5] Windows: fix unused variables in delete_route_ipv6 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 X-GMAIL-THRID: =?utf-8?q?1756838491123133326?= X-GMAIL-MSGID: =?utf-8?q?1756838491123133326?= At this point it might be easier to create a dedicated function for Windows... Signed-off-by: Frank Lichtenheld Acked-by: Lev Stipakov --- src/openvpn/route.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/openvpn/route.c b/src/openvpn/route.c index 82519c94..3798bc65 100644 --- a/src/openvpn/route.c +++ b/src/openvpn/route.c @@ -2333,12 +2333,6 @@ delete_route_ipv6(const struct route_ipv6 *r6, const struct tuntap *tt, openvpn_net_ctx_t *ctx) { const char *network; -#if !defined(TARGET_LINUX) - const char *gateway; -#else - int metric; -#endif - bool gateway_needed = false; if ((r6->flags & (RT_DEFINED|RT_ADDED)) != (RT_DEFINED|RT_ADDED)) { @@ -2346,19 +2340,34 @@ delete_route_ipv6(const struct route_ipv6 *r6, const struct tuntap *tt, } #ifndef _WIN32 +#if !defined(TARGET_LINUX) + const char *gateway; +#else + int metric; +#endif + bool gateway_needed = false; const char *device = tt->actual_name; if (r6->iface != NULL) /* vpn server special route */ { device = r6->iface; gateway_needed = true; } + + /* if we used a gateway on "add route", we also need to specify it on + * delete, otherwise some OSes will refuse to delete the route + */ + if (tt->type == DEV_TYPE_TAP + && !( (r6->flags & RT_METRIC_DEFINED) && r6->metric == 0 ) ) + { + gateway_needed = true; + } #endif struct gc_arena gc = gc_new(); struct argv argv = argv_new(); network = print_in6_addr( r6->network, 0, &gc); -#if !defined(TARGET_LINUX) +#if !defined(TARGET_LINUX) && !defined(_WIN32) gateway = print_in6_addr( r6->gateway, 0, &gc); #endif @@ -2382,15 +2391,6 @@ delete_route_ipv6(const struct route_ipv6 *r6, const struct tuntap *tt, msg( M_INFO, "delete_route_ipv6(%s/%d)", network, r6->netbits ); - /* if we used a gateway on "add route", we also need to specify it on - * delete, otherwise some OSes will refuse to delete the route - */ - if (tt->type == DEV_TYPE_TAP - && !( (r6->flags & RT_METRIC_DEFINED) && r6->metric == 0 ) ) - { - gateway_needed = true; - } - #if defined(TARGET_LINUX) metric = -1; if ((r6->flags & RT_METRIC_DEFINED) && (r6->metric > 0))