Article View: linux.kernel.netdev
Article #5666Re: [PATCH v4 net-next 08/15] selftests: xsk: split xskxceiver main() into setup, run and cleanup
From: netdev-bot+sashiko
Date: Tue, 20 Oct 2026 19:30
Date: Tue, 20 Oct 2026 19:30
157 lines
13536 bytes
13536 bytes
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] In tools/testing/selftests/net/lib/xsk/test_xsk.c,
xsk_reattach_xdp() attaches the new program withβ¦
- [Low] Baseline decision: not a valid finding at the end of the series.
--
selftests: xsk: split xskxceiver main() into setup, run and cleanup
This splits xskxceiver main() into the bind_iface(), detect_mode_caps(),
mode_supported() and cleanup_iface() helpers, to prepare for running a
single endpoint per process. run_pkt_test() now returns its result, and
main() gets a common out label for teardown. ksft_print_header() is called
right after parsing, so stdout is line buffered.
> diff --git a/tools/testing/selftests/net/lib/xsk/xskxceiver.c b/tools/testing/selftests/net/lib/xsk/xskxceiver.c
> index d82224a4fa4b0..97eece4c57f89 100644
> --- a/tools/testing/selftests/net/lib/xsk/xskxceiver.c
> +++ b/tools/testing/selftests/net/lib/xsk/xskxceiver.c
[ ... ]
> @@ -317,26 +332,43 @@ static bool is_xdp_supported(int ifindex)
[ ... ]
> +static void cleanup_iface(struct ifobject *ifobj)
> +{
> + if (ifobj->xdp_prog)
> + xsk_detach_xdp_program(ifobj->ifindex,
> + mode_to_xdp_flags(ifobj->mode));
> + xsk_unload_xdp_programs(ifobj);
> +}
[Severity: Low]
Can a native XDP program stay attached to the interface after xskxceiver
exits?
cleanup_iface() uses ifobj->xdp_prog and ifobj->mode to decide whether to
detach, and which flags to pass. Both fields are set only at the end of
xsk_reattach_xdp() in test_xsk.c, after the DRV mode check:
test_xsk.c:xsk_reattach_xdp() {
...
err = xsk_attach_xdp_program(xdp_prog, ifobj->ifindex, mode_to_xdp_flags(mode));
if (err) {
...
}
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 if bpf_xdp_query() fails, for example on a
netlink socket or recv error. That can happen even though the attach with
XDP_FLAGS_DRV_MODE succeeded. The error path then returns without
detaching the new program and without recording it.
If this is the first DRV/ZC attach, ifobj->xdp_prog is still NULL from
ifobject_create(), so cleanup_iface() skips the detach. If an earlier SKB
attach succeeded, cleanup_iface() detaches with XDP_FLAGS_SKB_MODE, and
that doesn't remove the native program.
In this patch, this only matters when the failing attach is the last one
for that ifobj. A later successful reattach in the same mode fixes the
bookkeeping. Later in the series, xskxceiver runs one test per invocation
with a fixed mode. Every DRV/ZC run then hits this check on its first
attach, and xsk_reattach_xdp() and cleanup_iface() are still unchanged.
The old main() never detached XDP programs at all. So this is a gap in the
new teardown, which the commit message describes as using flags "so that
they match the attach".
Would it make sense to record xdp_prog and mode right after the attach
succeeds, before the mode check? Detaching on that error path would also
work.
> @@ -371,90 +407,62 @@ int main(int argc, char **argv)
[ ... ]
> if (opt_run_test != RUN_ALL_TESTS && opt_run_test >= total_tests) {
> ksft_print_msg("Error: test %u does not exist.\n", opt_run_test);
> ksft_exit_xfail();
> }
>
[ ... ]
> + test.tx_pkt_stream_default = pkt_stream_generate(DEFAULT_PKT_CNT, MIN_PKT_SIZE);
> + test.rx_pkt_stream_default = pkt_stream_generate(DEFAULT_PKT_CNT, MIN_PKT_SIZE);
> + if (!test.tx_pkt_stream_default || !test.rx_pkt_stream_default)
> + goto out;
>
[ ... ]
> + caps = detect_mode_caps(ifobj_tx);
>
[ ... ]
> + if (opt_mode != TEST_MODE_ALL && !mode_supported(opt_mode, caps)) {
> + if (opt_mode == TEST_MODE_DRV)
> + ksft_print_msg("Error: XDP_DRV mode not supported.\n");
> + else
> + ksft_print_msg("Error: zero-copy mode not supported.\n");
> ksft_exit_xfail();
> }
[Severity: Low]
The commit message says:
cleanup_iface() detaches and unloads one interface and copes with
partially initialized objects, as does pkt_stream_delete(NULL), so
main() has a single exit path
Is that accurate for this patch? main() still calls ksft_exit_xfail()
after setup in two places, and both skip the out label:
- when the requested test index does not exist. This check now runs
after both interfaces are bound.
- here, when the requested mode is unsupported. This runs after the
packet streams are allocated.
bind_iface() can also call ksft_exit_fail() from parse_command_line() for
the rx interface. By that point the tx interface's skeleton is already
loaded.
None of these exits leaves an XDP program attached. is_xdp_supported()
detaches its probe program, ifobj_zc_avail() deletes its socket, and
process exit frees the skeletons and heap memory.
This is resolved later in the series. There, find_test() and
xsk_set_flow() run before any interface is bound, and only the local
interface is bound. The unsupported-mode case also becomes ret = TEST_SKIP
followed by goto out.
Could the commit message for this patch be reworded? Another option is to
convert these exits to goto out in this patch.
--
Sashiko AI review Β· https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261016174338.787135-1-maciej.fijalkowski%40intel.com
Technical Details
Message-ID:
<179252462414.3135.14132946402715622104@kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-349503-linux-kernel-netdev=dewy.ruReferences:
<20261016174338.787135-9-maciej.fijalkowski@intel.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-349503-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH v4 net-next 08/15] selftests: xsk: split xskxceiver main() into setup, run and cleanup Date: Tue, 20 Oct 2026 19:30:24 +0000 Organization: Usenet Network Message-ID: <179252462414.3135.14132946402715622104@kernel.org> References: <20261016174338.787135-9-maciej.fijalkowski@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3937172"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:YvL8TOoWBJK7afrMdvxiU26TOYI= sha256:otGqiw8naKqOS5i/GcuHTF8kXwPrOFklKX+dyrYeog0= sha1:EtuNI6zcJF1MYbHq/fZ248tx/aY= sha256:B7HE6/Ya97rs2Ssr7QlzoWaHytVbR+jVXE29AC2Rppg= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 51095110DFF; Tue, 20 Oct 2026 22:34:09 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.728 X-Spam-Status: No, score=-3.728 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.329, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bxvoSJve-XDU; Tue, 20 Oct 2026 22:34:06 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-349503-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 2084C110E07; Tue, 20 Oct 2026 22:33:58 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 0AAA83AE3D; Tue, 20 Oct 2026 19:30:50 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1792524641; b=wpBdx2mfUvkJ5RuaBgeDjP0suZobHZZ5KQHFSRibx9VrYB5w8osUYOO2iSNRKk4TttEZ Fv3VcHEUG5szFXKyPju+V5xvwfz7X5/ooyXXasdxcpQb2MzFZtPhheWPR5YlpC0a3BX9U YaltFJKicXvTMKaB1ZF8N873IlriFNhXqUWrr3hYc3Mqj93TukT5kB//TyVtK4DPZaiwI ioV0cH5D1kyJxbJwk7zMJHZgO6KEkhjj9H2jIRqLTUr4kE0eAKphc1Cmkc7Vb/IVnZ+s6 vw0YCSqTrP5aR+O+40eyIpR875gozhhWK5V/0oX6lveSbOgkKvbzPMjbUrPNXPcbpnA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792524641; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=fA8NmMcCUM69tmGM3phS918ewacyRr6rhiWhDJJ8Fzk=; b=rgd0kNeO7bH3kS5hJjGrzLwB77/bxfDQWQ27adXTazw73v6vVRvlDLEYCu53WHsUOL94 /hsByRqBFDsR7YgXn1tTpyqo8aJFgDanY4PyL09KhdLdeWai/gtHxu+dZNsuGD4gF9Io8 VAf6pnpbmIMOQAJ0Z2FsMiqIDZcqOFImLqSTMYrtOWwzuLyA42iH8pm7QB35mM/Jigjgy 8J+bNPZJiWkhprz/AI5W8kpjkqtHG/9smvjI5lIsUQfbOXyOJ2E1p14xFCr5OFtYF/biB UHfvnDJZ8TEG+ko1LEOxXNWY+Pk0u/GVdN4UyYMcQlCOKl0rZ+cYNHiQfU/XbR+kr8w== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=dR85apWi; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7D3A3606A33C; Tue, 20 Oct 2026 19:30:41 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=dR85apWi X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792524625; b=jWLz+CQcZ/5Ew/kTWFXsoVAgj6xVEVSZ75EIGKhMnFqYpRp3KVSkhUsvlvOCocAt/5yc QUqGa1mu00KJ5KLf/ZSuoXfA9Di60MtyZ3TGjCiQgZ/UgBU0C0yqVYnFWPOJ4QGkiO3xc XADQpdWsD/ParHz4zOZ1Qh5v60TPe1STmCq3Eu0RFBmoiNpd39DADvgkN0i5Z1aWqSx76 XVt4orMB/do5ks086g7oNMhjcaQ+OMBcloIB4xZ2eQeg2VsQ2sq7V32atqcU3tMzeXP3R uI17gfikRO/c/fwddNp3hf/Zg1MTLoZa7XxU2CstsyuV7xCn1Og1aDsVHhHcsxh02HQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792524625; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=fA8NmMcCUM69tmGM3phS918ewacyRr6rhiWhDJJ8Fzk=; b=nvynbQ5r4AyqOjTAGmXg0hkjTEiRgS+MUtnxrz+psGj96lXW0SCjU16fPHYlsvWB3yG4 f0hkUkdAac5uJb1Pvoh3wXZBPXqZiOOVsAajfJmxBTw4PTWIxw7qGbscdLuC/LYIizsRC WR0RABtskZzDno0LXhCw0+Elx/riyCXQFMSEaiHNeHQxtyhjzAcM8WIYamkL/9hQXYXeV WygnwsFmcCr+UbtiAd7fTVeQe9e5gIhQ1y/PhhUmiVObS3dJoacQjNZifQAy7YFmz2+PW Dec7I2FDwMuKbSc7XDIn1UZQSINUawHv9/OCYvqOzzONqO5nnniPVmhDEQuuQ9+OeqA== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=dR85apWi; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 59DEC60A2617; Tue, 20 Oct 2026 19:30:25 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94E7C1F000CC; Tue, 20 Oct 2026 19:30:24 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1792524625; bh=fA8NmMcCUM69tmGM3phS918ewacyRr6rhiWhDJJ8Fzk=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=dR85apWi/gh/GTS8LvuRBJzIGbPY9JsgAZa3H5lzy4QEmS2qo+ckN69t3DBiDbRT1 cPgqRATnn227MZNaJQ4r4I6KwbH1pCybD1gMgsTULzW7b5ulSvvVjY/aKFjdoR21j2 0Haemu8/RZGC8J6HAEzuV4P9AipdJgfS22DKZs/xVenB4apKUmhqd20iQgztV+23Yl oyhIhkVyvqv6WMsISHPi4c68DJ/bdwssPpF3zdWycXYdD2qaAzV9BrFNBcj4miv7IX ZddjroPZ6Drje0e6YrqMY0AZoey+0O8aGa7LOQcvr6xZJFTmeUWoPKh15uZpZnxWqf rEu/7F98+6d+Q== X-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 X-In-Reply-To: <20261016174338.787135-9-maciej.fijalkowski@intel.com> X-sashiko-severity: Low X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list