From b8b1f6495921a4f8682b06570c7324a4371f096e Mon Sep 17 00:00:00 2001 From: Jonathon Fernyhough Date: Wed, 21 Apr 2021 20:45:17 +0100 Subject: [PATCH] Revert "Reorder Linux TAP link sequence" This reverts commit 9374e45449ffe5c377e4cb2a346129ec598eeea9. --- osdep/LinuxEthernetTap.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/osdep/LinuxEthernetTap.cpp b/osdep/LinuxEthernetTap.cpp index f97f67c2d..a2a942dcc 100644 --- a/osdep/LinuxEthernetTap.cpp +++ b/osdep/LinuxEthernetTap.cpp @@ -207,6 +207,12 @@ 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 @@ -229,13 +235,6 @@ 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);