Skip to main content

run_poll

Function run_poll 

Source
pub fn run_poll<D: Dispatch>(
    udp_fd: RawFd,
    tun_fd: RawFd,
    vnet_hdr: bool,
    d: &mut D,
) -> Result<()>
Expand description

Run the epoll event loop until an I/O error is returned.

Both udp_fd and tun_fd are set non-blocking. An epoll instance watches both for EPOLLIN. epoll_wait uses a 10 ms timeout so that Dispatch::tick fires on cadence even when there is no network traffic.

The function returns when:

  • drain_udp or drain_tun returns a fatal I/O error, OR
  • flush_tx (via send_mmsg) returns a fatal I/O error (e.g. socket closed).

vnet_hdr must reflect whether tun_fd was actually opened with IFF_VNET_HDR + kernel GSO/GRO offload (TunTap::vnet_hdr_len().is_some() — see yip-device); passing true for a plain fd corrupts every TUN read/write with a bogus virtio_net_hdr prefix.