resolve buffer overflow with more than 500 interfaces
Closes #2570
This MR replaces the select()
calls in IfaceMgr with (e)poll()
. This will remove the buffer overflow caused by the size limit of FD_SETSIZE
when more than 1024 descriptors are open in the IfaceMgr. epoll()
also provides better performance on large numbers of sockets, but is only available on linux. For other systems, poll()
is used.
- Adds a new method
IfaceMgr::pollSockets
. This method is contains OS-specific polling implementations or callsIfaceMgr::pollSocketsPosix
to allow easier use of different implementations without having to maintain duplicate code. - Adds a new method
IfaceMgr::pollSocketsPosix
. This method does whatselect()
did before usingpoll()
and will run on any POSIX-compatible system and is used for BSD and sun by calling it in the respective files usingIfaceMgr::pollSockets
. - Implements
IfaceMgr::pollSockets
usingepoll()
for linux systems.epoll()
offers better performance overpoll()
on a large number of sockets. - Updates
IfaceMgr::receive4(In)direct
andIfaceMgr::receive6(In)Direkt
to useIfaceMgr::pollSockets()
instead ofselect()
- Updates
IfaceMgr::receive4
,IfaceMgr::receive6
,IfaceMgr::receive4(In)direct
,IfaceMgr::receive6(In)Direct
,Dhcpv6Srv::receivePacket
,Dhcpv4Srv::receivePacket
,PerfSocket::receive4
,PerfSocket::receive6
,Receiver::readPktFromSocket
to use millisecond timeout values instead of the old second + microseconds.poll()
and its variants use millisecond timeouts. None of the previous values used microsecond precision, so there should be no problem with this. - Updates
iface_mgr_unittest
,dhcp6to4_ipc_unittest
,dhcp4to6_ipc_unittest
,d2_unittest
,d2_udp_unittest
to also use millisecond values instead of seconds + micros - Adds a test for
IfaceMgr::pollSockets
- Adds a linux-only test
pollSocketsDetectBadDescriptors
for an epoll-specific behavior inIfaceMgr::pollSockets
- Updates documentation / comments in
command_mgr.cc
,dhcp4_process_tests.sh.in
,dhcp4_srv.cc
,dhcp6_process_tests.sh.in
,dhcp6_srv.cc
,ha_service.h
,ha_service.cc
,iface_mgr.h
,iface_mgr.cc
,libdhcpsrv.dox
to reflect the change ofselect()
topollSockets()
Edited by Merlin von Rössing