From b8f70b0f25c44e6d6a17b9f76756de87146a55d9 Mon Sep 17 00:00:00 2001
From: Gert Doering <gert@greenie.muc.de>
Date: Sun, 26 Apr 2015 18:16:39 +0200
Subject: [PATCH] Fix FreeBSD ifconfig for topology subnet tunnels.
For "topology subnet", we only pretend to have a subnet and keep
using the tun if in point-to-point mode - but for that to fully
work, the "remote" address needs to be different from the "local"
address. So just arbitrarily construct one from the on-link
subnet - base+1, if "that is not us", base+2, otherwise.
Fix trac #481
Signed-off-by: Gert Doering <gert@greenie.muc.de>
---
src/openvpn/tun.c | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c
index 11a6d71..aa7a9f0 100644
a
|
b
|
void delete_route_connected_v6_net(struct tuntap * tt, |
626 | 626 | } |
627 | 627 | #endif |
628 | 628 | |
| 629 | #if defined(TARGET_FREEBSD)||defined(TARGET_DRAGONFLY) |
| 630 | /* we can't use true subnet mode on tun on all platforms, as that |
| 631 | * conflicts with IPv6 (wants to use ND then, which we don't do), |
| 632 | * but the OSes want "a remote address that is different from ours" |
| 633 | * - so we construct one, normally the first in the subnet, but if |
| 634 | * this is the same as ours, use the second one. |
| 635 | * The actual address does not matter at all, as the tun interface |
| 636 | * is still point to point and no layer 2 resolution is done... |
| 637 | */ |
| 638 | |
| 639 | char * |
| 640 | create_arbitrary_remote( struct tuntap *tt, struct gc_arena * gc ) |
| 641 | { |
| 642 | in_addr_t remote; |
| 643 | |
| 644 | remote = (tt->local & tt->remote_netmask) +1; |
| 645 | |
| 646 | if ( remote == tt->local ) remote ++; |
| 647 | |
| 648 | return print_in_addr_t (remote, 0, &gc); |
| 649 | } |
| 650 | #endif |
629 | 651 | |
630 | 652 | /* execute the ifconfig command through the shell */ |
631 | 653 | void |
… |
… |
do_ifconfig (struct tuntap *tt, |
1150 | 1172 | IFCONFIG_PATH, |
1151 | 1173 | actual, |
1152 | 1174 | ifconfig_local, |
1153 | | ifconfig_local, |
| 1175 | create_arbitrary_remote( tt, &gc ), |
1154 | 1176 | tun_mtu, |
1155 | 1177 | ifconfig_remote_netmask |
1156 | 1178 | ); |