Skip to contentSkip to conversation

Repair topology subnet on FreeBSD 11

PATCH In review Gert Doering 3 participants 8 messages Nov 8, 2016 – Dec 8, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Repair topology subnet on FreeBSD 11

We used to add "route for this subnet" by using our own address as the gateway address, which used to mean "connected to the interface, no gateway". FreeBSD commit 293159 changed the kernel side of that assumption so "my address" is now always bound to "lo0" - thus, our subnet route also ended up pointing to "lo0", breaking connectivity for all hosts in the subnet except the one we used as "remote".

commit 60fd44e501f200 already introduced a "remote address" we use for the "ifconfig tunX <us> <remote>" part - extend that to be used as gateway address for the "tunX subnet" as well, and things will work more robustly.

Tested on FreeBSD 11.0-RELEASE and 7.4-RELEASE (client and server) (this particular issue is not present before 11.0, but "adding the subnet route" never worked right, not even in 7.4 - 11.0 just made the problem manifest more clearly)

Trac #425
URL: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=207831

---
 src/openvpn/tun.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
src/openvpn/tun.c +8 -5
index af685de..a6d38d5 100644
@@ -721,8 +721,8 @@ void delete_route_connected_v6_net(struct tuntap * tt,
  * is still point to point and no layer 2 resolution is done...
  */
 
-const char *
-create_arbitrary_remote( struct tuntap *tt, struct gc_arena * gc )
+in_addr_t
+create_arbitrary_remote( struct tuntap *tt )
 {
   in_addr_t remote;
 
@@ -730,7 +730,7 @@ create_arbitrary_remote( struct tuntap *tt, struct gc_arena * gc )
 
   if ( remote == tt->local ) remote ++;
 
-  return print_in_addr_t (remote, 0, gc);
+  return remote;
 }
 #endif
 
@@ -1230,6 +1230,8 @@ do_ifconfig (struct tuntap *tt,
 
 #elif defined(TARGET_FREEBSD)||defined(TARGET_DRAGONFLY)
 
+      in_addr_t remote_end;		/* for "virtual" subnet topology */
+
       /* example: ifconfig tun2 10.2.0.2 10.2.0.1 mtu 1450 netmask 255.255.255.255 up */
       if (tun)
 	argv_printf (&argv,
@@ -1242,12 +1244,13 @@ do_ifconfig (struct tuntap *tt,
 			  );
       else if ( tt->topology == TOP_SUBNET )
 	{
+	    remote_end = create_arbitrary_remote( tt );
 	    argv_printf (&argv,
 			  "%s %s %s %s mtu %d netmask %s up",
 			  IFCONFIG_PATH,
 			  actual,
 			  ifconfig_local,
-			  create_arbitrary_remote( tt, &gc ),
+			  print_in_addr_t (remote_end, 0, &gc),
 			  tun_mtu,
 			  ifconfig_remote_netmask
 			  );
@@ -1274,7 +1277,7 @@ do_ifconfig (struct tuntap *tt,
           r.flags = RT_DEFINED;
           r.network = tt->local & tt->remote_netmask;
           r.netmask = tt->remote_netmask;
-          r.gateway = tt->local;
+          r.gateway = remote_end;
           add_route (&r, tt, 0, NULL, es);
         }
 
Signature · 1 line
2.9.2
#1 lore raw

Hi,

Quoted 74 lines · Gert Doering

We used to add "route for this subnet" by using our own address as the gateway address, which used to mean "connected to the interface, no gateway". FreeBSD commit 293159 changed the kernel side of that assumption so "my address" is now always bound to "lo0" - thus, our subnet route also ended up pointing to "lo0", breaking connectivity for all hosts in the subnet except the one we used as "remote".

commit 60fd44e501f200 already introduced a "remote address" we use for the "ifconfig tunX <us> <remote>" part - extend that to be used as gateway address for the "tunX subnet" as well, and things will work more robustly.

Tested on FreeBSD 11.0-RELEASE and 7.4-RELEASE (client and server) (this particular issue is not present before 11.0, but "adding the subnet route" never worked right, not even in 7.4 - 11.0 just made the problem manifest more clearly)

Trac #425
URL: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=207831

---
 src/openvpn/tun.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
src/openvpn/tun.c +7 -4
index af685de..a6d38d5 100644
@@ -721,8 +721,8 @@ void delete_route_connected_v6_net(struct tuntap * tt,
  * is still point to point and no layer 2 resolution is done...
  */
 
-const char *
-create_arbitrary_remote( struct tuntap *tt, struct gc_arena * gc )
+in_addr_t
+create_arbitrary_remote( struct tuntap *tt )
 {
   in_addr_t remote;
 
@@ -730,7 +730,7 @@ create_arbitrary_remote( struct tuntap *tt, struct gc_arena * gc )
 
   if ( remote == tt->local ) remote ++;
 
-  return print_in_addr_t (remote, 0, gc);
+  return remote;
 }
 #endif
 
@@ -1230,6 +1230,8 @@ do_ifconfig (struct tuntap *tt,
 
 #elif defined(TARGET_FREEBSD)||defined(TARGET_DRAGONFLY)
 
+      in_addr_t remote_end;		/* for "virtual" subnet topology */
+
       /* example: ifconfig tun2 10.2.0.2 10.2.0.1 mtu 1450 netmask 255.255.255.255 up */
       if (tun)
 	argv_printf (&argv,
@@ -1242,12 +1244,13 @@ do_ifconfig (struct tuntap *tt,
 			  );
       else if ( tt->topology == TOP_SUBNET )
 	{
+	    remote_end = create_arbitrary_remote( tt );
 	    argv_printf (&argv,
 			  "%s %s %s %s mtu %d netmask %s up",
 			  IFCONFIG_PATH,
 			  actual,
 			  ifconfig_local,
-			  create_arbitrary_remote( tt, &gc ),
+			  print_in_addr_t (remote_end, 0, &gc),
 			  tun_mtu,
 			  ifconfig_remote_netmask
 			  );

src/openvpn/tun.c do_ifconfig (struct tuntap *tt, · line 1283

Quoted 8 lines
src/openvpn/tun.c +1 -1
@@ -1274,7 +1277,7 @@ do_ifconfig (struct tuntap *tt,
           r.flags = RT_DEFINED;
           r.network = tt->local & tt->remote_netmask;
           r.netmask = tt->remote_netmask;
-          r.gateway = tt->local;
+          r.gateway = remote_end;
           add_route (&r, tt, 0, NULL, es);
         }
 

Code-ACK.

I didn't test (no freebsd for me), but Gert did, and the pfsense guys (garga, in particular) reported this patch resolves their issue in #425.

-Steffan

#2 lore raw
In reply to Gert Doering

Thanks for testing & review :-)

Patch has been applied to the master and release/2.3 branch.

commit a433b3813d8c38b491d2baa7b433973f2d6cd7c6 (master) commit 446ef5bda4cdc75d4cb955e274846faff0181fd3 (release/2.3)

Author: Gert Doering
Date:   Tue Nov 8 13:45:06 2016 +0100
     Repair topology subnet on FreeBSD 11

     URL: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=207831
     Signed-off-by: Gert Doering <[email protected]...>
     Acked-by: Steffan Karger <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg12950.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#3 lore raw

Am 09.11.2016 um 21:14 schrieb Gert Doering:

Quoted 9 lines

Thanks for testing & review :-)

Patch has been applied to the master and release/2.3 branch.

commit a433b3813d8c38b491d2baa7b433973f2d6cd7c6 (master) commit 446ef5bda4cdc75d4cb955e274846faff0181fd3 (release/2.3)

Author: Gert Doering
Date:   Tue Nov 8 13:45:06 2016 +0100
Quoted 8 lines
     Repair topology subnet on FreeBSD 11

     URL: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=207831
     Signed-off-by: Gert Doering <[email protected]...>
     Acked-by: Steffan Karger <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg12950.html
     Signed-off-by: Gert Doering <[email protected]...>

This is now part of FreeBSD's openvpn 2.3.13_1 (on the port's head) and masked by an option that I enable by default and that I've dubbed FIXSUBNET. <https://svnweb.freebsd.org/ports?view=revision&revision=425811>.

If nothing new crops up, I can request to merge this back to the quarterly (stable) branch and drop the option if someone deems this urgent, else it will propagate to stable ports in early January 2017. I should probably kick the option before then and make this patch regular (unless 2.3.14 is out sooner, but I understand if people want to focus on getting 2.4.0 into Debian).

#4 lore raw

Hi,

Quoted 1 line · Matthias Andree
Quoted 1 line

Repair topology subnet on FreeBSD 11

[..]

Quoted 4 lines

This is now part of FreeBSD's openvpn 2.3.13_1 (on the port's head) and masked by an option that I enable by default and that I've dubbed FIXSUBNET. <https://svnweb.freebsd.org/ports?view=revision&revision=425811>.

Thanks, this is useful.

Quoted 6 lines

If nothing new crops up, I can request to merge this back to the quarterly (stable) branch and drop the option if someone deems this urgent, else it will propagate to stable ports in early January 2017. I should probably kick the option before then and make this patch regular (unless 2.3.14 is out sooner, but I understand if people want to focus on getting 2.4.0 into Debian).

I might be tempted to do a quick 2.3.14 release in between - there's two important platform fixes in that branch now (FreeBSD and OpenBSD topology subnet :-) ) and Lev's recursive routing patch. Add to that the windows block-outside-dns patch that I hope to be testing this weekend, and it's worth a minor bugfix release... at least "before January".

gert

Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
                                                           //www.muc.de/~gert/
Gert Doering - Munich, Germany                             [email protected]...
fax: +49-89-35655025                        [email protected]...
#5 lore raw

Am 11.11.2016 um 23:10 schrieb Gert Doering:

Quoted 5 lines

I might be tempted to do a quick 2.3.14 release in between - there's two important platform fixes in that branch now (FreeBSD and OpenBSD topology subnet :-) ) and Lev's recursive routing patch. Add to that the windows block-outside-dns patch that I hope to be testing this weekend, and it's worth a minor bugfix release... at least "before January".

Well, for me to update the FreeBSD port, mid December 2016 would be cool for anything (2.3.14, or 2.4.0, or both) due to the before-xmas-madness and to have like two weeks for smoke testing.

On the other hand, we're not Debian or Ubuntu, and the FreeBSD ports-secteam (who own the stable "quarterly" ports branch) take a rather pragmatic or management approach than drive their principles and policies home...

Also, since the FreeBSD stable ports branches follow a three-months-lifetime scheme, anything we miss in December will go in in April 2017 rather than January, and it's also easy enough to update OpenVPN to the ports HEAD branch if needed ahead of time by some user. While not formally supported, it works for OpenVPN.

Bottom line, give Debian the priority, and while it would be nice to have for FreeBSD, no need to rush.

#6 lore raw

Re: [Openvpn-devel] FreeBSD port versions (was: [PATCH applied] Re: Repair topology subnet on FreeBSD 11)

Hi,

Quoted 10 lines · Matthias Andree

Am 11.11.2016 um 23:10 schrieb Gert Doering:

Quoted 5 lines

I might be tempted to do a quick 2.3.14 release in between - there's two important platform fixes in that branch now (FreeBSD and OpenBSD topology subnet :-) ) and Lev's recursive routing patch. Add to that the windows block-outside-dns patch that I hope to be testing this weekend, and it's worth a minor bugfix release... at least "before January".

Well, for me to update the FreeBSD port, mid December 2016 would be cool for anything (2.3.14, or 2.4.0, or both) due to the before-xmas-madness and to have like two weeks for smoke testing.

Here we go :-) - Nikolaus present, 2.3.14.

2.4_beta2 is waiting for someone to bump the openvpn-devel port, but everyone is busy, it seems (PR#214930).

I wonder what the best approach towards 2.4 in ports would be, though - introduce an openvpn23 port, and bump "openvpn" to 2.4.0 when that happens? Or introduce it as "openvpn24"?

"operating system wise", 2.4.0 should be as good on FreeBSD as 2.3.14 (because all the platform fixes went into both branches), but there might be hidden bugs lurking in the "non-client, non-platform" bits that are new in 2.4

Quoted 2 lines

Bottom line, give Debian the priority, and while it would be nice to have for FreeBSD, no need to rush.

So far we've managed to keep to our timeline, which currently says "2.4_rc2 next week, and 2.4.0 end of the year" (two weeks of testing phase for rc2)

gert

Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
                                                           //www.muc.de/~gert/
Gert Doering - Munich, Germany                             [email protected]...
fax: +49-89-35655025                        [email protected]...
#7 lore raw

Re: [Openvpn-devel] FreeBSD port versions

Am 06.12.2016 um 22:02 schrieb Gert Doering:

Quoted 12 lines

Hi,

Quoted 9 lines · Matthias Andree

Am 11.11.2016 um 23:10 schrieb Gert Doering:

Quoted 5 lines

I might be tempted to do a quick 2.3.14 release in between - there's two important platform fixes in that branch now (FreeBSD and OpenBSD topology subnet :-) ) and Lev's recursive routing patch. Add to that the windows block-outside-dns patch that I hope to be testing this weekend, and it's worth a minor bugfix release... at least "before January".

Well, for me to update the FreeBSD port, mid December 2016 would be cool for anything (2.3.14, or 2.4.0, or both) due to the before-xmas-madness and to have like two weeks for smoke testing.

Quoted 8 lines

Here we go :-) - Nikolaus present, 2.3.14.

2.4_beta2 is waiting for someone to bump the openvpn-devel port, but everyone is busy, it seems (PR#214930).

I wonder what the best approach towards 2.4 in ports would be, though - introduce an openvpn23 port, and bump "openvpn" to 2.4.0 when that happens? Or introduce it as "openvpn24"?

I've updated the port to 2.3.14 last night (there was a glitch that didn't affect OpenVPN but cost my time), and have just committed the FreeBSD Bugzilla's #214930.

Assuming we trust the future OpenVPN 2.4.0 enough, the canonical way for me will be to copy openvpn 2.3.14 to a new port named openvpn23, mark it deprecated with an expiration half a year from then or 2017-06-30 so it doesn't make the 2017Q3 "quarterly" stable branch, and update the plain port from 2.3.14 to 2.4.0. All other concerns as we see fit.

Quoted 4 lines

"operating system wise", 2.4.0 should be as good on FreeBSD as 2.3.14 (because all the platform fixes went into both branches), but there might be hidden bugs lurking in the "non-client, non-platform" bits that are new in 2.4

Sure, but that needs testing. I wonder if we temporarily need -rc ports on top of the existing -devel. Expect - due to the pre-XMas madness - that I need a few days to reply though. Anything important with the OpenVPN-related FreeBSD ports, Cc: me directly.