From: Jakub Kicinski <kuba@kernel.org>
To: Joe Damato <jdamato@fastly.com>
Cc: netdev@vger.kernel.org, Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>, Shuah Khan <shuah@kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Jesper Dangaard Brouer <hawk@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
linux-kernel@vger.kernel.org (open list),
linux-kselftest@vger.kernel.org (open list:KERNEL SELFTEST
FRAMEWORK),
bpf@vger.kernel.org (open list:XDP (eXpress Data
Path):Keyword:(?:\b|_)xdp(?:\b|_))
Subject: Re: [PATCH net-next v2 4/4] selftests: drv-net: Test that NAPI ID is non-zero
Date: Thu, 17 Apr 2025 06:46:15 -0700 [thread overview]
Message-ID: <20250417064615.10aba96b@kernel.org> (raw)
In-Reply-To: <20250417013301.39228-5-jdamato@fastly.com>
On Thu, 17 Apr 2025 01:32:42 +0000 Joe Damato wrote:
> Test that the SO_INCOMING_NAPI_ID of a network file descriptor is
> non-zero. This ensures that either the core networking stack or, in some
> cases like netdevsim, the driver correctly sets the NAPI ID.
>
> Signed-off-by: Joe Damato <jdamato@fastly.com>
> ---
> .../testing/selftests/drivers/net/.gitignore | 1 +
> tools/testing/selftests/drivers/net/Makefile | 6 +-
> .../testing/selftests/drivers/net/napi_id.py | 24 ++++++
> .../selftests/drivers/net/napi_id_helper.c | 83 +++++++++++++++++++
> 4 files changed, 113 insertions(+), 1 deletion(-)
> create mode 100755 tools/testing/selftests/drivers/net/napi_id.py
> create mode 100644 tools/testing/selftests/drivers/net/napi_id_helper.c
>
> diff --git a/tools/testing/selftests/drivers/net/.gitignore b/tools/testing/selftests/drivers/net/.gitignore
> index ec746f374e85..71bd7d651233 100644
> --- a/tools/testing/selftests/drivers/net/.gitignore
> +++ b/tools/testing/selftests/drivers/net/.gitignore
> @@ -1,2 +1,3 @@
> # SPDX-License-Identifier: GPL-2.0-only
> xdp_helper
> +napi_id_helper
sort alphabetically, pls
> diff --git a/tools/testing/selftests/drivers/net/Makefile b/tools/testing/selftests/drivers/net/Makefile
> index 0c95bd944d56..47247c2ef948 100644
> --- a/tools/testing/selftests/drivers/net/Makefile
> +++ b/tools/testing/selftests/drivers/net/Makefile
> @@ -6,9 +6,13 @@ TEST_INCLUDES := $(wildcard lib/py/*.py) \
> ../../net/net_helper.sh \
> ../../net/lib.sh \
>
> -TEST_GEN_FILES := xdp_helper
> +TEST_GEN_FILES := \
> + napi_id_helper \
> + xdp_helper \
like you did here
> +# end of TEST_GEN_FILES
>
> TEST_PROGS := \
> + napi_id.py \
> netcons_basic.sh \
> netcons_fragmented_msg.sh \
> netcons_overflow.sh \
> diff --git a/tools/testing/selftests/drivers/net/napi_id.py b/tools/testing/selftests/drivers/net/napi_id.py
> new file mode 100755
> index 000000000000..aee6f90be49b
> --- /dev/null
> +++ b/tools/testing/selftests/drivers/net/napi_id.py
> @@ -0,0 +1,24 @@
> +#!/usr/bin/env python3
> +# SPDX-License-Identifier: GPL-2.0
> +
> +from lib.py import ksft_run, ksft_exit
> +from lib.py import ksft_eq, NetDrvEpEnv
> +from lib.py import bkg, cmd, rand_port, NetNSEnter
> +
> +def test_napi_id(cfg) -> None:
> + port = rand_port()
> + listen_cmd = f'{cfg.test_dir / "napi_id_helper"} {cfg.addr_v['4']} {port}'
you need to deploy, in case test is running with a real remote machine
and the binary has to be copied over:
bin_remote = cfg.remote.deploy(cfg.test_dir / "napi_id_helper")
listen_cmd = f'{bin_remote} {cfg.addr_v['4']} {port}'
> + with bkg(listen_cmd, ksft_wait=3) as server:
> + with NetNSEnter('net', '/proc/self/ns/'):
> + cmd(f"echo a | socat - TCP:{cfg.addr_v['4']}:{port}", host=cfg.remote, shell=True)
Like Xiao Liang said, just host=cfg.remote should work.
> + ksft_eq(0, server.ret)
> +
next prev parent reply other threads:[~2025-04-17 13:46 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-17 1:32 [PATCH net-next v2 0/4] Fix netdevim to correctly mark NAPI IDs Joe Damato
2025-04-17 1:32 ` [PATCH net-next v2 1/4] netdevsim: Mark NAPI ID on skb in nsim_rcv Joe Damato
2025-04-17 1:32 ` [PATCH net-next v2 2/4] selftests: drv-net: Factor out ksft C helpers Joe Damato
2025-04-17 1:32 ` [PATCH net-next v2 3/4] selftests: net: Allow custom net ns paths Joe Damato
2025-04-17 1:32 ` [PATCH net-next v2 4/4] selftests: drv-net: Test that NAPI ID is non-zero Joe Damato
2025-04-17 7:26 ` Paolo Abeni
2025-04-17 16:33 ` Joe Damato
2025-04-17 10:21 ` Xiao Liang
2025-04-17 13:46 ` Jakub Kicinski [this message]
2025-04-17 16:43 ` Joe Damato
2025-04-17 16:53 ` Jakub Kicinski
2025-04-17 17:06 ` Joe Damato
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=20250417064615.10aba96b@kernel.org \
--to=kuba@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=jdamato@fastly.com \
--cc=john.fastabend@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shuah@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).