Fix combination of Mode = router and DeviceType = tap on Linux.
authorEtienne Dechamps <etienne@edechamps.fr>
Sat, 13 Jul 2013 22:34:42 +0000 (23:34 +0100)
committerGuus Sliepen <guus@tinc-vpn.org>
Sun, 14 Jul 2013 22:27:37 +0000 (00:27 +0200)
I believe I have found a bug in tinc on Linux when it is used with
Mode = router and DeviceType = tap. This combination is useful because
it allows global broadcast packets to be used in router mode. However,
when tinc receives a packet in this situation, it needs to make sure its
destination MAC address matches the address of the TAP adapter, which is
typically not the case since the sending node doesn't know the MAC
address of the recipient. Unfortunately, this is not the case on Linux,
which breaks connectivity.

src/linux/device.c

index f770f7f..71fedef 100644 (file)
@@ -94,6 +94,8 @@ static bool setup_device(void) {
                device_type = DEVICE_TYPE_TUN;
                device_info = "Linux tun/tap device (tun mode)";
        } else {
                device_type = DEVICE_TYPE_TUN;
                device_info = "Linux tun/tap device (tun mode)";
        } else {
+               if (routing_mode == RMODE_ROUTER)
+                       overwrite_mac = true;
                ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
                device_type = DEVICE_TYPE_TAP;
                device_info = "Linux tun/tap device (tap mode)";
                ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
                device_type = DEVICE_TYPE_TAP;
                device_info = "Linux tun/tap device (tap mode)";