mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-01-29 15:43:52 +00:00
Add bigness to buffers to prevent overflow on high traffic (Mac tap).
This commit is contained in:
parent
92c811deb7
commit
d77846dcea
@ -350,10 +350,14 @@ void MacEthernetTap::setMtu(unsigned int mtu)
|
||||
_mtu = mtu;
|
||||
}
|
||||
|
||||
#define ZT_MACETHERNETTAP_AGENT_READ_BUF_SIZE 1048576
|
||||
|
||||
void MacEthernetTap::threadMain()
|
||||
throw()
|
||||
{
|
||||
char agentReadBuf[262144];
|
||||
char *const agentReadBuf = (char *)valloc(ZT_MACETHERNETTAP_AGENT_READ_BUF_SIZE);
|
||||
if (!agentReadBuf)
|
||||
return;
|
||||
fd_set readfds,nullfds;
|
||||
MAC to,from;
|
||||
|
||||
@ -375,7 +379,7 @@ void MacEthernetTap::threadMain()
|
||||
break;
|
||||
}
|
||||
if (FD_ISSET(_agentStdout,&readfds)) {
|
||||
long n = (long)read(_agentStdout,agentReadBuf + agentReadPtr,sizeof(agentReadBuf) - agentReadPtr);
|
||||
long n = (long)read(_agentStdout,agentReadBuf + agentReadPtr,ZT_MACETHERNETTAP_AGENT_READ_BUF_SIZE - agentReadPtr);
|
||||
if (n > 0) {
|
||||
agentReadPtr += n;
|
||||
while (agentReadPtr >= 2) {
|
||||
@ -401,9 +405,11 @@ void MacEthernetTap::threadMain()
|
||||
}
|
||||
}
|
||||
if (FD_ISSET(_agentStderr,&readfds)) {
|
||||
read(_agentStderr,agentReadBuf,sizeof(agentReadBuf));
|
||||
read(_agentStderr,agentReadBuf,ZT_MACETHERNETTAP_AGENT_READ_BUF_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
free(agentReadBuf);
|
||||
}
|
||||
|
||||
} // namespace ZeroTier
|
||||
|
@ -104,8 +104,8 @@
|
||||
|
||||
#define P_IFCONFIG "/sbin/ifconfig"
|
||||
|
||||
static unsigned char s_pktReadBuf[262144] __attribute__ ((__aligned__(16)));
|
||||
static unsigned char s_stdinReadBuf[262144] __attribute__ ((__aligned__(16)));
|
||||
static unsigned char s_pktReadBuf[1048576] __attribute__ ((__aligned__(16)));
|
||||
static unsigned char s_stdinReadBuf[1048576] __attribute__ ((__aligned__(16)));
|
||||
static char s_deviceName[IFNAMSIZ];
|
||||
static char s_peerDeviceName[IFNAMSIZ];
|
||||
static int s_bpffd = -1;
|
||||
@ -418,6 +418,10 @@ int main(int argc,char **argv)
|
||||
|
||||
case ZT_MACETHERNETTAPAGENT_STDIN_CMD_EXIT:
|
||||
return ZT_MACETHERNETTAPAGENT_EXIT_CODE_SUCCESS;
|
||||
|
||||
default:
|
||||
fprintf(stderr,"E unrecognized message type over pipe from host process: %d (length: %d)\n",(int)msg[0],(int)len);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user