From: Guus Sliepen Date: Sat, 8 Nov 2025 23:21:48 +0000 (+0100) Subject: Drop support for Linux Ethertap devices X-Git-Url: https://www.tinc-vpn.org/git/?a=commitdiff_plain;h=8026259ca027f56ad4ec89b3570887089d224285;p=tinc Drop support for Linux Ethertap devices 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. --- diff --git a/doc/PROTOCOL b/doc/PROTOCOL index 3ac95849..edf39065 100644 --- a/doc/PROTOCOL +++ b/doc/PROTOCOL @@ -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 ------------------ diff --git a/doc/sample-config/tinc.conf b/doc/sample-config/tinc.conf index 70817644..59f8bc8c 100644 --- a/doc/sample-config/tinc.conf +++ b/doc/sample-config/tinc.conf @@ -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 diff --git a/doc/tinc.texi b/doc/tinc.texi index 0420e6f6..4e2ba516 100644 --- a/doc/tinc.texi +++ b/doc/tinc.texi @@ -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 diff --git a/doc/tincd.8.in b/doc/tincd.8.in index bdccf9d7..2e5c08be 100644 --- a/doc/tincd.8.in +++ b/doc/tincd.8.in @@ -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, diff --git a/src/linux/device.c b/src/linux/device.c index 38debe84..97f8329e 100644 --- a/src/linux/device.c +++ b/src/linux/device.c @@ -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 @@ -20,12 +20,8 @@ #include "../system.h" -#ifdef HAVE_LINUX_IF_TUN_H #include #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; }