mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2024-12-24 07:06:39 +00:00
more fun with linux ethernet taps
older kernels: must set MTU before IFF_UP. newer kernels: must set MTU *after* IFF_UP
This commit is contained in:
parent
ed74ed6ed2
commit
31c12aebb5
@ -246,15 +246,20 @@ LinuxEthernetTap::LinuxEthernetTap(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ifr.ifr_ifru.ifru_mtu = (int)_mtu;
|
|
||||||
if (ioctl(sock,SIOCSIFMTU,(void *)&ifr) < 0) {
|
|
||||||
::close(sock);
|
|
||||||
printf("WARNING: ioctl() failed setting up Linux tap device (set MTU)\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
usleep(100000);
|
usleep(100000);
|
||||||
|
|
||||||
|
if (isOldLinuxKernel()) {
|
||||||
|
ifr.ifr_ifru.ifru_mtu = (int)_mtu;
|
||||||
|
if (ioctl(sock,SIOCSIFMTU,(void *)&ifr) < 0) {
|
||||||
|
::close(sock);
|
||||||
|
printf("WARNING: ioctl() failed setting up Linux tap device (set MTU)\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
usleep(100000);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ifr.ifr_flags |= IFF_MULTICAST;
|
ifr.ifr_flags |= IFF_MULTICAST;
|
||||||
ifr.ifr_flags |= IFF_UP;
|
ifr.ifr_flags |= IFF_UP;
|
||||||
if (ioctl(sock,SIOCSIFFLAGS,(void *)&ifr) < 0) {
|
if (ioctl(sock,SIOCSIFFLAGS,(void *)&ifr) < 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user