Re: [PATCH net-next 03/15] net: Add memory providers that only feed XDP
From: Björn Töpel
Date: Wed Nov 25 2026 - 14:43:23 EST
netdev-bot+sashiko@xxxxxxxxxx writes:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue(s) to consider.
>
> Critical: 0 · High: 0 · Medium: 1 · Low: 0
>
> If you believe none of the issues are legitimate, please reply to each
> issue of Medium severity or higher and explain why the AI is wrong.
> If any of them are legitimate and you plan to respin, please let patchwork
> know by including "pw-bot: cr" as a separate line at the end of your reply
> (one such reply per series is enough).
>
> - [Medium] This patch adds MP_XDP_ONLY providers, which by design sit
> next to native XDP and AF_XDP.
>
> --
>
> net: Add memory providers that only feed XDP
>
> This patch lets a memory provider mark itself XDP-only with MP_XDP_ONLY.
> Such a provider needs no header split and does not block native XDP. A page
> pool takes it only when the driver sets PP_FLAG_ALLOW_XDP_ONLY_NETMEM. The
> XDP install, XDP propagate and ethtool rings checks move from
> dev_get_min_mp_channel_count() to the new dev_mp_blocks_xdp().
>
>> diff --git a/net/core/dev.c b/net/core/dev.c
>> index 4ca8a9f5a7a5c..8a1d5a284e53c 100644
>> --- a/net/core/dev.c
>> +++ b/net/core/dev.c
>
> [ ... ]
>
>> @@ -11146,6 +11146,23 @@ int dev_change_xdp_fd(struct net_device *dev, struct netlink_ext_ack *extack,
>> return err;
>> }
>>
>> +/* Native XDP runs next to XDP-only providers only, see %MP_XDP_ONLY */
>> +bool dev_mp_blocks_xdp(const struct net_device *dev)
>> +{
>> + const struct memory_provider_ops *ops;
>> + unsigned int i;
>> +
>> + netdev_assert_locked_ops_compat(dev);
>> +
>> + for (i = 0; i < dev->real_num_rx_queues; i++) {
>> + ops = dev->_rx[i].mp_params.mp_ops;
>> + if (ops && !(ops->flags & MP_XDP_ONLY))
>> + return true;
>> + }
>> +
>> + return false;
>> +}
>> +
>
> [Severity: Medium]
> Should the AF_XDP zero-copy setup paths use this helper too?
>
> Two callers still use dev_get_min_mp_channel_count(). It counts every
> provider by mp_priv, including XDP-only ones:
>
> net/xdp/xsk_buff_pool.c:xp_assign_dev() {
> ...
> if (dev_get_min_mp_channel_count(netdev)) {
> err = -EBUSY;
> goto err_unreg_pool;
> }
> ...
> err_unreg_pool:
> if (!force_zc)
> err = 0; /* fallback to copy mode */
> ...
> }
>
> drivers/net/netkit.c:netkit_xsk() {
> ...
> if (!create || !dev_get_min_mp_channel_count(phys))
> ret = phys->netdev_ops->ndo_bpf(phys, &xdp_lower);
> ...
> }
>
> Later in the series, xsk_sink_bind() installs an MP_XDP_ONLY provider
> (xsk_sink_ops) on q0. After that, a classic AF_XDP socket that binds q1 on
> the same device would see this:
>
> bind with XDP_ZEROCOPY fails with -EBUSY
> bind without a mode flag falls back to copy mode and does not report it
> XSK pool creation through a netkit leased queue returns -EBUSY
>
> The result also seems to depend on bind order. Suppose the classic
> zero-copy socket binds q1 first. The sink can then still be installed on
> q0, because __netif_mp_open_rxq() only checks the pool of its own queue:
>
> net/core/netdev_rx_queue.c:__netif_mp_open_rxq() {
> ...
> if (rxq->pool && !xdp_only) {
> ...
> }
>
> So the same end state (sink on q0, zero copy on q1) is accepted in one
> order and refused in the other. Is that intended?
No, that's not intended. The device-wide check in
xp_assign_dev()/netkit_xsk() predates this work, and a sink on another
queue does not stop native XDP. I'll switch both to dev_mp_blocks_xdp()
in the next version, so the bind order no longer mattters.