BPF List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: maciej.fijalkowski@intel.com
Cc: netdev@vger.kernel.org, bpf@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 v3 net-next 08/15] selftests: xsk: split xskxceiver main() into setup, run and cleanup
Date: Sat, 17 Oct 2026 03:06:07 +0000	[thread overview]
Message-ID: <179220636731.434549.8598674043519949556@kernel.org> (raw)
In-Reply-To: <20261014184539.774708-9-maciej.fijalkowski@intel.com>

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] Besides restructuring main(), the patch fixes an existing false-
  pass bug in xskxceiver's exit status, but it carries no Fixes: tag and…

Pre-existing issues:
- [Low] cleanup_iface() detaches an XDP program only when
  `ifobj->xdp_prog` is set, and it picks the detach flags from…

--

selftests: xsk: split xskxceiver main() into setup, run and cleanup

This commit splits xskxceiver main() into three parts. Setup is done by
bind_iface() and detect_mode_caps(), the test loop counts the return
value of run_pkt_test(), and cleanup_iface() gives a single exit path.
It also makes hw_ring_size_reset() skip no-op resets and calls
ksft_print_header() right after the command line is parsed.

> diff --git a/tools/testing/selftests/net/lib/xsk/xskxceiver.c b/tools/testing/selftests/net/lib/xsk/xskxceiver.c
> index 8b3e4d18e982b..02e54b026806b 100644
> --- a/tools/testing/selftests/net/lib/xsk/xskxceiver.c
> +++ b/tools/testing/selftests/net/lib/xsk/xskxceiver.c

[ ... ]

> @@ -317,26 +332,46 @@ static bool is_xdp_supported(int ifindex)

[ ... ]

> +static void cleanup_iface(struct ifobject *ifobj)
> +{
> +	if (ifobj_has_cap(ifobj, XSK_CAP_HW_RING))
> +		hw_ring_size_reset(ifobj);
> +	if (ifobj->xdp_prog)
> +		xsk_detach_xdp_program(ifobj->ifindex,
> +				       ifobj->mode == TEST_MODE_SKB ?
> +				       XDP_FLAGS_SKB_MODE : XDP_FLAGS_DRV_MODE);
> +	xsk_unload_xdp_programs(ifobj);
>  }

[Severity: Low]
This is a pre-existing issue and was not introduced by this patch. Can a
native XDP program still be left attached after xskxceiver exits?

cleanup_iface() depends on ifobj->xdp_prog and ifobj->mode. In test_xsk.c,
xsk_reattach_xdp() only updates them at the very end:

tools/testing/selftests/net/lib/xsk/test_xsk.c:xsk_reattach_xdp() {
    ...
	err = xsk_attach_xdp_program(xdp_prog, ifobj->ifindex, mode_to_xdp_flags(mode));
	...
	if (ifobj->mode != mode && (mode == TEST_MODE_DRV || mode == TEST_MODE_ZC))
		if (!xsk_is_in_mode(ifobj->ifindex, XDP_FLAGS_DRV_MODE)) {
			ksft_print_msg("ERROR: XDP prog not in DRV mode\n");
			return -EINVAL;
		}

	ifobj->xdp_prog = xdp_prog;
	ifobj->xskmap = xskmap;
	ifobj->mode = mode;
    ...
}

xsk_is_in_mode() returns false whenever bpf_xdp_query() fails, even if
the native attach just succeeded. If this happens on the last attach of
a run, the new program is attached but never recorded.

cleanup_iface() then either skips the detach because xdp_prog is still
NULL, or detaches with the stale SKB mode flags.

Before this patch, main() did not detach anything at exit, so this patch
makes the window smaller rather than opening it. The code is unchanged at
the end of the series. The runners clean up there: xsk.py detaches the
programs after a failed endpoint, and test_xsk.py uses a fresh veth pair
per case.

Could xsk_reattach_xdp() detach the program, or record it, before it
returns -EINVAL?

> @@ -371,95 +410,62 @@ int main(int argc, char **argv)

[ ... ]

>  			test_init(&test, ifobj_tx, ifobj_rx, i, &tests[j]);
> -			run_pkt_test(&test);
> -			usleep(USLEEP_MAX);
> -
> -			if (test.fail)
> +			if (run_pkt_test(&test) == TEST_FAILURE)
>  				failed_tests++;
> +			usleep(USLEEP_MAX);
>  		}
>  	}
> +	ret = failed_tests ? TEST_FAILURE : TEST_PASS;

[Severity: Low]
This change also fixes an existing false pass in the exit status. Should
it go in a separate patch with a Fixes: tag?

Before this patch, failed_tests only went up when test.fail was set.
Several paths return TEST_FAILURE without setting it. One example is in
__testapp_validate_traffic():

	err = test_spec_set_mtu(test, test->mtu);
	if (err) {
		ksft_print_msg("Error, could not set mtu.\n");
		return TEST_FAILURE;
	}

The same is true for these failures:

- xsk_attach_xdp_progs()
- pthread_barrier_init() and pthread_barrier_destroy() in
  __testapp_validate_traffic()
- set_ring_size() in testapp_validate_traffic()

run_pkt_test() printed a "not ok" line for these, but main() still
called ksft_exit_pass() and exited with 0. In xsk_prereqs.sh,
exec_xskxceiver() looks only at the exit status:

	./${XSKOBJ} -i ${VETH0} -i ${VETH1} ${ARGS}
	retval=$?

As a result, these failures were reported as passes.

The commit message does say "which main() counts instead of test->fail,
as not every failing path sets it". Without a Fixes: tag or a small
standalone patch, though, the fix can't be backported without the whole
refactor.

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

  parent reply	other threads:[~2026-10-17  3:06 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-14 18:45 [PATCH v3 net-next 00/15] selftests: net: migrate AF_XDP test suite over to net Maciej Fijalkowski
2026-10-14 18:45 ` [PATCH v3 net-next 01/15] selftests: xsk: factor endpoint work out of pthread wrappers Maciej Fijalkowski
2026-10-15  8:14   ` Björn Töpel
2026-10-14 18:45 ` [PATCH v3 net-next 02/15] selftests: xsk: size the TX UMEM in HW_SW_MAX_RING_SIZE Maciej Fijalkowski
2026-10-15  8:15   ` Björn Töpel
2026-10-15 18:46   ` sashiko-bot
2026-10-17  3:06   ` netdev-bot+sashiko
2026-10-17 14:40     ` Maciej Fijalkowski
2026-10-14 18:45 ` [PATCH v3 net-next 03/15] selftests: xsk: drop the single-interface loopback mode Maciej Fijalkowski
2026-10-15  8:17   ` Björn Töpel
2026-10-17  3:06   ` netdev-bot+sashiko
2026-10-17 14:50     ` Maciej Fijalkowski
2026-10-14 18:45 ` [PATCH v3 net-next 04/15] selftests/bpf: drop the test_progs AF_XDP wrapper Maciej Fijalkowski
2026-10-15  8:18   ` Björn Töpel
2026-10-14 18:45 ` [PATCH v3 net-next 05/15] selftests: net: add a generic rule for BPF skeletons Maciej Fijalkowski
2026-10-15  8:20   ` Björn Töpel
2026-10-14 18:45 ` [PATCH v3 net-next 06/15] selftests: xsk: move the AF_XDP test suite to selftests/net Maciej Fijalkowski
2026-10-15  8:22   ` Björn Töpel
2026-10-17  3:06   ` netdev-bot+sashiko
2026-10-17 15:31     ` Maciej Fijalkowski
2026-10-14 18:45 ` [PATCH v3 net-next 07/15] selftests: xsk: collect interface capabilities in struct xsk_caps Maciej Fijalkowski
2026-10-15  8:27   ` Björn Töpel
2026-10-14 18:45 ` [PATCH v3 net-next 08/15] selftests: xsk: split xskxceiver main() into setup, run and cleanup Maciej Fijalkowski
2026-10-15  8:29   ` Björn Töpel
2026-10-17  3:06   ` netdev-bot+sashiko [this message]
2026-10-14 18:45 ` [PATCH v3 net-next 09/15] selftests: xsk: run one test case per xskxceiver invocation Maciej Fijalkowski
2026-10-15  8:34   ` Björn Töpel
2026-10-15 18:46   ` sashiko-bot
2026-10-17  3:06   ` netdev-bot+sashiko
2026-10-17 16:04     ` Maciej Fijalkowski
2026-10-14 18:45 ` [PATCH v3 net-next 10/15] selftests: xsk: run the RX and TX endpoints in separate processes Maciej Fijalkowski
2026-10-15  9:04   ` Björn Töpel
2026-10-14 18:45 ` [PATCH v3 net-next 11/15] selftests: xsk: add a hardware mode to xskxceiver Maciej Fijalkowski
2026-10-15  9:42   ` Björn Töpel
2026-10-15 10:55     ` Maciej Fijalkowski
2026-10-15 16:03       ` Björn Töpel
2026-10-17  3:06   ` netdev-bot+sashiko
2026-10-17 17:40     ` Maciej Fijalkowski
2026-10-14 18:45 ` [PATCH v3 net-next 12/15] selftests: xsk: pass non-test traffic to the stack in hardware mode Maciej Fijalkowski
2026-10-15 10:05   ` Björn Töpel
2026-10-17  3:06   ` netdev-bot+sashiko
2026-10-14 18:45 ` [PATCH v3 net-next 13/15] selftests: xsk: list the hardware test cases Maciej Fijalkowski
2026-10-14 18:45 ` [PATCH v3 net-next 14/15] selftests: drv-net: test AF_XDP zero-copy with an SKB peer Maciej Fijalkowski
2026-10-15 10:29   ` Björn Töpel
2026-10-15 12:52     ` Maciej Fijalkowski
2026-10-15 18:46   ` sashiko-bot
2026-10-17  3:06   ` netdev-bot+sashiko
2026-10-14 18:45 ` [PATCH v3 net-next 15/15] selftests: xsk: document generic and hardware endpoint runs Maciej Fijalkowski
2026-10-17  3:06   ` netdev-bot+sashiko

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=179220636731.434549.8598674043519949556@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=bjorn@kernel.org \
    --cc=bpf@vger.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