> xdp: warn on XDP_PASS with stored values when XDP runs on an skb
TL;DR: Comment nit in xdp_skb_ext_warn_pass(): the new
generic-XDP/BPF_PROG_RUN comment is inaccurate for BPF_F_TEST_XDP_LIVE_FRAMES,
which uses a separate rxq, and the next comment is now stale. Not a bug.
> diff --git a/net/core/xdp.c b/net/core/xdp.c
> --- a/net/core/xdp.c
> +++ b/net/core/xdp.c
[ ... ]
> @@ -1124,12 +1125,17 @@ void xdp_skb_ext_to_skb(struct sk_buff *skb, const
> struct xdp_skb_ext *ext)
> void xdp_skb_ext_warn_pass(const struct bpf_prog *prog,
> const struct xdp_buff *xdp)
> {
> - const struct net_device *dev = xdp->rxq->dev;
> + const struct xdp_rxq_info *rxq = xdp->rxq;
> + const struct net_device *dev = rxq->dev;
>
> /* The skb is built later from the xdp_frame */
> if (prog->expected_attach_type == BPF_XDP_CPUMAP ||
> prog->expected_attach_type == BPF_XDP_DEVMAP)
> return;
> + /* Generic XDP and BPF_PROG_RUN use the netdev_rx_queue xdp_rxq */
> + if (rxq->queue_index < dev->num_rx_queues &&
> + rxq == &dev->_rx[rxq->queue_index].xdp_rxq)
> + return;
> /* No native XDP, so only generic XDP or BPF_PROG_RUN runs on dev */
> if (!(dev->xdp_features & NETDEV_XDP_ACT_BASIC))
> return;
This isn't a bug, but is the new comment accurate for BPF_PROG_RUN?
With BPF_F_TEST_XDP_LIVE_FRAMES, xdp_test_run_setup() registers a separate
rxq embedded in struct xdp_test_data:
xdp_rxq_info_reg(&xdp->rxq, orig_ctx->rxq->dev, 0, 0)
and xdp_test_run_init_page() then does:
xdp_init_buff(new_ctx, TEST_XDP_FRAME_SIZE, &xdp->rxq);
so in live-frames mode rxq != &dev->_rx[rxq->queue_index].xdp_rxq and the
early return is not taken.
That also makes the following comment stale: generic XDP and non-live
BPF_PROG_RUN now return at the new check, so only the live-frames
BPF_PROG_RUN can reach the NETDEV_XDP_ACT_BASIC test.
Would something like "Generic XDP and BPF_PROG_RUN without
BPF_F_TEST_XDP_LIVE_FRAMES use the netdev_rx_queue xdp_rxq" match the code
better?
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/42755842687