| Message ID | 2f575943f32de2328843b3cec3286ca1@shambarger.net |
|---|---|
| State | New |
| Delegated to: | Gert Doering |
| Headers |
Return-Path: <openvpn-devel-bounces@lists.sourceforge.net> Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director8.mail.ord1d.rsapps.net ([172.27.255.50]) by backend30.mail.ord1d.rsapps.net (Dovecot) with LMTP id JP4DImCH+1pLBwAAIUCqbw for <patchwork@openvpn.net>; Tue, 15 May 2018 21:20:32 -0400 Received: from proxy2.mail.iad3a.rsapps.net ([172.27.255.50]) by director8.mail.ord1d.rsapps.net (Dovecot) with LMTP id 6fOgDWCH+1qhUgAAfY0hYg ; Tue, 15 May 2018 21:20:32 -0400 Received: from smtp7.gate.iad3a ([172.27.255.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy2.mail.iad3a.rsapps.net with LMTP id KPd2HmCH+1pdXgAABcWvHw ; Tue, 15 May 2018 21:20:32 -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: smtp7.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=pass header.d=lists.sourceforge.net; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dkim=fail (signature verification failed) header.d=shambarger.net; dmarc=pass (p=none; dis=none) header.from=lists.sourceforge.net X-Suspicious-Flag: NO X-Classification-ID: 5312f628-58a7-11e8-a668-525400bbebb8-1-1 Received: from [216.105.38.7] ([216.105.38.7:38013] helo=lists.sourceforge.net) by smtp7.gate.iad3a.rsapps.net (envelope-from <openvpn-devel-bounces@lists.sourceforge.net>) (ecelerity 4.2.1.56364 r(Core:4.2.1.14)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id CD/11-17586-F578BFA5; Tue, 15 May 2018 21:20:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Type:Content-Transfer-Encoding: Reply-To:From:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Subject:Message-ID:To:Date:MIME-Version:Sender:Cc: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=VUQ38w2eQcdHVLntx8aYV7LvjNzZllVFg6PtJ2N770I=; b=JtfrWmxF7RAtR9Q7vEr8EMUJ96 IwdZPwmhZ3cgFXwjIqkyewyPNfiKZYtdx0MBIXtfHChDhqVxgNj88C7TZoHdW0/yT4pQVbzOYXNWo mXS4QhD+1gwwiMqH2X/BpRm/oDozhxRNQLinhLkaPX2KtwfegYbbVHOylDlSTnfxdENQ=; 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.90_1) (envelope-from <openvpn-devel-bounces@lists.sourceforge.net>) id 1fIl6G-0004ij-N1; Wed, 16 May 2018 01:19:28 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from <devel@shambarger.net>) id 1fIl6F-0004ic-2D for openvpn-devel@lists.sourceforge.net; Wed, 16 May 2018 01:19:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Message-ID:Subject:To:From:Date: Content-Transfer-Encoding:Content-Type:MIME-Version:Sender:Reply-To:Cc: 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=ohGgCVmKu7KroEq95q5fu2IObrsbQH+h6mS0UzeMO+o=; b=EmxZv+2yZND95unmdm5XRImLe GpTD3EQ+sNAZ4caWzCgI34N51Sr3WxomC7plLSRmL8F985GUIIXWfHsgFAFr0QLa4Sbpmo1dsh+fb rj3x38Fm2aoHEMKzCeIMnTBnuaZSW2uohKkqyZy3fFYOEXVPvSqeGDKVXduYRc6gc6Jz4=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Message-ID:Subject:To:From:Date:Content-Transfer-Encoding:Content-Type: MIME-Version:Sender:Reply-To:Cc: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=ohGgCVmKu7KroEq95q5fu2IObrsbQH+h6mS0UzeMO+o=; b=m //O6HK5ujwu6NjUqPfcRP3LmEFHr9yaTJ+9GIB6FdEeZDJacRCvqHZv5wCerBlUDLq9mNXHgY7HH2 PB6VHaxbkqjbwgZT2+ib7cfs6nIK/zPRNZtoPTD4XugR2scGVuOtETXbfKu3PmVbI1n9xJbmVG/5s Nh4ztcFsv2X8YniQ=; Received: from shambarger.net ([209.76.109.246]) by sfi-mx-4.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) id 1fIl6D-008ShK-9x for openvpn-devel@lists.sourceforge.net; Wed, 16 May 2018 01:19:26 +0000 Received: from www.shambarger.net (shambarger.net [IPv6:fd7d:beef:beef::1]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by shambarger.net (Postfix) with ESMTPSA id 92093E0DC0 for <openvpn-devel@lists.sourceforge.net>; Tue, 15 May 2018 18:01:41 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 shambarger.net 92093E0DC0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shambarger.net; s=s2048; t=1526432501; bh=ohGgCVmKu7KroEq95q5fu2IObrsbQH+h6mS0UzeMO+o=; h=Date:From:To:Subject:From; b=s9MSn3LRE6ED4dn7lK6M/L7IN1G+e738ic2vaLX+NUIgNtp3FjxsbCT29V4PQPe9F uV8Jc02CnwbB9ytbw6Re4cYnhAzOMYlHD0TLWcIf+UKEaTyN8q1IiIJ9/9Qp1TBy+G bfGEYVDbJFVNXCtPfbkqhRhaegveH0qLtWRtl0KBQfQXbp5Tz6m5Agq+mZHwu4Gd2r 8qoLOEYIG672/++Quy/TrY7HntvXlnjrPtNWBWtjUzt4gZYyBco50qOIL/1doccqOL DMpTFkpxWs0HDYPuJLd6tp+VapuEINbov8vWX5b3A81w7ZHa64OmSmh9ihhlaQ3hYa DKJXiSXbWbVPQ== MIME-Version: 1.0 Date: Tue, 15 May 2018 18:01:41 -0700 To: openvpn-devel@lists.sourceforge.net Message-ID: <2f575943f32de2328843b3cec3286ca1@shambarger.net> X-Sender: devel@shambarger.net User-Agent: Roundcube Webmail/1.3.6 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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 X-Headers-End: 1fIl6D-008ShK-9x Subject: [Openvpn-devel] Darwin tap ipv6 fix X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: <openvpn-devel.lists.sourceforge.net> List-Unsubscribe: <https://lists.sourceforge.net/lists/options/openvpn-devel>, <mailto:openvpn-devel-request@lists.sourceforge.net?subject=unsubscribe> List-Archive: <http://sourceforge.net/mailarchive/forum.php?forum_name=openvpn-devel> List-Post: <mailto:openvpn-devel@lists.sourceforge.net> List-Help: <mailto:openvpn-devel-request@lists.sourceforge.net?subject=help> List-Subscribe: <https://lists.sourceforge.net/lists/listinfo/openvpn-devel>, <mailto:openvpn-devel-request@lists.sourceforge.net?subject=subscribe> From: Scott Shambarger via Openvpn-devel <openvpn-devel@lists.sourceforge.net> Reply-To: Scott Shambarger <devel@shambarger.net> Content-Transfer-Encoding: base64 Content-Type: text/plain; charset="utf-8"; Format="flowed" Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox |
| Series |
[Openvpn-devel] Darwin tap ipv6 fix
|
|
Commit Message
haixiao.yan.cn--- via Openvpn-devel
May 15, 2018, 3:01 p.m. UTC
I’m setting up a tap config on a Darwin client (Tunnelblick on OSX) to a
Linux server (Fedora). The config has the following (only relevant
portions):
== server
dev tap0
server-bridge
push "redirect-gateway def1 ipv6"
push "ifconfig-ipv6 {local-ipv6-address} {linklocal-addr}”
…etc
== client
client
dev tap
remote {host} {port} udp4
…etc
The ipv4 vpn works fine, but the routes created for ipv6 are on the
wrong interface — they're on the network transport interface, not the
tap interface. This causes ipv6 to not function (since the
{linklocal-addr} cannot be reached on that network interface)
I tracked the problem to route.c around line 1880 (in v2.4.6 at least).
(a) There is Darwin/BSD specific code that modifies the gateway string
variable to include the interface name (to “<gatewayip>%<iface>”) if
gateway_needed is true, but it only works if r6->iface is non-NULL.
(b) the gateway_needed flag is set for tap devices, but only after it’s
checked in (a).
I’ve included a patch below that moves (b) above (a), and uses the local
“device" variable (which is either the tt->actual_name, or r6->iface if
set) when creating the modified gateway string. With this change, the
routes are created on the correct interface — the logs show:
== before
add_route_ipv6(::/3 -> {linklocal-addr} metric -1) dev tap0
/sbin/route add -inet6 :: -prefixlen 3 {linklocal-addr}
add net ::: gateway {linklocal-addr}
== after
add_route_ipv6(::/3 -> {linklocal-addr}%tap0 metric -1) dev tap0
/sbin/route add -inet6 :: -prefixlen 3 {linklocal-addr}%tap0
add net ::: gateway {linklocal-addr}%tap0
NOTE1: In the process of setting this up, I noticed a warning message to
gives the wrong advice (route.c:453):
msg(M_WARN, PACKAGE_NAME " ROUTE6: " PACKAGE_NAME " needs a
gateway par\
ameter for a --route-ipv6 option and no default was specified by either
--route\
-ipv6-gateway or --ifconfig-ipv6 options");
... There is no "route-ipv6-gateway" option (although it'd be nice to
have one, since for tap at least the {local-ipv6-address} on the
ifconfig-ipv6 option (in my config above) appears to be ignored.
NOTE2: Since ipv6 does automatic address configuration anyway... it'd be
nice to add a ipv6 equivalent to the dhcp_extract_router_msg() function
(called in forward.c to get the DHCP gateway) that extracts the default
gateway so that ifconfig-ipv6 isn't needed at all. I'd be happy to make
an attempt at that if it'd be useful :)
Thanks,
Scott
+
#if defined(TARGET_DARWIN) \
|| defined(TARGET_FREEBSD) || defined(TARGET_DRAGONFLY) \
|| defined(TARGET_OPENBSD) || defined(TARGET_NETBSD)
@@ -1887,12 +1899,12 @@ add_route_ipv6(struct route_ipv6 *r6, const
struct tuntap *tt, unsigned int flag
* but for link-local destinations, we MUST specify the interface,
so
* we build a combined "$gateway%$interface" gateway string
*/
- if (r6->iface != NULL && gateway_needed
+ if (gateway_needed
&& IN6_IS_ADDR_LINKLOCAL(&r6->gateway) ) /*
fe80::...%intf */
{
- int len = strlen(gateway) + 1 + strlen(r6->iface)+1;
+ int len = strlen(gateway) + 1 + strlen(device)+1;
char *tmp = gc_malloc( len, true, &gc );
- snprintf( tmp, len, "%s%%%s", gateway, r6->iface );
+ snprintf( tmp, len, "%s%%%s", gateway, device );
gateway = tmp;
}
#endif
@@ -1905,18 +1917,6 @@ add_route_ipv6(struct route_ipv6 *r6, const
struct tuntap *tt, unsigned int flag
* (not currently done for IPv6)
*/
- /* On "tun" interface, we never set a gateway if the operating
system
- * can do "route to interface" - it does not add value, as the
target
- * dev already fully qualifies the route destination on
point-to-point
- * interfaces. OTOH, on "tap" interface, we must always set the
- * gateway unless the route is to be an on-link network
- */
- if (tt->type == DEV_TYPE_TAP
- && !( (r6->flags & RT_METRIC_DEFINED) && r6->metric == 0 ) )
- {
- gateway_needed = true;
- }
-
#if defined(TARGET_LINUX)
#ifdef ENABLE_IPROUTE
argv_printf(&argv, "%s -6 route add %s/%d dev %s",
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Comments
Hi, On Tue, May 15, 2018 at 06:01:41PM -0700, Scott Shambarger via Openvpn-devel wrote: > - if (r6->iface != NULL && gateway_needed > + if (gateway_needed > && IN6_IS_ADDR_LINKLOCAL(&r6->gateway) ) /* > fe80::...%intf */ > { > - int len = strlen(gateway) + 1 + strlen(r6->iface)+1; > + int len = strlen(gateway) + 1 + strlen(device)+1; This part will break routes that need to go over the LAN interface, not over the tap interface - namely, the /128 that is installed if you have overlapping v6-over-v6 setups (... if you have link-local next hops). So NAK on the patch "as is" - for the rest, I'll look into it next week. gert
On 2018-05-16 05:16, Gert Doering wrote: > > This part will break routes that need to go over the LAN interface, not > over the tap interface - namely, the /128 that is installed if you > have overlapping v6-over-v6 setups (... if you have link-local next > hops). > Are you sure it won't work? There's some code higher up in the function that appears to handle that case: #ifndef _WIN32 if (r6->iface != NULL) /* vpn server special route */ { device = r6->iface; if (!IN6_IS_ADDR_UNSPECIFIED(&r6->gateway) ) { gateway_needed = true; } } #endif I'll test it on my build if you can point me towards an example... > So NAK on the patch "as is" - for the rest, I'll look into it next > week. Thanks! Scott ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Hi, On Wed, May 16, 2018 at 11:26:15AM -0700, Scott Shambarger via Openvpn-devel wrote: > On 2018-05-16 05:16, Gert Doering wrote: > > This part will break routes that need to go over the LAN interface, not > > over the tap interface - namely, the /128 that is installed if you > > have overlapping v6-over-v6 setups (... if you have link-local next > > hops). > > Are you sure it won't work? There's some code higher up in the function > that appears to handle that case: > > #ifndef _WIN32 > if (r6->iface != NULL) /* vpn server special route */ > { > device = r6->iface; > if (!IN6_IS_ADDR_UNSPECIFIED(&r6->gateway) ) > { > gateway_needed = true; > } > } You might be right. Need to look more closely at the whole #ifdef mess - and look at our MacOS X buildslave, which seems to work just fine with the current code in tap mode... but I might have managed (again) to build a test rig that does not excercise all relevant code paths. gert
Hi, cleaning up loose ends, and this is one of the things on my plate - sorry for stalling so long., On Tue, May 15, 2018 at 06:01:41PM -0700, Scott Shambarger via Openvpn-devel wrote: > I???m setting up a tap config on a Darwin client (Tunnelblick on OSX) to a > Linux server (Fedora). The config has the following (only relevant > portions): > > == server > dev tap0 > server-bridge > push "redirect-gateway def1 ipv6" > push "ifconfig-ipv6 {local-ipv6-address} {linklocal-addr}??? > ???etc I saw something now that I overlooked last time: you have a {linklocal-addr} here, in the "gateway address" position. This is the reason why it is failing, and also the reason why my test rigs are not picking up the problem - I never envisioned that someone would want to use a link-local address here, if you have a GUA around (so this is a case which has never been tested, and as link-local needs special handling, the various conditional checks are not picking it up correctly) gert
diff --git a/src/openvpn/route.c b/src/openvpn/route.c index 2d6428b2..35ae8d09 100644 --- a/src/openvpn/route.c +++ b/src/openvpn/route.c @@ -1879,6 +1879,18 @@ add_route_ipv6(struct route_ipv6 *r6, const struct tuntap *tt, unsigned int flag network = print_in6_addr( r6->network, 0, &gc); gateway = print_in6_addr( r6->gateway, 0, &gc); + /* On "tun" interface, we never set a gateway if the operating system + * can do "route to interface" - it does not add value, as the target + * dev already fully qualifies the route destination on point-to-point + * interfaces. OTOH, on "tap" interface, we must always set the + * gateway unless the route is to be an on-link network + */ + if (tt->type == DEV_TYPE_TAP + && !( (r6->flags & RT_METRIC_DEFINED) && r6->metric == 0 ) ) + { + gateway_needed = true; + }