Adding a new member to m_pkthdr

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Fri, 27 May 2022 20:17:29 UTC
For NIC offload of kernel TLS on the receive side, the kernel needs to know
the "leaf" interface that packets arrive on up in the socket buffer layer
when appending received packet data to a socket using KTLS.  rcvif does not
fully work since connections that transit a virtual interface like if_vlan or
if_lagg rewrite m_rcvif to be the virtual interface.  For KTLS transmit we
are able to follow the transmit path down to configure KTLS on the leaf
interface.  However, while the receive path is usually a mirror of the
transmit path, it is not always.  In particular, when using a lagg(4) with
LACP, the other end of the lagg is free to use whatever hash it chooses to
distribute traffic across the lagg ports such that the receive and transmit
sides of a connection may transit different ports within a lagg.

To provide a leaf interface, I have a patch that adds a new field to m_pkthdr
to track the leaf receive interface.  It is optional and the only use
currently anticipated is KTLS.  In the current KTLS patches it is set
on received packets by the mlx5 driver.  Possibly it could be set more
generically in ether_input instead of in individual drivers.  It is
serialized to an index and generation count while packets are deferred to
a netisr similar to rcvif except that it is non-fatal if the ifp cannot
be re-materialized when the mbuf is dequeued.  Instead, the pointer is
simply left as NULL.

However, using more space in m_pkthdr is a non-trivial thing, so it's worth
raising the conversation more broadly.  The change to add this field is in
https://reviews.freebsd.org/D35339.  Drew has tested this isolated change
under load at Netflix and found no impact on performance.

-- 
John Baldwin