mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 20:13:44 +02:00
Reorder Linux TAP link sequence
This corrects the flow for bringing up a TAP device under Linux. Closes #1314
This commit is contained in:
parent
e8f7d5ef9e
commit
9374e45449
1 changed files with 7 additions and 6 deletions
|
@ -207,12 +207,6 @@ LinuxEthernetTap::LinuxEthernetTap(
|
||||||
printf("WARNING: ioctl() failed setting up Linux tap device (bring interface up)\n");
|
printf("WARNING: ioctl() failed setting up Linux tap device (bring interface up)\n");
|
||||||
return;
|
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
|
// 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
|
// before they will accept MTU and MAC. For others it doesn't matter, but is
|
||||||
|
@ -235,6 +229,13 @@ LinuxEthernetTap::LinuxEthernetTap(
|
||||||
return;
|
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);
|
fcntl(_fd,F_SETFL,O_NONBLOCK);
|
||||||
|
|
||||||
::close(sock);
|
::close(sock);
|
||||||
|
|
Loading…
Add table
Reference in a new issue