mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 12:03:44 +02:00
Try pipelining tap reads on Linux for a little more speed.
This commit is contained in:
parent
31d8758ad9
commit
dc806dd718
2 changed files with 22 additions and 22 deletions
|
@ -40,7 +40,7 @@ namespace ZeroTier {
|
|||
namespace {
|
||||
|
||||
// Returns true if packet appears valid; pos and proto will be set
|
||||
static bool _ipv6GetPayload(const uint8_t *frameData,unsigned int frameLen,unsigned int &pos,unsigned int &proto)
|
||||
static inline bool _ipv6GetPayload(const uint8_t *frameData,unsigned int frameLen,unsigned int &pos,unsigned int &proto)
|
||||
{
|
||||
if (frameLen < 40)
|
||||
return false;
|
||||
|
|
|
@ -173,9 +173,8 @@ LinuxEthernetTap::LinuxEthernetTap(
|
|||
|
||||
::ioctl(_fd,TUNSETPERSIST,0); // valgrind may generate a false alarm here
|
||||
_dev = ifr.ifr_name;
|
||||
|
||||
// Set close-on-exec so that devices cannot persist if we fork/exec for update
|
||||
::fcntl(_fd,F_SETFD,fcntl(_fd,F_GETFD) | FD_CLOEXEC);
|
||||
::fcntl(_fd,F_SETFL,O_NONBLOCK);
|
||||
|
||||
(void)::pipe(_shutdownSignalPipe);
|
||||
|
||||
|
@ -474,9 +473,9 @@ void LinuxEthernetTap::threadMain()
|
|||
break;
|
||||
|
||||
if (FD_ISSET(_fd,&readfds)) {
|
||||
for(int x=0;x<64;++x) {
|
||||
n = (int)::read(_fd,getBuf + r,sizeof(getBuf) - r);
|
||||
if (n < 0) {
|
||||
if ((errno != EINTR)&&(errno != ETIMEDOUT))
|
||||
break;
|
||||
} else {
|
||||
// Some tap drivers like to send the ethernet frame and the
|
||||
|
@ -500,6 +499,7 @@ void LinuxEthernetTap::threadMain()
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ZeroTier
|
||||
|
|
Loading…
Add table
Reference in a new issue