veth does not link its RX queues to their NAPI instances, so queue-get
reports no napi-id for them. napi-get lists each NAPI instance, and its
thread PID when NAPI is threaded, but not the RX queue it polls.
Userspace cannot tell which NAPI thread to pin for a given queue, or
which NAPI to change with napi-set.
There is also no way to busy poll an AF_XDP socket bound to a veth
queue. xsk_bind() takes the socket's NAPI ID from the RX queue, and a
veth RX queue has none.
Patch 1 is a cleanup to ease review of patch 2. veth_enable_xdp_range()
adds the NAPI instances only to pass their napi_id to
xdp_rxq_info_reg(), which no longer uses it. Patch 1 moves
netif_napi_add() into veth_napi_enable_range(), before the loop that
enables the NAPI instances. It also drops the napi_already_on and
delete_napi arguments and two wrappers.
Patch 2 calls netif_queue_set_napi() in veth_napi_enable_range(), after
napi_enable(). In veth_napi_del_range(), it clears the link with NULL
before napi_disable().
Patch 3 adds RX queue NAPI link checks to veth.sh. The napi-ids of the
RX queues must be the IDs of the NAPI instances of the device. The
queues must be linked only while NAPI is enabled. The checks run with
GRO on and with XDP attached, and across RX channel changes and link
down/up.
Patch 4 uses netif_napi_add_config(). veth deletes the NAPI instance of
an RX queue when it no longer needs it. With a persistent NAPI config,
the queue keeps its NAPI ID and settings when veth adds the instance
again.
Patch 5 adds checks to veth.sh that each RX queue keeps its NAPI ID.
---
Changes in v3:
- Patch 1: add all NAPI instances before enabling any, as before the
series (Sashiko [1]).
- Patch 3: reword the commit message. No code change.
- New patch 4: use netif_napi_add_config() (Sashiko [2]).
- New patch 5: check that each RX queue keeps its NAPI ID.
- v2: https://lore.kernel.org/all/20261111015922.67745-1-tianyi@cloudflare.com/ (local)
[1] https://lore.kernel.org/all/179470883254.2199510.15270739408094114749@kernel.org/ (local)
[2] https://lore.kernel.org/all/179470883411.2199510.13825316417997386083@kernel.org/ (local)
Changes in v2:
- Rebase on net-next. Patch 3 no longer applied after commit
c1f04ea0aa0f ("selftests: net: check veth carrier after changing
channel counts"). The conflict is in context only. No code change.
- v1: https://lore.kernel.org/all/20261105143356.17062-1-tianyi@cloudflare.com/ (local)
Tianyi Gao (5):
veth: refactor NAPI enable paths
veth: link RX queues to their NAPI instances
selftests: net: veth: test RX queue NAPI links
veth: use persistent NAPI config
selftests: net: veth: test that RX queues keep their NAPI IDs
drivers/net/veth.c | 85 ++++++----------------
tools/testing/selftests/net/veth.sh | 108 +++++++++++++++++++++++++++-
2 files changed, 130 insertions(+), 63 deletions(-)
base-commit: 6964ff21c5d8b75649211a52dbfd92753e605649
--
2.56.0