X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Flinux%2Fdevice.c;h=0cfc546ee16557c037c3e5352cbe5eb7c12a4571;hb=886a6f61a1f4cc48a77b42d10f34f9126377d904;hp=6c828c01d84f1909ab15ae8093a7ab56c7f71e9e;hpb=798fa2f04c52b0639713f74b1195847bec40c16a;p=tinc diff --git a/src/linux/device.c b/src/linux/device.c index 6c828c01..0cfc546e 100644 --- a/src/linux/device.c +++ b/src/linux/device.c @@ -52,6 +52,7 @@ static uint64_t device_total_out = 0; bool setup_device(void) { struct ifreq ifr; + bool t1q = false; if(!get_config_string(lookup_config(config_tree, "Device"), &device)) device = xstrdup(DEFAULT_DEVICE); @@ -73,7 +74,7 @@ bool setup_device(void) { #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)); + memset(&ifr, 0, sizeof ifr); if(routing_mode == RMODE_ROUTER) { ifr.ifr_flags = IFF_TUN; device_type = DEVICE_TYPE_TUN; @@ -84,6 +85,12 @@ bool setup_device(void) { device_info = "Linux tun/tap device (tap mode)"; } +#ifdef IFF_ONE_QUEUE + /* Set IFF_ONE_QUEUE flag... */ + if(get_config_bool(lookup_config(config_tree, "IffOneQueue"), &t1q) && t1q) + ifr.ifr_flags |= IFF_ONE_QUEUE; +#endif + if(iface) strncpy(ifr.ifr_name, iface, IFNAMSIZ); @@ -121,41 +128,41 @@ void close_device(void) { } bool read_packet(vpn_packet_t *packet) { - int lenin; + int inlen; switch(device_type) { case DEVICE_TYPE_TUN: - lenin = read(device_fd, packet->data + 10, MTU - 10); + inlen = read(device_fd, packet->data + 10, MTU - 10); - if(lenin <= 0) { + if(inlen <= 0) { logger(LOG_ERR, "Error while reading from %s %s: %s", device_info, device, strerror(errno)); return false; } - packet->len = lenin + 10; + packet->len = inlen + 10; break; case DEVICE_TYPE_TAP: - lenin = read(device_fd, packet->data, MTU); + inlen = read(device_fd, packet->data, MTU); - if(lenin <= 0) { + if(inlen <= 0) { logger(LOG_ERR, "Error while reading from %s %s: %s", device_info, device, strerror(errno)); return false; } - packet->len = lenin; + packet->len = inlen; break; case DEVICE_TYPE_ETHERTAP: - lenin = read(device_fd, packet->data - 2, MTU + 2); + inlen = read(device_fd, packet->data - 2, MTU + 2); - if(lenin <= 0) { + if(inlen <= 0) { logger(LOG_ERR, "Error while reading from %s %s: %s", device_info, device, strerror(errno)); return false; } - packet->len = lenin - 2; + packet->len = inlen - 2; break; }