On Thu,  3 Dec 2026 08:42:03 -0800
Scott Mitchell <[email protected]> wrote:

> Fixes for af_packet ring handling, then Tx features: non-blocking Tx
> and software checksum offload.
> 
> Patches 1-3 are fixes for stable, and 4 tests them. 5-8 are not for
> stable.
> 
> v9:
> * tp_status helpers cast to (uint32_t __rte_atomic *). (Stephen)
> * The invalid ring parameter error prints blocksz, framesz and framecnt
>   instead of describing the constraints; af_packet.rst documents them,
>   including the 2GB blocksz limit. (Stephen)


AI re-review found some things still left.

Review: [PATCH v9 0/8] net/af_packet fixes and Tx features

Applied to main (27.03-rc0, ddb3b0c) with git am. Every commit builds
with -Dwerror=true (net/af_packet + app/test). Tests not run (need
root and a TAP device).

Summary
-------
The fixes are right: acquire/release on tp_status, the
packet_lookup_frame() layout, and the 66 byte Rx offset all match
the kernel.

One real bug: the larger Rx overhead from 3/8 makes small frame
sizes underflow, and 5/8 still accepts them and documents 64 as
valid. One wrong Fixes tag.


Patch 3/8: net/af_packet: fix maximum Rx packet length
------------------------------------------------------
Error:

* ETH_AF_PACKET_RX_FRAME_OVERHEAD is 66, but probe accepts any
  framesz >= TPACKET2_HDRLEN (52). With framesz=64 or 80:

        max_rx_pktlen = 64 - 66            -> 0xfffffffe (size_t wrap)
        max_mtu       = 0xfffffffe - 18    -> 65516 (uint16_t)

  so ethdev lets the application set MTU 65516 and the driver passes
  it to SIOCSIFMTU. eth_rx_queue_setup() computes the same wrapped
  data_size, so with scatter enabled the queue is accepted. Checked
  with the real macros: framesz=64 gives max_rx_pktlen 4294967294,
  max_mtu 65516.

  Before this patch the overhead was 32 and 64 did not wrap. Reject
  frames that cannot hold a minimum Ethernet frame on Rx, in this
  patch (5/8 can then fold it into its condition):

        if (framesize < ETH_AF_PACKET_RX_FRAME_OVERHEAD + RTE_ETHER_MIN_LEN) {
                PMD_LOG(ERR, "%s: framesz %u below minimum %zu", name,
                        framesize,
                        ETH_AF_PACKET_RX_FRAME_OVERHEAD + RTE_ETHER_MIN_LEN);
                return -1;
        }

  That makes the minimum 144 after 16 byte alignment. Fix the
  "at least 64B" in af_packet.rst (5/8) to match, and add framesz=64
  to the bad[] table in test_af_packet_invalid_frame_config().

Warning:

* Fixes tag is wrong. The original driver set
  max_rx_pktlen = ETH_FRAME_LEN; the frame-size based
  max_rx_pktlen/max_mtu came from 220a5c7b75 (v26.03), and the
  Rx queue setup check from b5a8868bde. Use:

        Fixes: b5a8868bde2f ("net/af_packet: guard against buffer overruns in 
Rx path")
        Fixes: 220a5c7b75c9 ("net/af_packet: support jumbo frames")

  Cc stable still applies for the Rx setup part, which is in 25.11.


Patch 6/8: net/af_packet: clean up Tx and bulk free mbufs
---------------------------------------------------------
Info:

* The commit message does not mention the two tests it adds
  (tx_vlan_oversize, tx_mbuf_accounting). One line will do.

* Pre-existing, but it matters more now that 8/8 makes a point of
  not writing the mbuf: rte_vlan_insert() modifies the
  application's mbuf, needs headroom, and fails with -EINVAL on
  clones and shared mbufs, which are then dropped. Every packet is
  already copied into the ring frame, so the tag can be inserted
  during the copy instead: copy 12 bytes of MACs, write TPID and
  TCI, copy the rest, add 4 to tp_len and the offsets used by the
  checksum code. Fine as a follow-up.

Reply via email to