Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: maciej.fijalkowski@intel.com
Cc: netdev@vger.kernel.org, magnus.karlsson@intel.com,
	stfomichev@gmail.com, kuba@kernel.org, pabeni@redhat.com,
	tushar.vyavahare@intel.com, kerneljasonxing@gmail.com,
	bjorn@kernel.org
Subject: Re: [PATCH v5 net-next 09/13] selftests: xsk: prepare xskxceiver for endpoints on two hosts
Date: Mon, 23 Nov 2026 18:46:40 +0000	[thread overview]
Message-ID: <179545960018.3135.10988887966916268523@kernel.org> (raw)
In-Reply-To: <20261119164636.1071385-10-maciej.fijalkowski@intel.com>

Thank you for your contribution! Sashiko AI review found 5 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 4 · Low: 1

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] In SKB mode, the remote's driver-mode RX_SG flag still gates
  the multi-buffer cases, so the DUT can lose that coverage.
- [Medium] xsk_wait_link_up() (tools/testing/selftests/net/lib/xsk/xsk.c)
  is meant to wait out a NIC reset, but it stops on the first…
- [Medium] detect_mode_caps() (xskxceiver.c) now sets
  XSK_CAP_DRV|XSK_CAP_ZC from NETDEV_XDP_ACT_XSK_ZEROCOPY alone,…
- [Medium] The new MTU restore in cleanup_iface() (xskxceiver.c) runs
  right after the XDP detach.
- [Low] selftests: xsk: TX-only guard bypassed in xsk_attach_xdp_progs()

--

selftests: xsk: prepare xskxceiver for endpoints on two hosts

This commit adds --queue, --max-frags and --timeout options to xskxceiver.
It also adds a SKIP message on the control channel and a link-up wait after
READY, so a zero-copy endpoint on a DUT can run against an SKB-mode endpoint
on a remote host. Zero-copy support is now taken from
NETDEV_XDP_ACT_XSK_ZEROCOPY instead of a probe bind, cases default to a 1500
MTU, and cleanup_iface() restores the original MTU.

> diff --git a/tools/testing/selftests/net/lib/xsk/xsk.c b/tools/testing/selftests/net/lib/xsk/xsk.c
> index 54e6808e3fe46..6249a4955b64b 100644
> --- a/tools/testing/selftests/net/lib/xsk/xsk.c
> +++ b/tools/testing/selftests/net/lib/xsk/xsk.c
> @@ -828,3 +828,37 @@ int xsk_get_mac(const char *ifname, u8 mac[ETH_ALEN])

[ ... ]

> +int xsk_wait_link_up(const char *ifname, int timeout_ms)
> +{
> +	struct ethtool_value edata = { .cmd = ETHTOOL_GLINK };
> +	struct ifreq ifr = { .ifr_data = (void *)&edata };
> +	int err;
> +
> +	for (;;) {
> +		err = xsk_ifreq_ioctl(ifname, SIOCETHTOOL, &ifr);
> +		if (err == -EOPNOTSUPP)
> +			return 0;
> +		if (err || edata.data)
> +			return err;

[Severity: Medium]
Should transient ioctl errors be retried here the same way as a down link?
Any SIOCETHTOOL error other than -EOPNOTSUPP ends the wait right away.

__dev_ethtool() returns -ENODEV while the device is detached:

net/ethtool/ioctl.c:__dev_ethtool() {
    ...
	if (!netif_device_present(dev)) {
		rc = -ENODEV;
		goto out;
	}
    ...
}

An error from ethtool_ops->begin() ends the wait the same way.

Drivers detach the netdev during a reset. For example, ice_prepare_for_reset()
and idpf_detach_and_close() both call netif_device_detach(). The local device
may still be detached when sync_endpoints()->wait_link_up() runs. In that
case, wouldn't wait_link_up() print "Link on %s is not up", send
XSK_PEER_ABORT, and fail the case on both endpoints?

That looks like the reset this wait was added for. Could the loop sleep and
retry on such errors until timeout_ms runs out?

> +		if (timeout_ms <= 0)
> +			return -ETIMEDOUT;
> +		usleep(100 * 1000);
> +		timeout_ms -= 100;
> +	}
> +}

[ ... ]

> diff --git a/tools/testing/selftests/net/lib/xsk/xskxceiver.c b/tools/testing/selftests/net/lib/xsk/xskxceiver.c
> index ef03bf3bd37b1..cc7754f3a8224 100644
> --- a/tools/testing/selftests/net/lib/xsk/xskxceiver.c
> +++ b/tools/testing/selftests/net/lib/xsk/xskxceiver.c

[ ... ]

> @@ -403,12 +397,14 @@ static bool is_xdp_supported(int ifindex)
>  	return true;
>  }
>  
> +/* Probe only the mode that the endpoint runs in. */
>  static u32 detect_mode_caps(struct ifobject *ifobj)
>  {
> -	if (is_xdp_supported(ifobj->ifindex)) {
> +	if (opt_mode == TEST_MODE_ZC && ifobj_has_cap(ifobj, XSK_CAP_ZC_ADVERTISED)) {
> +		/* Trust the advertised flag; an XDP_ZEROCOPY bind never falls back to copy. */
> +		ifobj_set_cap(ifobj, XSK_CAP_DRV | XSK_CAP_ZC);
> +	} else if (opt_mode == TEST_MODE_DRV && is_xdp_supported(ifobj->ifindex)) {
>  		ifobj_set_cap(ifobj, XSK_CAP_DRV);
> -		if (ifobj_zc_avail(ifobj))
> -			ifobj_set_cap(ifobj, XSK_CAP_ZC);
>  	}

[Severity: Medium]
On devices where zero-copy support depends on configuration, does trusting
NETDEV_XDP_ACT_XSK_ZEROCOPY alone turn a SKIP into a FAIL?

virtio_net sets the flag unconditionally in virtnet_probe():

	dev->xdp_features = NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT |
		NETDEV_XDP_ACT_XSK_ZEROCOPY;

But virtnet_xsk_pool_enable() refuses the pool when the virtqueue has no DMA
device:

	dma_dev = virtqueue_dma_dev(rq->vq);
	if (!dma_dev)
		return -EINVAL;

That happens without VIRTIO_F_ACCESS_PLATFORM, e.g. a default QEMU
virtio-net-pci without iommu_platform=on. It also returns -ENOENT when the RX
queue has no page_pool (big-packets mode).

With the old ifobj_zc_avail() probe bind, such a device skipped every
zero-copy case. Now mode_supported() passes, but the XDP_ZEROCOPY bind fails
in each case, so the case is reported as FAIL.

The commit message says "a false advertisement still fails the case". The
static flag cannot tell whether a given device instance can do zero-copy,
though. Is failing every ZC case on such setups, for example virtio-net CI
VMs, the intended result?

> @@ -423,8 +419,10 @@ static bool mode_supported(enum test_mode mode, u32 caps)
>  	return caps & XSK_CAP_ZC;
>  }
>  
> -static void cleanup_iface(struct ifobject *ifobj)
> +static int cleanup_iface(struct ifobject *ifobj)
>  {
> +	int err = 0;
> +
>  	/* A peer shadow has a skeleton but no bound interface. */
>  	if (!ifobj_is_local(ifobj))
>  		goto unload;
> @@ -432,8 +430,16 @@ static void cleanup_iface(struct ifobject *ifobj)
>  	if (ifobj->xdp_prog)
>  		xsk_detach_xdp_program(ifobj->ifindex,
>  				       mode_to_xdp_flags(ifobj->mode));
> +	/* After the detach, as an attached program can cap the MTU. */
> +	if (ifobj->dev_mtu != ifobj->orig_mtu) {
> +		err = xsk_set_mtu(ifobj->ifindex, ifobj->orig_mtu);
> +		if (err)
> +			ksft_print_msg("Failed to restore MTU %d on %s\n",
> +				       ifobj->orig_mtu, ifobj->ifname);
> +	}

[Severity: Low]
Does POLL_TXQ_FULL still attach an XDP program on a TX-only endpoint
in SKB and DRV mode?

testapp_poll_txq_tmout() runs single-threaded on the TX ifobj:

testapp_poll_txq_tmout()
  testapp_validate_traffic_single_thread(test, test->ifobj_tx)
    __testapp_validate_traffic(test, test->ifobj_tx, NULL)
      xsk_attach_xdp_progs(test, test->ifobj_tx, NULL)

The TX ifobj therefore enters xsk_attach_xdp_progs() as ifobj_rx. On
the TX host that ifobj is local. xdp_prog_changed_rx() looks at
test->ifobj_rx, which is the shadow there and never has a program, so
it is true.

xsk_reattach_xdp() then attaches test->xdp_prog_rx and test->xskmap_rx
to the TX interface. Those come from the shadow's skeleton. The
function returns at the !ifobj_tx check, before it reaches the new
rx_on / TEST_MODE_ZC guard.

The commit message says an endpoint that only transmits attaches the
XDP program only in zero-copy mode. This case does not follow that
rule. In DRV mode it attaches a native program on the TX NIC, which is
the kind of change that can reset a NIC and that this patch otherwise
tries to avoid.

Should the TX-only check be based on rx_on of whichever ifobj is being
attached, so that it also covers the first branch? Or should the
single-threaded path pass its ifobj in the slot that matches its
role?

[Severity: Medium]
Can this restore race with the deferred release of the zero-copy pool?

Closing the XSK socket does not unbind the pool from the queue right away:

xsk_destruct()
  xp_put_pool()
    queue_work(system_freezable_wq, &pool->work)

xp_release_deferred()   (later, under rtnl)
  xp_clear_dev()
    ndo_bpf(XDP_SETUP_XSK_POOL, NULL)

Nothing makes this MTU request wait for that work. mlx5e_change_mtu() rejects
an MTU that does not fit a pool that is still bound:

	if (priv->xsk.refcnt &&
	    !mlx5e_xsk_validate_mtu(netdev, &priv->channels,
				    &new_params, priv->mdev)) {
		err = -EINVAL;

For example, take a DUT with an original MTU of 9000 that runs a default ZC
case at 1500 with 4096 byte chunks. If the restore to 9000 gets rtnl before
the pool teardown, it fails. The endpoint then reports FAIL for a case that
passed.

Under xsk.py the fallback ip link set mtu restores the MTU later. Run
standalone, xskxceiver leaves the NIC at the test MTU.

The series already retries ethtool -G in xsk.py's _set_ring() for the same
deferred release ("A driver can refuse that while an XSK socket that just
closed still holds a queue, as ice does until a work item releases the
buffer pool"). Should the MTU restore get a similar retry?

>  unload:
>  	xsk_unload_xdp_programs(ifobj);
> +	return err;
>  }

[ ... ]

> @@ -553,8 +563,17 @@ int main(int argc, char **argv)
>  
>  out:
>  	xsk_set_endpoint(NULL);
> -	cleanup_iface(ifobj_tx);
> -	cleanup_iface(ifobj_rx);
> +	err = cleanup_iface(ifobj_tx);
> +	err |= cleanup_iface(ifobj_rx);
> +	/* xsk.py trusts a passed or skipped endpoint to have undone the MTU. */
> +	if (err)
> +		ret = TEST_FAILURE;
> +	/* After the cleanup, which can still fail a case that ran. */
> +	if (test.test_func)
> +		report_pkt_test(&test, ret);
> +	/* The peer skips the case too, rather than fail on the closed connection. */
> +	if (ret == TEST_SKIP)
> +		xsk_peer_skip(peer, opt_timeout * 1000);

[Severity: Medium]
Can this SKIP pass on to the DUT a skip that comes only from the remote NIC's
native driver features?

In SKB mode, __testapp_validate_traffic() requires XSK_CAP_MBUF on both
ifobjs for every case with test->mtu > MAX_ETH_PKT_SIZE:

	mbuf_cap = test->mode == TEST_MODE_ZC ? XSK_CAP_MBUF_ZC :
						XSK_CAP_MBUF;
	...
		return TEST_SKIP;

detect_ifobj_caps() sets XSK_CAP_MBUF only from NETDEV_XDP_ACT_RX_SG. That
flag belongs to the native driver's feature set:

	if (query_opts.feature_flags & NETDEV_XDP_ACT_RX_SG)
		ifobj_set_cap(ifobj, XSK_CAP_MBUF);

An SKB-mode endpoint binds with XDP_COPY, and xp_assign_dev() returns early
for force_copy without looking at xdp_features. Generic XDP handles frags for
an xdp.frags program through
netif_skb_check_for_xdp()->skb_cow_data_for_xdp().

setup_peer() copies the remote's own caps into the shadow, so both checks
read the remote NIC's RX_SG bit.

If the remote NIC does not advertise RX_SG, the remote returns TEST_SKIP for
every multi-buffer case: SEND_RECEIVE_9K_PACKETS, the *_MULTI_BUFF cases,
TOO_MANY_FRAGS, UNALIGNED_*_9K/MB, and others. With this patch it then sends
XSK_PEER_SKIP. The ZC DUT's sync_endpoints() returns TEST_SKIP, and xsk.py
reports the case as skipped.

Doesn't that lose the DUT's multi-buffer zero-copy coverage just because of
the remote's native XDP flags? It also seems to go against "an endpoint
probes only the mode it runs in" in the commit message.

>  	xsk_peer_close(peer);
>  	pkt_stream_delete(test.tx_pkt_stream_default);
>  	pkt_stream_delete(test.rx_pkt_stream_default);

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119164636.1071385-1-maciej.fijalkowski%40intel.com

  reply	other threads:[~2026-11-23 18:46 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 16:46 [PATCH v5 net-next 00/13] selftests: net: adjust xskxceiver to drv-net Maciej Fijalkowski
2026-11-19 16:46 ` [PATCH v5 net-next 01/13] selftests: xsk: factor endpoint work out of pthread wrappers Maciej Fijalkowski
2026-11-19 16:46 ` [PATCH v5 net-next 02/13] selftests: xsk: size the TX UMEM in HW_SW_MAX_RING_SIZE Maciej Fijalkowski
2026-11-23 18:46   ` netdev-bot+sashiko
2026-11-19 16:46 ` [PATCH v5 net-next 03/13] selftests: xsk: drop the single-interface loopback mode Maciej Fijalkowski
2026-11-19 16:46 ` [PATCH v5 net-next 04/13] selftests: xsk: collect interface capabilities in struct xsk_caps Maciej Fijalkowski
2026-11-19 16:46 ` [PATCH v5 net-next 05/13] selftests: xsk: split xskxceiver main() into setup, run and cleanup Maciej Fijalkowski
2026-11-23 18:46   ` netdev-bot+sashiko
2026-11-19 16:46 ` [PATCH v5 net-next 06/13] selftests: xsk: run one test case per xskxceiver invocation Maciej Fijalkowski
2026-11-23 18:46   ` netdev-bot+sashiko
2026-11-19 16:46 ` [PATCH v5 net-next 07/13] selftests: xsk: run the RX and TX endpoints in separate processes Maciej Fijalkowski
2026-11-23 18:46   ` netdev-bot+sashiko
2026-11-19 16:46 ` [PATCH v5 net-next 08/13] selftests: xsk: send UDP over IPv4 or IPv6 between the interface MACs Maciej Fijalkowski
2026-11-23 18:46   ` netdev-bot+sashiko
2026-11-23 19:08   ` Björn Töpel
2026-11-19 16:46 ` [PATCH v5 net-next 09/13] selftests: xsk: prepare xskxceiver for endpoints on two hosts Maciej Fijalkowski
2026-11-23 18:46   ` netdev-bot+sashiko [this message]
2026-11-19 16:46 ` [PATCH v5 net-next 10/13] selftests: xsk: list the endpoint roles of the test cases Maciej Fijalkowski
2026-11-19 16:46 ` [PATCH v5 net-next 11/13] selftests: drv-net: decouple local link setup from netdevsim Maciej Fijalkowski
2026-11-19 16:46 ` [PATCH v5 net-next 12/13] selftests: drv-net: run the AF_XDP tests over veth or a NIC Maciej Fijalkowski
2026-11-23 18:46   ` netdev-bot+sashiko
2026-11-19 16:46 ` [PATCH v5 net-next 13/13] selftests: xsk: document generic and hardware endpoint runs Maciej Fijalkowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179545960018.3135.10988887966916268523@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=bjorn@kernel.org \
    --cc=kerneljasonxing@gmail.com \
    --cc=kuba@kernel.org \
    --cc=maciej.fijalkowski@intel.com \
    --cc=magnus.karlsson@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=stfomichev@gmail.com \
    --cc=tushar.vyavahare@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox