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 calls IfaceMgr::pollSocketsPosix to allow easier use of different implementations without having to maintain duplicate code.
  • Adds a new method IfaceMgr::pollSocketsPosix. This method does what select() did before using poll() and will run on any POSIX-compatible system and is used for BSD and sun by calling it in the respective files using IfaceMgr::pollSockets.
  • Implements IfaceMgr::pollSockets using epoll() for linux systems. epoll() offers better performance over poll() on a large number of sockets.
  • Updates IfaceMgr::receive4(In)direct and IfaceMgr::receive6(In)Direkt to use IfaceMgr::pollSockets() instead of select()
  • 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 in IfaceMgr::pollSockets
  • Updates documentation / comments in,,,,, ha_service.h,, iface_mgr.h,, libdhcpsrv.dox to reflect the change of select() to pollSockets()
Edited by Merlin von Rössing

Merge request reports