diff --git a/osdep/LinuxEthernetTap.cpp b/osdep/LinuxEthernetTap.cpp index a2a942dcc..f97f67c2d 100644 --- a/osdep/LinuxEthernetTap.cpp +++ b/osdep/LinuxEthernetTap.cpp @@ -207,12 +207,6 @@ LinuxEthernetTap::LinuxEthernetTap( printf("WARNING: ioctl() failed setting up Linux tap device (bring interface up)\n"); return; } - ifr.ifr_flags |= IFF_UP; - if (ioctl(sock,SIOCSIFFLAGS,(void *)&ifr) < 0) { - ::close(sock); - printf("WARNING: ioctl() failed setting up Linux tap device (bring interface up)\n"); - return; - } // Some kernel versions seem to require you to yield while the device comes up // before they will accept MTU and MAC. For others it doesn't matter, but is @@ -235,6 +229,13 @@ LinuxEthernetTap::LinuxEthernetTap( return; } + ifr.ifr_flags |= IFF_UP; + if (ioctl(sock,SIOCSIFFLAGS,(void *)&ifr) < 0) { + ::close(sock); + printf("WARNING: ioctl() failed setting up Linux tap device (bring interface up)\n"); + return; + } + fcntl(_fd,F_SETFL,O_NONBLOCK); ::close(sock);