From a7e906d2d6b15dd9e6c471a720bbbc39bd9da9a7 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Wed, 11 Oct 2017 20:02:22 +0200 Subject: [PATCH] Handle tun/tap device returning EPERM or EBUSY. Often when tun/tap is used any errors during setup will be confuse tinc and it will then assume it is an Ethertap device. Try to avoid this by checking errno after a failed TUNSETIFF; if it's EPERM or EBUSY then we can be sure it was not an Ethertap device, and we should report an error instead. Closes #157 on GitHub. --- src/linux/device.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/linux/device.c b/src/linux/device.c index f75f4bdb..990de6a8 100644 --- a/src/linux/device.c +++ b/src/linux/device.c @@ -125,6 +125,9 @@ static bool setup_device(void) { ifrname[IFNAMSIZ - 1] = 0; free(iface); iface = xstrdup(ifrname); + } else if(errno == EPERM || errno == EBUSY) { + logger(LOG_ERR, "Error while trying to configure %s: %s", device, strerror(errno)); + return false; } else if(!ioctl(device_fd, (('T' << 8) | 202), &ifr)) { logger(LOG_WARNING, "Old ioctl() request was needed for %s", device); strncpy(ifrname, ifr.ifr_name, IFNAMSIZ); -- 2.20.1