From patchwork Fri Oct 2 07:57:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 1501 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director9.mail.ord1d.rsapps.net ([172.27.255.58]) by backend30.mail.ord1d.rsapps.net with LMTP id SGlZIi9ud19qBAAAIUCqbw (envelope-from ) for ; Fri, 02 Oct 2020 14:15:11 -0400 Received: from proxy21.mail.iad3a.rsapps.net ([172.27.255.58]) by director9.mail.ord1d.rsapps.net with LMTP id eN9EIi9ud19ZOQAAalYnBA (envelope-from ) for ; Fri, 02 Oct 2020 14:15:11 -0400 Received: from smtp9.gate.iad3a ([172.27.255.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy21.mail.iad3a.rsapps.net with LMTPS id kDKlGi9ud1/QGgAASBQwCQ (envelope-from ) for ; Fri, 02 Oct 2020 14:15:11 -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: smtp9.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; dmarc=none (p=nil; dis=none) header.from=greenie.muc.de X-Suspicious-Flag: YES X-Classification-ID: 343f1f00-04db-11eb-aa36-52540097fc8c-1-1 Received: from [216.105.38.7] ([216.105.38.7:51204] helo=lists.sourceforge.net) by smtp9.gate.iad3a.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 84/A8-18295-D2E677F5; Fri, 02 Oct 2020 14:15:09 -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 1kOPZH-00010N-2a; Fri, 02 Oct 2020 18:14:07 +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 1kOPZF-0000zu-CF for openvpn-devel@lists.sourceforge.net; Fri, 02 Oct 2020 18:14:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:Content-Type:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: 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=0ppbogYX6ajecEpsv/EI4wYEp8llovodH82Hy/vbP2o=; b=HaSIaoJoAMypYkeRIHJXoooQ5M gCvmOfk2oL231z7dep0yCqzFrKCxdtZUlY9AbZAJc1OzEvVO9m/1GoKg39unG0hb2oYPRQn/UoE7M Hu6P+sRnQ43+hfjkDumE3uUm2bA2QqJC+G7BoKabwOlKi7km6Wd2zU3GFmjUI1Rcqf/I=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: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=0ppbogYX6ajecEpsv/EI4wYEp8llovodH82Hy/vbP2o=; b=TFKiBObX/BXCJApnM6ecDdE4fj NfL9dybI7mA5RoZUUsajtEUp+DX+sKW48+PH0IMEUK2JjluMBoaxVqOxJj6aJtGnYR1zbrc0rBfLo YcUD9ah23wMGPRFvDYCw3140RU+KbGpC0Bn7sHJ5BadixK6hpTrQRGDW6gsZbc3rKH6w=; Received: from vmail1.greenie.net ([195.30.8.66]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1kOPZ4-000795-JB for openvpn-devel@lists.sourceforge.net; Fri, 02 Oct 2020 18:14:05 +0000 Received: from fbsd-tc.ov.greenie.net (fbsd-tc.ov.greenie.net [IPv6:2001:608:0:814:0:0:f000:21]) by vmail1.greenie.net (8.16.1/8.12.11) with ESMTPS id 092Hvav2016657 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 2 Oct 2020 19:57:36 +0200 (CEST) Received: from fbsd-tc.ov.greenie.net (localhost [127.0.0.1]) by fbsd-tc.ov.greenie.net (8.15.2/8.15.2) with ESMTPS id 092Hvaeb082653 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO) for ; Fri, 2 Oct 2020 19:57:36 +0200 (CEST) (envelope-from gert@fbsd-tc.ov.greenie.net) Received: (from gert@localhost) by fbsd-tc.ov.greenie.net (8.15.2/8.15.2/Submit) id 092Hva5A082652 for openvpn-devel@lists.sourceforge.net; Fri, 2 Oct 2020 19:57:36 +0200 (CEST) (envelope-from gert) From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Fri, 2 Oct 2020 19:57:36 +0200 Message-Id: <20201002175736.82609-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <63aacbfb-20a0-de78-fccb-bbf8a2ad4189@tuxed.net> References: <63aacbfb-20a0-de78-fccb-bbf8a2ad4189@tuxed.net> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (vmail1.greenie.net [IPv6:2001:608:1:995a:20c:29ff:feb8:10eb]); Fri, 02 Oct 2020 19:57:36 +0200 (CEST) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: muc.de] 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-Headers-End: 1kOPZ4-000795-JB Subject: [Openvpn-devel] [PATCH] Fix redirecting of IPv4 default gateway if connecting over 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 Commit aa34684972eb0 fixed a long-standing bug in setting the "route-list" flag RTSA_REMOTE_HOST for IPv4 ("we have a well-defined remote_host == VPN server IP address") even if connecting over IPv6. Unfortunately the logic in redirect_default_route_to_vpn() was also wrong, and refused cooperation if that flag is not set, triggering the message "NOTE: unable to redirect IPv4 default gateway -- Cannot obtain current remote host address" Correct operation: if RTSA_REMOTE_HOST is not set, or remote_host is IPV4_INVALID_ADDR (= 255.255.255.255), do not try to install a host route for continued connectivity to the VPN server - which is not needed when connecting over IPv6. But the actual *routes* (/0 or 2 x /1) can be installed just fine. There is a second bug here, which hits if there is no IPv4 gateway at all. In that case, the same function triggers the message "NOTE: unable to redirect IPv4 default gateway -- Cannot read current default gateway from system" This is caused by using "IPV4_INVALID_ADDR" as a flag for "do we know the remote_host?" - which worked before, but after the commit said above, the "remote_host" field is not well-defined unless RTSA_REMOTE_HOST is set. So, change the condition to check that. Reported-By: François Kooman Reported-By: Thomas Schäfer Trac: #1332 Signed-off-by: Gert Doering Signed-off-by: Antonio Quartulli --- src/openvpn/route.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/openvpn/route.c b/src/openvpn/route.c index d75aa5f4..8037d8b3 100644 --- a/src/openvpn/route.c +++ b/src/openvpn/route.c @@ -1011,14 +1011,10 @@ redirect_default_route_to_vpn(struct route_list *rl, const struct tuntap *tt, * - we are connecting to a non-IPv4 remote host (i.e. we use IPv6) */ else if (!(rl->rgi.flags & RGI_ADDR_DEFINED) && !local - && (rl->spec.remote_host != IPV4_INVALID_ADDR)) + && (rl->spec.flags & RTSA_REMOTE_HOST)) { msg(M_WARN, "%s Cannot read current default gateway from system", err); } - else if (!(rl->spec.flags & RTSA_REMOTE_HOST)) - { - msg(M_WARN, "%s Cannot obtain current remote host address", err); - } else { #ifndef TARGET_ANDROID @@ -1041,7 +1037,8 @@ redirect_default_route_to_vpn(struct route_list *rl, const struct tuntap *tt, /* route remote host to original default gateway */ /* if remote_host is not ipv4 (ie: ipv6), just skip * adding this special /32 route */ - if (rl->spec.remote_host != IPV4_INVALID_ADDR) + if ((rl->spec.flags & RTSA_REMOTE_HOST) + && rl->spec.remote_host != IPV4_INVALID_ADDR) { add_route3(rl->spec.remote_host, IPV4_NETMASK_HOST,