]> tinc-vpn.org Git - tinc/commitdiff
Drop support for Linux Ethertap devices
authorGuus Sliepen <guus@tinc-vpn.org>
Sat, 8 Nov 2025 23:21:48 +0000 (00:21 +0100)
committerGuus Sliepen <guus@tinc-vpn.org>
Sat, 8 Nov 2025 23:35:21 +0000 (00:35 +0100)
The compiler didn't like the code handling Ethertap devices, and since
the TUN/TAP driver has superseded it in 1999, it can just be removed.

doc/PROTOCOL
doc/sample-config/tinc.conf
doc/tinc.texi
doc/tincd.8.in
src/linux/device.c

index 3ac958497f3aef9551f0f99c97e537f9464d5ae8..edf3906557a89ce7915e58b52a949e290dc252df 100644 (file)
@@ -21,8 +21,7 @@ makes TCP connections to other tinc daemons.  It uses the "meta
 protocol" for these connections.  To exchange packets on the virtual
 network, UDP connections are made and the "packet protocol" is used.
 Tinc also needs to exchange network packets with the kernel.  This is
-done using the ethertap device or the universal TUN/TAP device that
-can be found in various UNIX flavours.
+done using the TUN/TAP device that can be found in various UNIX flavours.
 
 2.  Packet protocol
 ------------------
index 70817644b15ae9a44d07688913c2c9647b967256..59f8bc8ce15dfe164bdc7d1dc11fd256ecc878e3 100644 (file)
@@ -16,7 +16,7 @@ Name = alpha
 ConnectTo = beta
 
 # The tap device tinc will use.
-# /dev/tap0 for ethertap, FreeBSD or OpenBSD
+# /dev/tap0 for FreeBSD or OpenBSD
 # /dev/tun0 for Solaris
 # /dev/net/tun for Linux tun/tap
 Device = /dev/net/tun
index 0420e6f6fe22f09509a27dfa37c8442717007a16..4e2ba51607b327658617b8c8e745d68fcc2060b9 100644 (file)
@@ -1878,13 +1878,6 @@ What follows is a list of the most common error messages you might find in the l
 Some of them will only be visible if the debug level is high enough.
 
 @table @samp
-@item Could not open /dev/tap0: No such device
-
-@itemize
-@item You forgot to `modprobe netlink_dev' or `modprobe ethertap'.
-@item You forgot to compile `Netlink device emulation' in the kernel.
-@end itemize
-
 @item Can't write to /dev/net/tun: No such device
 
 @itemize
index bdccf9d7a14ed321eae7fa97a0f0af255e81b37f..2e5c08bebe2f4a8b882aabb839b575738996cafa 100644 (file)
@@ -30,7 +30,7 @@ When started,
 .Nm
 will read it's configuration file to determine what virtual subnets it has to serve
 and to what other tinc daemons it should connect.
-It will connect to the ethertap or tun/tap device
+It will connect to the tun/tap device
 and set up a socket for incoming connections.
 Optionally a script will be executed to further configure the virtual device.
 If that succeeds,
index 38debe842d1d4fae3ba34609052be8af9ace44a4..97f8329ecf399fe7c9e98a01f160853400df0a60 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    device.c -- Interaction with Linux ethertap and tun/tap device
+    device.c -- Interaction with Linux tun/tap device
     Copyright (C) 2001-2005 Ivo Timmermans,
                   2001-2014 Guus Sliepen <guus@tinc-vpn.org>
 
 
 #include "../system.h"
 
-#ifdef HAVE_LINUX_IF_TUN_H
 #include <linux/if_tun.h>
 #define DEFAULT_DEVICE "/dev/net/tun"
-#else
-#define DEFAULT_DEVICE "/dev/tap0"
-#endif
 
 #include "../conf.h"
 #include "../device.h"
@@ -36,7 +32,6 @@
 #include "../xalloc.h"
 
 typedef enum device_type_t {
-       DEVICE_TYPE_ETHERTAP,
        DEVICE_TYPE_TUN,
        DEVICE_TYPE_TAP,
 } device_type_t;
@@ -61,14 +56,10 @@ static bool setup_device(void) {
        }
 
        if(!get_config_string(lookup_config(config_tree, "Interface"), &iface))
-#ifdef HAVE_LINUX_IF_TUN_H
                if(netname != NULL) {
                        iface = xstrdup(netname);
                }
 
-#else
-               iface = xstrdup(strrchr(device, '/') ? strrchr(device, '/') + 1 : device);
-#endif
        device_fd = open(device, O_RDWR | O_NONBLOCK);
 
        if(device_fd < 0) {
@@ -80,9 +71,6 @@ static bool setup_device(void) {
        fcntl(device_fd, F_SETFD, FD_CLOEXEC);
 #endif
 
-#ifdef HAVE_LINUX_IF_TUN_H
-       /* Ok now check if this is an old ethertap or a new tun/tap thingie */
-
        memset(&ifr, 0, sizeof(ifr));
 
        get_config_string(lookup_config(config_tree, "DeviceType"), &type);
@@ -134,17 +122,9 @@ static bool setup_device(void) {
                ifrname[IFNAMSIZ - 1] = 0;
                free(iface);
                iface = xstrdup(ifrname);
-       } else
-#endif
-       {
-               if(routing_mode == RMODE_ROUTER) {
-                       overwrite_mac = true;
-               }
-
-               device_info = "Linux ethertap device";
-               device_type = DEVICE_TYPE_ETHERTAP;
-               free(iface);
-               iface = xstrdup(strrchr(device, '/') ? strrchr(device, '/') + 1 : device);
+       } else {
+               logger(LOG_ERR, "%s is not a TUN/TAP device", device);
+               return false;
        }
 
        if(overwrite_mac && !ioctl(device_fd, SIOCGIFHWADDR, &ifr)) {
@@ -192,18 +172,6 @@ static bool read_packet(vpn_packet_t *packet) {
 
                packet->len = lenin;
                break;
-
-       case DEVICE_TYPE_ETHERTAP:
-               lenin = read(device_fd, packet->data - 2, MTU + 2);
-
-               if(lenin <= 0) {
-                       logger(LOG_ERR, "Error while reading from %s %s: %s",
-                              device_info, device, strerror(errno));
-                       return false;
-               }
-
-               packet->len = lenin - 2;
-               break;
        }
 
        device_total_in += packet->len;
@@ -237,17 +205,6 @@ static bool write_packet(vpn_packet_t *packet) {
                        return false;
                }
 
-               break;
-
-       case DEVICE_TYPE_ETHERTAP:
-               memcpy(packet->data - 2, &packet->len, 2);
-
-               if(write(device_fd, packet->data - 2, packet->len + 2) < 0) {
-                       logger(LOG_ERR, "Can't write to %s %s: %s", device_info, device,
-                              strerror(errno));
-                       return false;
-               }
-
                break;
        }