HomeFreeBSD

iflib: don't pullup UDP payloads to the TCP header size

Description

iflib: don't pullup UDP payloads to the TCP header size

The IPv4 packet parsing logic in iflib is incredibly complex,
prematurely optimized, and believes all the world is TCP.
This causes it to pullup part of the UDP payload into
the packet header, causing unneeded memory copies.
This impacts a project I'm working on, and also impacts
nearly any kernel user of UDP, like NFS. Eg, NFS over UDP
will result in pullups for every datagram sent over an iflib NIC.

This patch:

  • adds parsing for UDP to iflib
  • attempts to pull up the correct header size, based on UDP or

TCP protocol type.

  • simplifies packet parsing in iflib by
    • no longer special casing having an ethernet header in a packet by

itself

  • no longer checking that we're trying to pullup something beyond the

end of the packet. Since we're no longer trying to pull up a
larger TCP header, attempting to pullup something larger than
the packet should no longer happen. If it does, the packet is
malformed and m_pullup will return an error when it runs out of
data in the mbuf chain

Reviewed by: erj, glebius, kbowling
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D51748

Details

Provenance
gallatinAuthored on Aug 7 2025, 2:48 PM
Reviewer
erj
Differential Revision
D51748: iflib: don't pullup UDP payloads to the TCP header size
Parents
rGa39277782140: libc: Fix style nits in flushlbuf regression test
Branches
Unknown
Tags
Unknown