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
(cherry picked from commit 60fd44e501f2002459a49c6c9bc64370ea26ca87)
... | ... |
@@ -623,6 +623,28 @@ void delete_route_connected_v6_net(struct tuntap * tt, |
623 | 623 |
} |
624 | 624 |
#endif |
625 | 625 |
|
626 |
+#if defined(TARGET_FREEBSD)||defined(TARGET_DRAGONFLY) |
|
627 |
+/* we can't use true subnet mode on tun on all platforms, as that |
|
628 |
+ * conflicts with IPv6 (wants to use ND then, which we don't do), |
|
629 |
+ * but the OSes want "a remote address that is different from ours" |
|
630 |
+ * - so we construct one, normally the first in the subnet, but if |
|
631 |
+ * this is the same as ours, use the second one. |
|
632 |
+ * The actual address does not matter at all, as the tun interface |
|
633 |
+ * is still point to point and no layer 2 resolution is done... |
|
634 |
+ */ |
|
635 |
+ |
|
636 |
+char * |
|
637 |
+create_arbitrary_remote( struct tuntap *tt, struct gc_arena * gc ) |
|
638 |
+{ |
|
639 |
+ in_addr_t remote; |
|
640 |
+ |
|
641 |
+ remote = (tt->local & tt->remote_netmask) +1; |
|
642 |
+ |
|
643 |
+ if ( remote == tt->local ) remote ++; |
|
644 |
+ |
|
645 |
+ return print_in_addr_t (remote, 0, &gc); |
|
646 |
+} |
|
647 |
+#endif |
|
626 | 648 |
|
627 | 649 |
/* execute the ifconfig command through the shell */ |
628 | 650 |
void |
... | ... |
@@ -1119,7 +1141,7 @@ do_ifconfig (struct tuntap *tt, |
1119 | 1119 |
IFCONFIG_PATH, |
1120 | 1120 |
actual, |
1121 | 1121 |
ifconfig_local, |
1122 |
- ifconfig_local, |
|
1122 |
+ create_arbitrary_remote( tt, &gc ), |
|
1123 | 1123 |
tun_mtu, |
1124 | 1124 |
ifconfig_remote_netmask |
1125 | 1125 |
); |