* [PATCH net-next v2 1/2] selftests: drv-net: add path helper for net/lib
@ 2025-03-06 17:11 Jakub Kicinski
2025-03-06 17:11 ` [PATCH net-next v2 2/2] selftests: net: use the dummy bpf from net/lib Jakub Kicinski
2025-03-06 22:22 ` [PATCH net-next v2 1/2] selftests: drv-net: add path helper for net/lib Willem de Bruijn
0 siblings, 2 replies; 8+ messages in thread
From: Jakub Kicinski @ 2025-03-06 17:11 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, pabeni, andrew+netdev, horms, shuah, willemb,
petrm, sdf, linux-kselftest, Jakub Kicinski
Looks like a lot of users of recently added env.rpath() actually
want to access stuff under net/lib. Add another helper.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
tools/testing/selftests/drivers/net/hds.py | 2 +-
tools/testing/selftests/drivers/net/hw/csum.py | 2 +-
tools/testing/selftests/drivers/net/lib/py/env.py | 7 +++++++
3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/drivers/net/hds.py b/tools/testing/selftests/drivers/net/hds.py
index 7cc74faed743..def44c10349a 100755
--- a/tools/testing/selftests/drivers/net/hds.py
+++ b/tools/testing/selftests/drivers/net/hds.py
@@ -20,7 +20,7 @@ from lib.py import defer, ethtool, ip
def _xdp_onoff(cfg):
- prog = cfg.rpath("../../net/lib/xdp_dummy.bpf.o")
+ prog = cfg.lpath("xdp_dummy.bpf.o")
ip("link set dev %s xdp obj %s sec xdp" %
(cfg.ifname, prog))
ip("link set dev %s xdp off" % cfg.ifname)
diff --git a/tools/testing/selftests/drivers/net/hw/csum.py b/tools/testing/selftests/drivers/net/hw/csum.py
index 701aca1361e0..49ec98aef579 100755
--- a/tools/testing/selftests/drivers/net/hw/csum.py
+++ b/tools/testing/selftests/drivers/net/hw/csum.py
@@ -88,7 +88,7 @@ from lib.py import bkg, cmd, wait_port_listen
with NetDrvEpEnv(__file__, nsim_test=False) as cfg:
check_nic_features(cfg)
- cfg.bin_local = cfg.rpath("../../../net/lib/csum")
+ cfg.bin_local = cfg.lpath("csum")
cfg.bin_remote = cfg.remote.deploy(cfg.bin_local)
cases = []
diff --git a/tools/testing/selftests/drivers/net/lib/py/env.py b/tools/testing/selftests/drivers/net/lib/py/env.py
index fd4d674e6c72..2a1f8bd0ec19 100644
--- a/tools/testing/selftests/drivers/net/lib/py/env.py
+++ b/tools/testing/selftests/drivers/net/lib/py/env.py
@@ -30,6 +30,13 @@ from .remote import Remote
src_dir = Path(self.src_path).parent.resolve()
return (src_dir / path).as_posix()
+ def lpath(self, path):
+ """
+ Similar to rpath, but for files in net/lib TARGET.
+ """
+ lib_dir = (Path(__file__).parent / "../../../../net/lib").resolve()
+ return (lib_dir / path).as_posix()
+
def _load_env_file(self):
env = os.environ.copy()
--
2.48.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH net-next v2 2/2] selftests: net: use the dummy bpf from net/lib
2025-03-06 17:11 [PATCH net-next v2 1/2] selftests: drv-net: add path helper for net/lib Jakub Kicinski
@ 2025-03-06 17:11 ` Jakub Kicinski
2025-03-06 19:35 ` Willem de Bruijn
2025-03-06 22:22 ` [PATCH net-next v2 1/2] selftests: drv-net: add path helper for net/lib Willem de Bruijn
1 sibling, 1 reply; 8+ messages in thread
From: Jakub Kicinski @ 2025-03-06 17:11 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, pabeni, andrew+netdev, horms, shuah, willemb,
petrm, sdf, linux-kselftest, Jakub Kicinski
Commit 29b036be1b0b ("selftests: drv-net: test XDP, HDS auto and
the ioctl path") added an sample XDP_PASS prog in net/lib, so
that we can reuse it in various sub-directories. Delete the old
sample and use the one from the lib in existing tests.
Acked-by: Stanislav Fomichev <sdf@fomichev.me>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
v2:
- also remove the one in drivers/net/hw/
v1: https://lore.kernel.org/20250228212956.25399-2-kuba@kernel.org
---
.../selftests/drivers/net/hw/xdp_dummy.bpf.c | 13 -------------
tools/testing/selftests/net/xdp_dummy.bpf.c | 13 -------------
tools/testing/selftests/drivers/net/hw/irq.py | 2 +-
tools/testing/selftests/net/udpgro_bench.sh | 2 +-
tools/testing/selftests/net/udpgro_frglist.sh | 2 +-
tools/testing/selftests/net/udpgro_fwd.sh | 2 +-
tools/testing/selftests/net/veth.sh | 2 +-
7 files changed, 5 insertions(+), 31 deletions(-)
delete mode 100644 tools/testing/selftests/drivers/net/hw/xdp_dummy.bpf.c
delete mode 100644 tools/testing/selftests/net/xdp_dummy.bpf.c
diff --git a/tools/testing/selftests/drivers/net/hw/xdp_dummy.bpf.c b/tools/testing/selftests/drivers/net/hw/xdp_dummy.bpf.c
deleted file mode 100644
index d988b2e0cee8..000000000000
--- a/tools/testing/selftests/drivers/net/hw/xdp_dummy.bpf.c
+++ /dev/null
@@ -1,13 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-
-#define KBUILD_MODNAME "xdp_dummy"
-#include <linux/bpf.h>
-#include <bpf/bpf_helpers.h>
-
-SEC("xdp")
-int xdp_dummy_prog(struct xdp_md *ctx)
-{
- return XDP_PASS;
-}
-
-char _license[] SEC("license") = "GPL";
diff --git a/tools/testing/selftests/net/xdp_dummy.bpf.c b/tools/testing/selftests/net/xdp_dummy.bpf.c
deleted file mode 100644
index d988b2e0cee8..000000000000
--- a/tools/testing/selftests/net/xdp_dummy.bpf.c
+++ /dev/null
@@ -1,13 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-
-#define KBUILD_MODNAME "xdp_dummy"
-#include <linux/bpf.h>
-#include <bpf/bpf_helpers.h>
-
-SEC("xdp")
-int xdp_dummy_prog(struct xdp_md *ctx)
-{
- return XDP_PASS;
-}
-
-char _license[] SEC("license") = "GPL";
diff --git a/tools/testing/selftests/drivers/net/hw/irq.py b/tools/testing/selftests/drivers/net/hw/irq.py
index 42ab98370245..e3c2201bb58b 100755
--- a/tools/testing/selftests/drivers/net/hw/irq.py
+++ b/tools/testing/selftests/drivers/net/hw/irq.py
@@ -69,7 +69,7 @@ from lib.py import cmd, ip, defer
def check_reconfig_xdp(cfg) -> None:
def reconfig(cfg) -> None:
ip(f"link set dev %s xdp obj %s sec xdp" %
- (cfg.ifname, cfg.rpath("xdp_dummy.bpf.o")))
+ (cfg.ifname, cfg.lpath("xdp_dummy.bpf.o")))
ip(f"link set dev %s xdp off" % cfg.ifname)
_check_reconfig(cfg, reconfig)
diff --git a/tools/testing/selftests/net/udpgro_bench.sh b/tools/testing/selftests/net/udpgro_bench.sh
index c51ea90a1395..815fad8c53a8 100755
--- a/tools/testing/selftests/net/udpgro_bench.sh
+++ b/tools/testing/selftests/net/udpgro_bench.sh
@@ -7,7 +7,7 @@ source net_helper.sh
readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)"
-BPF_FILE="xdp_dummy.bpf.o"
+BPF_FILE="lib/xdp_dummy.bpf.o"
cleanup() {
local -r jobs="$(jobs -p)"
diff --git a/tools/testing/selftests/net/udpgro_frglist.sh b/tools/testing/selftests/net/udpgro_frglist.sh
index 17404f49cdb6..5f3d1a110d11 100755
--- a/tools/testing/selftests/net/udpgro_frglist.sh
+++ b/tools/testing/selftests/net/udpgro_frglist.sh
@@ -7,7 +7,7 @@ source net_helper.sh
readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)"
-BPF_FILE="xdp_dummy.bpf.o"
+BPF_FILE="lib/xdp_dummy.bpf.o"
cleanup() {
local -r jobs="$(jobs -p)"
diff --git a/tools/testing/selftests/net/udpgro_fwd.sh b/tools/testing/selftests/net/udpgro_fwd.sh
index 550d8eb3e224..f22f6c66997e 100755
--- a/tools/testing/selftests/net/udpgro_fwd.sh
+++ b/tools/testing/selftests/net/udpgro_fwd.sh
@@ -3,7 +3,7 @@
source net_helper.sh
-BPF_FILE="xdp_dummy.bpf.o"
+BPF_FILE="lib/xdp_dummy.bpf.o"
readonly BASE="ns-$(mktemp -u XXXXXX)"
readonly SRC=2
readonly DST=1
diff --git a/tools/testing/selftests/net/veth.sh b/tools/testing/selftests/net/veth.sh
index 6bb7dfaa30b6..9709dd067c72 100755
--- a/tools/testing/selftests/net/veth.sh
+++ b/tools/testing/selftests/net/veth.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
-BPF_FILE="xdp_dummy.bpf.o"
+BPF_FILE="lib/xdp_dummy.bpf.o"
readonly STATS="$(mktemp -p /tmp ns-XXXXXX)"
readonly BASE=`basename $STATS`
readonly SRC=2
--
2.48.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH net-next v2 2/2] selftests: net: use the dummy bpf from net/lib
2025-03-06 17:11 ` [PATCH net-next v2 2/2] selftests: net: use the dummy bpf from net/lib Jakub Kicinski
@ 2025-03-06 19:35 ` Willem de Bruijn
2025-03-06 20:56 ` Jakub Kicinski
0 siblings, 1 reply; 8+ messages in thread
From: Willem de Bruijn @ 2025-03-06 19:35 UTC (permalink / raw)
To: Jakub Kicinski, davem
Cc: netdev, edumazet, pabeni, andrew+netdev, horms, shuah, willemb,
petrm, sdf, linux-kselftest, Jakub Kicinski
Jakub Kicinski wrote:
> Commit 29b036be1b0b ("selftests: drv-net: test XDP, HDS auto and
> the ioctl path") added an sample XDP_PASS prog in net/lib, so
> that we can reuse it in various sub-directories. Delete the old
> sample and use the one from the lib in existing tests.
>
> Acked-by: Stanislav Fomichev <sdf@fomichev.me>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> diff --git a/tools/testing/selftests/net/udpgro_bench.sh b/tools/testing/selftests/net/udpgro_bench.sh
> index c51ea90a1395..815fad8c53a8 100755
> --- a/tools/testing/selftests/net/udpgro_bench.sh
> +++ b/tools/testing/selftests/net/udpgro_bench.sh
> @@ -7,7 +7,7 @@ source net_helper.sh
>
> readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)"
>
> -BPF_FILE="xdp_dummy.bpf.o"
> +BPF_FILE="lib/xdp_dummy.bpf.o"
Just curious:
How does tools/testing/selftests/net/lib get compiled? The other
subdirs of net are separate explicit targets in
tools/testing/selftests/Makefile
And what is the magic that avoids the need for adding bpf objects to
.gitignore?
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH net-next v2 2/2] selftests: net: use the dummy bpf from net/lib
2025-03-06 19:35 ` Willem de Bruijn
@ 2025-03-06 20:56 ` Jakub Kicinski
2025-03-06 22:20 ` Willem de Bruijn
0 siblings, 1 reply; 8+ messages in thread
From: Jakub Kicinski @ 2025-03-06 20:56 UTC (permalink / raw)
To: Willem de Bruijn
Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms, shuah,
willemb, petrm, sdf, linux-kselftest
On Thu, 06 Mar 2025 14:35:09 -0500 Willem de Bruijn wrote:
> How does tools/testing/selftests/net/lib get compiled?
> The other subdirs of net are separate explicit targets in
> tools/testing/selftests/Makefile
There is some magic / hack at top level:
# Networking tests want the net/lib target, include it automatically
ifneq ($(filter net drivers/net drivers/net/hw,$(TARGETS)),)
ifeq ($(filter net/lib,$(TARGETS)),)
INSTALL_DEP_TARGETS := net/lib
endif
endif
https://web.git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/tree/tools/testing/selftests/Makefile#n129
> And what is the magic that avoids the need for adding bpf objects to
> .gitignore?
All BPF files are suffixed with .bpf.c and we turn that into .bpf.o
So they have an .o at the end, I think the global gitignore ignores
those?
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH net-next v2 2/2] selftests: net: use the dummy bpf from net/lib
2025-03-06 20:56 ` Jakub Kicinski
@ 2025-03-06 22:20 ` Willem de Bruijn
0 siblings, 0 replies; 8+ messages in thread
From: Willem de Bruijn @ 2025-03-06 22:20 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Willem de Bruijn, davem, netdev, edumazet, pabeni, andrew+netdev,
horms, shuah, petrm, sdf, linux-kselftest
On Thu, Mar 6, 2025 at 3:56 PM Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Thu, 06 Mar 2025 14:35:09 -0500 Willem de Bruijn wrote:
> > How does tools/testing/selftests/net/lib get compiled?
> > The other subdirs of net are separate explicit targets in
> > tools/testing/selftests/Makefile
>
> There is some magic / hack at top level:
>
> # Networking tests want the net/lib target, include it automatically
> ifneq ($(filter net drivers/net drivers/net/hw,$(TARGETS)),)
> ifeq ($(filter net/lib,$(TARGETS)),)
> INSTALL_DEP_TARGETS := net/lib
> endif
> endif
Oh right.
>
> https://web.git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/tree/tools/testing/selftests/Makefile#n129
>
> > And what is the magic that avoids the need for adding bpf objects to
> > .gitignore?
>
> All BPF files are suffixed with .bpf.c and we turn that into .bpf.o
> So they have an .o at the end, I think the global gitignore ignores
> those?
Also makes sense. Thanks!
Reviewed-by: Willem de Bruijn <willemb@google.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next v2 1/2] selftests: drv-net: add path helper for net/lib
2025-03-06 17:11 [PATCH net-next v2 1/2] selftests: drv-net: add path helper for net/lib Jakub Kicinski
2025-03-06 17:11 ` [PATCH net-next v2 2/2] selftests: net: use the dummy bpf from net/lib Jakub Kicinski
@ 2025-03-06 22:22 ` Willem de Bruijn
2025-03-07 0:00 ` Jakub Kicinski
1 sibling, 1 reply; 8+ messages in thread
From: Willem de Bruijn @ 2025-03-06 22:22 UTC (permalink / raw)
To: Jakub Kicinski
Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms, shuah,
petrm, sdf, linux-kselftest
On Thu, Mar 6, 2025 at 12:12 PM Jakub Kicinski <kuba@kernel.org> wrote:
>
> Looks like a lot of users of recently added env.rpath() actually
> want to access stuff under net/lib. Add another helper.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Willem de Bruijn <willemb@google.com>
> diff --git a/tools/testing/selftests/drivers/net/lib/py/env.py b/tools/testing/selftests/drivers/net/lib/py/env.py
> index fd4d674e6c72..2a1f8bd0ec19 100644
> --- a/tools/testing/selftests/drivers/net/lib/py/env.py
> +++ b/tools/testing/selftests/drivers/net/lib/py/env.py
> @@ -30,6 +30,13 @@ from .remote import Remote
> src_dir = Path(self.src_path).parent.resolve()
> return (src_dir / path).as_posix()
>
> + def lpath(self, path):
> + """
> + Similar to rpath, but for files in net/lib TARGET.
> + """
> + lib_dir = (Path(__file__).parent / "../../../../net/lib").resolve()
> + return (lib_dir / path).as_posix()
> +
small nit that one letter acronyms are not the most self describing ;)
I would initially read this as local path
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next v2 1/2] selftests: drv-net: add path helper for net/lib
2025-03-06 22:22 ` [PATCH net-next v2 1/2] selftests: drv-net: add path helper for net/lib Willem de Bruijn
@ 2025-03-07 0:00 ` Jakub Kicinski
2025-03-07 1:31 ` Willem de Bruijn
0 siblings, 1 reply; 8+ messages in thread
From: Jakub Kicinski @ 2025-03-07 0:00 UTC (permalink / raw)
To: Willem de Bruijn
Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms, shuah,
petrm, sdf, linux-kselftest
On Thu, 6 Mar 2025 17:22:47 -0500 Willem de Bruijn wrote:
> > + def lpath(self, path):
> > + """
> > + Similar to rpath, but for files in net/lib TARGET.
> > + """
> > + lib_dir = (Path(__file__).parent / "../../../../net/lib").resolve()
> > + return (lib_dir / path).as_posix()
> > +
>
> small nit that one letter acronyms are not the most self describing ;)
> I would initially read this as local path
The other option that came to mind was to have one helper called path()
and pass rel=CONST to it. For example:
prog = cfg.path("xdp_dummy.bpf.o", rel=cfg.NET_LIB)
Thinking about it now we could also store dir directly, which is
probably most "Pythonic"?
prog = cfg.net_lib_dir / "xdp_dummy.bpf.o"
Thoughts?
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH net-next v2 1/2] selftests: drv-net: add path helper for net/lib
2025-03-07 0:00 ` Jakub Kicinski
@ 2025-03-07 1:31 ` Willem de Bruijn
0 siblings, 0 replies; 8+ messages in thread
From: Willem de Bruijn @ 2025-03-07 1:31 UTC (permalink / raw)
To: Jakub Kicinski, Willem de Bruijn
Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms, shuah,
petrm, sdf, linux-kselftest
Jakub Kicinski wrote:
> On Thu, 6 Mar 2025 17:22:47 -0500 Willem de Bruijn wrote:
> > > + def lpath(self, path):
> > > + """
> > > + Similar to rpath, but for files in net/lib TARGET.
> > > + """
> > > + lib_dir = (Path(__file__).parent / "../../../../net/lib").resolve()
> > > + return (lib_dir / path).as_posix()
> > > +
> >
> > small nit that one letter acronyms are not the most self describing ;)
> > I would initially read this as local path
>
> The other option that came to mind was to have one helper called path()
> and pass rel=CONST to it. For example:
>
> prog = cfg.path("xdp_dummy.bpf.o", rel=cfg.NET_LIB)
>
> Thinking about it now we could also store dir directly, which is
> probably most "Pythonic"?
>
> prog = cfg.net_lib_dir / "xdp_dummy.bpf.o"
>
> Thoughts?
The pythonic approach is nice. No function indirection, so self explanatory.
But they all are reasonable, of course.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-03-07 1:31 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-06 17:11 [PATCH net-next v2 1/2] selftests: drv-net: add path helper for net/lib Jakub Kicinski
2025-03-06 17:11 ` [PATCH net-next v2 2/2] selftests: net: use the dummy bpf from net/lib Jakub Kicinski
2025-03-06 19:35 ` Willem de Bruijn
2025-03-06 20:56 ` Jakub Kicinski
2025-03-06 22:20 ` Willem de Bruijn
2025-03-06 22:22 ` [PATCH net-next v2 1/2] selftests: drv-net: add path helper for net/lib Willem de Bruijn
2025-03-07 0:00 ` Jakub Kicinski
2025-03-07 1:31 ` Willem de Bruijn
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).