linux/net/xdp
Paul Moses b88b826ec5 xsk: restore UMEM flags after failed pool assignment
xp_assign_dev() sets XDP_UMEM_SG_FLAG before checking whether the
device supports multibuffer zero-copy. If assignment fails, xsk_bind()
destroys the pool but retains the registered UMEM. A subsequent bind
without XDP_USE_SG inherits the stale flag.

The flag also changes RX buffer sizing after DMA mapping. On igc, a
failed SG bind followed by a non-SG retry with 4096-byte chunks and
1792 bytes of headroom passes admission with 2048 bytes, but programs
a 1024-byte RX buffer. On I225-V hardware, an ordinary 1514-byte frame
is truncated to 1024 bytes or 1008 with RX timestamps enabled.
Restoring the original flags eliminates the truncation in both cases.

Save the UMEM flags before assignment and restore them on failure.

Discovered during development of AF_XDP changes for igc.

Fixes: d609f3d228 ("xsk: add multi-buffer support for sockets sharing umem")
Cc: stable@vger.kernel.org
Signed-off-by: Paul Moses <p@1g4.org>
Acked-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Link: https://patch.msgid.link/20261021224705.2078753-1-p@1g4.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-10-26 17:04:04 -07:00
..
Kconfig treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
Makefile xsk: Introduce AF_XDP buffer allocation API 2020-05-21 17:31:26 -07:00
xdp_umem.c xsk: require at least 16 bytes of TX metadata 2026-08-03 16:43:53 -07:00
xdp_umem.h xsk: Fix umem cleanup bug at socket destruct 2020-11-20 15:52:39 +01:00
xsk_buff_pool.c xsk: restore UMEM flags after failed pool assignment 2026-10-26 17:04:04 -07:00
xsk_diag.c net: change sock.sk_ino and sock_i_ino() to u64 2026-03-06 14:31:26 +01:00
xsk_queue.c xsk: account ring allocations to memcg 2026-08-05 19:32:39 -07:00
xsk_queue.h xsk: reclaim invalid Tx descriptors in ZC batch path 2026-07-24 15:12:14 -07:00
xsk.c xsk: freeze deferred pool teardown without blocking unregister 2026-10-20 12:38:34 +02:00
xsk.h xsk: remove repeated defines 2026-03-16 19:28:21 -07:00
xskmap.c xsk: Use a 32-bit compare in xsk_map_gen_lookup 2026-09-17 10:56:16 -07:00