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
See also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=194745
Signed-off-by: Gert Doering <gert@greenie.muc.de>
Tested-By: Anton Sayetsky <vsasjason@gmail.com>
Lazy-ACK-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1430071438-31675-1-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9606
... | ... |
@@ -631,6 +631,28 @@ void delete_route_connected_v6_net(struct tuntap * tt, |
631 | 631 |
} |
632 | 632 |
#endif |
633 | 633 |
|
634 |
+#if defined(TARGET_FREEBSD)||defined(TARGET_DRAGONFLY) |
|
635 |
+/* we can't use true subnet mode on tun on all platforms, as that |
|
636 |
+ * conflicts with IPv6 (wants to use ND then, which we don't do), |
|
637 |
+ * but the OSes want "a remote address that is different from ours" |
|
638 |
+ * - so we construct one, normally the first in the subnet, but if |
|
639 |
+ * this is the same as ours, use the second one. |
|
640 |
+ * The actual address does not matter at all, as the tun interface |
|
641 |
+ * is still point to point and no layer 2 resolution is done... |
|
642 |
+ */ |
|
643 |
+ |
|
644 |
+char * |
|
645 |
+create_arbitrary_remote( struct tuntap *tt, struct gc_arena * gc ) |
|
646 |
+{ |
|
647 |
+ in_addr_t remote; |
|
648 |
+ |
|
649 |
+ remote = (tt->local & tt->remote_netmask) +1; |
|
650 |
+ |
|
651 |
+ if ( remote == tt->local ) remote ++; |
|
652 |
+ |
|
653 |
+ return print_in_addr_t (remote, 0, &gc); |
|
654 |
+} |
|
655 |
+#endif |
|
634 | 656 |
|
635 | 657 |
/* execute the ifconfig command through the shell */ |
636 | 658 |
void |
... | ... |
@@ -1155,7 +1177,7 @@ do_ifconfig (struct tuntap *tt, |
1155 | 1155 |
IFCONFIG_PATH, |
1156 | 1156 |
actual, |
1157 | 1157 |
ifconfig_local, |
1158 |
- ifconfig_local, |
|
1158 |
+ create_arbitrary_remote( tt, &gc ), |
|
1159 | 1159 |
tun_mtu, |
1160 | 1160 |
ifconfig_remote_netmask |
1161 | 1161 |
); |