* [Devel] [PATCH hci-8.1 v4 0/3] selftests/bpf: run the xsk veth tests in a network namespace of their own
@ 2026-10-27 18:15 Konstantin Khorenko
2026-10-27 18:15 ` [Devel] [PATCH hci-8.1 v4 1/3] selftests/bpf: xsk: exit with the status test_exit() is given Konstantin Khorenko
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Konstantin Khorenko @ 2026-10-27 18:15 UTC (permalink / raw)
To: Konstantin Khorenko, devel
Patchset for task https://virtuozzo.atlassian.net/browse/VSTOR-150731
test_xsk.sh makes its veth pair in the host's namespace. The host's own
traffic on the pair reaches the AF_XDP sockets under test, so the tests
fail on a configured host and pass on a bare one. The series moves the
veth part into a namespace of its own, after two fixes it relies on:
- Patch 1: test_exit() exits 1 for a skip, so the runner counts every
"skip all tests" as a failure.
- Patch 2: xskxceiver takes the fragment limit from the max_skb_frags
sysctl, which AF_XDP does not check and which exists in the initial
namespace only. Take MAX_SKB_FRAGS from the kernel's BTF.
- Patch 3: the namespace itself.
Assisted-by: LLM
Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
Changes in v4:
- Split v3 into three patches. The test_exit() fix gets a Fixes: tag;
mainline gets the same fix (VSTOR-151679), and a commit of its own
here can later be replaced by the ms/ one.
- Patch 3: drop "mount --make-rprivate /", unshare --mount already
makes the new mount namespace private.
- Messages: the sysctl fallback serves kernels without BTF only, it
cannot work inside the namespace; the "as before" claim is gone.
- Link to v3: http://lore.virtuozzo.com/20261026012309.458048-1-eva.kurchatova@virtuozzo.com
Changes in v3:
- The namespace is unnamed, so it goes with its last process however
the run ends, Ctrl-C, a timeout or a kill, and no outer run is left
to delete host interfaces.
- Obtain max_skb_frags from the kernel BTF, removing -f option.
- Fix test_exit() exit status for skipped runs.
- With -d, the namespace is kept.
- Rebased.
- Link to v2: http://lore.virtuozzo.com/kernel/20261022024816.2435565-1-eva.kurchatova@virtuozzo.com/T/#t
Changes in v2:
- -f is checked as the sysctl is, 1 to 45 and digits only, so a value
that would wrap the fragment count or the packet array is refused.
- -f goes into the namespace only when the host's sysctl file could be
read; a bare -f made getopts complain.
- No network namespace skips the tests, as no veth support does, rather
than failing them.
- The -f description says the option tells the tests the kernel's limit
and changes nothing in the kernel.
- The -d hint names the namespace in a usable form.
- test_exit() exits 1 for a skip as it does for the veth one; as the
script has it.
- Link to v1: http://lore.virtuozzo.com/kernel/20261020041218.1659392-1-eva.kurchatova@virtuozzo.com/T/#t
---
Eva Kurchatova (3):
selftests/bpf: xsk: exit with the status test_exit() is given
selftests/bpf: xsk: take the fragment limit from the kernel's BTF
selftests/bpf: run the xsk veth tests in a network namespace of their own
tools/testing/selftests/bpf/test_xsk.sh | 30 +++++++++++++++++++++--
tools/testing/selftests/bpf/xsk_prereqs.sh | 2 +-
tools/testing/selftests/bpf/xskxceiver.c | 39 +++++++++++++++++++++++++++++-
3 files changed, 67 insertions(+), 4 deletions(-)
---
base-commit: 02401c5e378f282fbf11bdc65996253ff65dad9b
change-id: 20261027-b4-prep-khorenko-vstor-150731-xsk-veth-netns-d97e81caa801
Best regards,
--
Konstantin Khorenko,
Virtuozzo Linux Kernel Team
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Devel] [PATCH hci-8.1 v4 1/3] selftests/bpf: xsk: exit with the status test_exit() is given
2026-10-27 18:15 [Devel] [PATCH hci-8.1 v4 0/3] selftests/bpf: run the xsk veth tests in a network namespace of their own Konstantin Khorenko
@ 2026-10-27 18:15 ` Konstantin Khorenko
2026-10-27 18:15 ` [Devel] [PATCH hci-8.1 v4 2/3] selftests/bpf: xsk: take the fragment limit from the kernel's BTF Konstantin Khorenko
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Konstantin Khorenko @ 2026-10-27 18:15 UTC (permalink / raw)
To: Konstantin Khorenko, devel
From: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
test_exit() prints the status it is given, then exits 1 whatever it
was. Every "skip all tests" of test_xsk.sh, no veth support or no ip
utility, reaches the kselftest runner as a failure.
Exit with the given status. The callers pass $ksft_fail or $ksft_skip,
so a failure still exits 1.
Fixes: 895b62eed2ab ("selftests: xsk: fix reporting of failed tests")
https://virtuozzo.atlassian.net/browse/VSTOR-150731
Feature: fix selftests
Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
Reviewed-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
tools/testing/selftests/bpf/xsk_prereqs.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/bpf/xsk_prereqs.sh b/tools/testing/selftests/bpf/xsk_prereqs.sh
index 47c7b8064f38b..12176d85cd6cf 100755
--- a/tools/testing/selftests/bpf/xsk_prereqs.sh
+++ b/tools/testing/selftests/bpf/xsk_prereqs.sh
@@ -50,7 +50,7 @@ test_exit()
if [ $1 -ne 0 ]; then
test_status $1 $(basename $0)
fi
- exit 1
+ exit $1
}
cleanup_iface()
--
2.43.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Devel] [PATCH hci-8.1 v4 2/3] selftests/bpf: xsk: take the fragment limit from the kernel's BTF
2026-10-27 18:15 [Devel] [PATCH hci-8.1 v4 0/3] selftests/bpf: run the xsk veth tests in a network namespace of their own Konstantin Khorenko
2026-10-27 18:15 ` [Devel] [PATCH hci-8.1 v4 1/3] selftests/bpf: xsk: exit with the status test_exit() is given Konstantin Khorenko
@ 2026-10-27 18:15 ` Konstantin Khorenko
2026-10-27 18:15 ` [Devel] [PATCH hci-8.1 v4 3/3] selftests/bpf: run the xsk veth tests in a network namespace of their own Konstantin Khorenko
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Konstantin Khorenko @ 2026-10-27 18:15 UTC (permalink / raw)
To: Konstantin Khorenko, devel
From: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
too_many_frags sends a packet with as many fragments as the kernel
takes, then one that goes past the limit, and expects only the first to
arrive. xskxceiver reads the limit from the max_skb_frags sysctl, which
has two problems:
- AF_XDP does not use the sysctl: xsk_build_skb() checks the
compile-time MAX_SKB_FRAGS. The sysctl only equals it by default, so
on a host where it is lowered the test expects the wrong limit.
- The sysctl exists in the initial network namespace only. A run in any
other namespace finds no file and falls back to 17, wrong for a kernel
built with another CONFIG_MAX_SKB_FRAGS.
Take the limit from the kernel's BTF as the element count of
skb_shared_info's frags array: it is MAX_SKB_FRAGS itself and readable
from any namespace. The sysctl stays as a fallback for a kernel without
BTF.
https://virtuozzo.atlassian.net/browse/VSTOR-150731
Feature: fix selftests
Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
Reviewed-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
tools/testing/selftests/bpf/xskxceiver.c | 39 +++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/bpf/xskxceiver.c
index 11f047b8af752..a4a0b4e2516ca 100644
--- a/tools/testing/selftests/bpf/xskxceiver.c
+++ b/tools/testing/selftests/bpf/xskxceiver.c
@@ -103,6 +103,7 @@
#include "xsk.h"
#include "xskxceiver.h"
#include <bpf/bpf.h>
+#include <bpf/btf.h>
#include <linux/filter.h>
#include "../kselftest.h"
#include "xsk_xdp_common.h"
@@ -325,12 +326,48 @@ static bool ifobj_zc_avail(struct ifobject *ifobject)
return zc_avail;
}
+/* AF_XDP checks MAX_SKB_FRAGS, which the sysctl only follows by default */
+static unsigned int btf_max_skb_frags(void)
+{
+ unsigned int max_skb_frags = 0;
+ const struct btf_member *m;
+ const struct btf_type *t;
+ struct btf *btf;
+ int id, i;
+
+ btf = btf__load_vmlinux_btf();
+ if (!btf)
+ return 0;
+
+ id = btf__find_by_name_kind(btf, "skb_shared_info", BTF_KIND_STRUCT);
+ if (id < 0)
+ goto out;
+
+ t = btf__type_by_id(btf, id);
+ m = btf_members(t);
+ for (i = 0; i < btf_vlen(t); i++, m++) {
+ if (strcmp(btf__name_by_offset(btf, m->name_off), "frags"))
+ continue;
+ t = btf__type_by_id(btf, m->type);
+ if (btf_is_array(t))
+ max_skb_frags = btf_array(t)->nelems;
+ break;
+ }
+out:
+ btf__free(btf);
+ return max_skb_frags;
+}
+
#define MAX_SKB_FRAGS_PATH "/proc/sys/net/core/max_skb_frags"
static unsigned int get_max_skb_frags(void)
{
- unsigned int max_skb_frags = 0;
+ unsigned int max_skb_frags = btf_max_skb_frags();
FILE *file;
+ if (max_skb_frags)
+ return max_skb_frags;
+
+ ksft_print_msg("No MAX_SKB_FRAGS in the kernel's BTF, reading %s\n", MAX_SKB_FRAGS_PATH);
file = fopen(MAX_SKB_FRAGS_PATH, "r");
if (!file) {
ksft_print_msg("Error opening %s\n", MAX_SKB_FRAGS_PATH);
--
2.43.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Devel] [PATCH hci-8.1 v4 3/3] selftests/bpf: run the xsk veth tests in a network namespace of their own
2026-10-27 18:15 [Devel] [PATCH hci-8.1 v4 0/3] selftests/bpf: run the xsk veth tests in a network namespace of their own Konstantin Khorenko
2026-10-27 18:15 ` [Devel] [PATCH hci-8.1 v4 1/3] selftests/bpf: xsk: exit with the status test_exit() is given Konstantin Khorenko
2026-10-27 18:15 ` [Devel] [PATCH hci-8.1 v4 2/3] selftests/bpf: xsk: take the fragment limit from the kernel's BTF Konstantin Khorenko
@ 2026-10-27 18:15 ` Konstantin Khorenko
2026-10-27 18:50 ` [Devel] [PATCH hci-8.1 v4 0/3] " Eva Kurchatova (Virtuozzo)
2026-10-29 13:59 ` Konstantin Khorenko
4 siblings, 0 replies; 6+ messages in thread
From: Konstantin Khorenko @ 2026-10-27 18:15 UTC (permalink / raw)
To: Konstantin Khorenko, devel
From: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
test_xsk.sh makes its veth pair in the namespace it runs in, and the
host treats it as any new interface: address configuration, neighbour
discovery and the like happen on that pair. The AF_XDP sockets under
test receive the host's packets among their own. The tests count and
inspect what they receive, so they fail on a configured host and pass
on a bare one.
Re-run the veth part in an unnamed network namespace with a sysfs of its
own, which the busy poll setup writes to. The namespace goes away with
its last process however the run ends, and takes the pair with it.
With -d the pair has to outlive the run, so the namespace gets a name,
and the script prints how to enter and delete it.
If no network namespace can be created, the tests are skipped, as
without veth or ip. A failure after that, mounting sysfs in the
namespace included, fails the run.
https://virtuozzo.atlassian.net/browse/VSTOR-150731
Feature: fix selftests
Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
tools/testing/selftests/bpf/test_xsk.sh | 30 ++++++++++++++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/bpf/test_xsk.sh b/tools/testing/selftests/bpf/test_xsk.sh
index 65aafe0003db0..1554d1ec02b12 100755
--- a/tools/testing/selftests/bpf/test_xsk.sh
+++ b/tools/testing/selftests/bpf/test_xsk.sh
@@ -68,7 +68,8 @@
# Run with verbose output:
# sudo ./test_xsk.sh -v
#
-# Set up veth interfaces and leave them up so xskxceiver can be launched in a debugger:
+# Set up veth interfaces in a network namespace and leave them up so
+# xskxceiver can be launched in a debugger there:
# sudo ./test_xsk.sh -d
#
# Run test suite for physical device in loopback mode
@@ -162,8 +163,33 @@ if [ ! -z $ETH ]; then
VETH1=${ETH}
else
validate_root_exec
- validate_veth_support ${VETH0}
validate_ip_utility
+ # The host configures and talks on any new interface in its namespace
+ if [ -z "$XSK_NETNS" ]; then
+ if ! unshare --net true; then
+ echo "skip all tests: cannot create a network namespace" >&2
+ test_exit $ksft_skip
+ fi
+ if [[ $debug -ne 1 ]]; then
+ # Unnamed, it goes with its last process; its own sysfs shows its interfaces
+ XSK_NETNS=1 exec unshare --net --mount sh -c \
+ 'mount -t sysfs sysfs /sys && exec bash "$0" "$@"' \
+ "$0" "$@"
+ fi
+ # The pair of a run by hand outlives it, in a namespace with a name
+ XSK_NETNS=xsk${VETH0_POSTFIX}
+ ip netns add ${XSK_NETNS} || exit 1
+ trap "ip netns del ${XSK_NETNS}" EXIT
+ # This run's veth names were never created; the pair is in the namespace
+ trap "exit 1" INT
+ XSK_NETNS=${XSK_NETNS} ip netns exec ${XSK_NETNS} bash "$0" "$@" || exit
+ trap - EXIT
+ echo "The pair is up in network namespace ${XSK_NETNS}," \
+ "use ip netns exec ${XSK_NETNS};" \
+ "ip netns del ${XSK_NETNS} removes it"
+ exit 0
+ fi
+ validate_veth_support ${VETH0}
setup_vethPairs
retval=$?
--
2.43.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Devel] [PATCH hci-8.1 v4 0/3] selftests/bpf: run the xsk veth tests in a network namespace of their own
2026-10-27 18:15 [Devel] [PATCH hci-8.1 v4 0/3] selftests/bpf: run the xsk veth tests in a network namespace of their own Konstantin Khorenko
` (2 preceding siblings ...)
2026-10-27 18:15 ` [Devel] [PATCH hci-8.1 v4 3/3] selftests/bpf: run the xsk veth tests in a network namespace of their own Konstantin Khorenko
@ 2026-10-27 18:50 ` Eva Kurchatova (Virtuozzo)
2026-10-29 13:59 ` Konstantin Khorenko
4 siblings, 0 replies; 6+ messages in thread
From: Eva Kurchatova (Virtuozzo) @ 2026-10-27 18:50 UTC (permalink / raw)
To: Konstantin Khorenko, devel
On 10/27/26 20:15, Konstantin Khorenko wrote:
> Patchset for task https://virtuozzo.atlassian.net/browse/VSTOR-150731
>
> test_xsk.sh makes its veth pair in the host's namespace. The host's own
> traffic on the pair reaches the AF_XDP sockets under test, so the tests
> fail on a configured host and pass on a bare one. The series moves the
> veth part into a namespace of its own, after two fixes it relies on:
>
> - Patch 1: test_exit() exits 1 for a skip, so the runner counts every
> "skip all tests" as a failure.
> - Patch 2: xskxceiver takes the fragment limit from the max_skb_frags
> sysctl, which AF_XDP does not check and which exists in the initial
> namespace only. Take MAX_SKB_FRAGS from the kernel's BTF.
> - Patch 3: the namespace itself.
>
> Assisted-by: LLM
> Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
> ---
> Changes in v4:
> - Split v3 into three patches. The test_exit() fix gets a Fixes: tag;
> mainline gets the same fix (VSTOR-151679), and a commit of its own
> here can later be replaced by the ms/ one.
> - Patch 3: drop "mount --make-rprivate /", unshare --mount already
> makes the new mount namespace private.
> - Messages: the sysctl fallback serves kernels without BTF only, it
> cannot work inside the namespace; the "as before" claim is gone.
> - Link to v3: http://lore.virtuozzo.com/20261026012309.458048-1-eva.kurchatova@virtuozzo.com
>
> Changes in v3:
> - The namespace is unnamed, so it goes with its last process however
> the run ends, Ctrl-C, a timeout or a kill, and no outer run is left
> to delete host interfaces.
> - Obtain max_skb_frags from the kernel BTF, removing -f option.
> - Fix test_exit() exit status for skipped runs.
> - With -d, the namespace is kept.
> - Rebased.
> - Link to v2: http://lore.virtuozzo.com/kernel/20261022024816.2435565-1-eva.kurchatova@virtuozzo.com/T/#t
>
> Changes in v2:
> - -f is checked as the sysctl is, 1 to 45 and digits only, so a value
> that would wrap the fragment count or the packet array is refused.
> - -f goes into the namespace only when the host's sysctl file could be
> read; a bare -f made getopts complain.
> - No network namespace skips the tests, as no veth support does, rather
> than failing them.
> - The -f description says the option tells the tests the kernel's limit
> and changes nothing in the kernel.
> - The -d hint names the namespace in a usable form.
> - test_exit() exits 1 for a skip as it does for the veth one; as the
> script has it.
> - Link to v1: http://lore.virtuozzo.com/kernel/20261020041218.1659392-1-eva.kurchatova@virtuozzo.com/T/#t
>
> ---
> Eva Kurchatova (3):
> selftests/bpf: xsk: exit with the status test_exit() is given
> selftests/bpf: xsk: take the fragment limit from the kernel's BTF
> selftests/bpf: run the xsk veth tests in a network namespace of their own
>
> tools/testing/selftests/bpf/test_xsk.sh | 30 +++++++++++++++++++++--
> tools/testing/selftests/bpf/xsk_prereqs.sh | 2 +-
> tools/testing/selftests/bpf/xskxceiver.c | 39 +++++++++++++++++++++++++++++-
> 3 files changed, 67 insertions(+), 4 deletions(-)
> ---
> base-commit: 02401c5e378f282fbf11bdc65996253ff65dad9b
> change-id: 20261027-b4-prep-khorenko-vstor-150731-xsk-veth-netns-d97e81caa801
>
> Best regards,
> --
> Konstantin Khorenko,
> Virtuozzo Linux Kernel Team
Thanks, I've had a look. This is a clean split of my v3 series into 3
commits, with some wording tightened. The dropped `mount --make-rprivate
/` is correct, as `unshare --mount` already makes the new mount
namespace private.
This is good to merge.
Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Devel] [PATCH hci-8.1 v4 0/3] selftests/bpf: run the xsk veth tests in a network namespace of their own
2026-10-27 18:15 [Devel] [PATCH hci-8.1 v4 0/3] selftests/bpf: run the xsk veth tests in a network namespace of their own Konstantin Khorenko
` (3 preceding siblings ...)
2026-10-27 18:50 ` [Devel] [PATCH hci-8.1 v4 0/3] " Eva Kurchatova (Virtuozzo)
@ 2026-10-29 13:59 ` Konstantin Khorenko
4 siblings, 0 replies; 6+ messages in thread
From: Konstantin Khorenko @ 2026-10-29 13:59 UTC (permalink / raw)
To: devel, Konstantin Khorenko
On Tue, 27 Oct 2026 19:15:18 +0100, Konstantin Khorenko wrote:
> selftests/bpf: run the xsk veth tests in a network namespace of their own
>
> Patchset for task https://virtuozzo.atlassian.net/browse/VSTOR-150731
>
> test_xsk.sh makes its veth pair in the host's namespace. The host's own
> traffic on the pair reaches the AF_XDP sockets under test, so the tests
> fail on a configured host and pass on a bare one. The series moves the
> veth part into a namespace of its own, after two fixes it relies on:
>
> [...]
Applied to branch-rh10-6.12.0-211.52.1.22.x.vz10-ovz, will be released in rh10-6.12.0-211.52.1.22.12.vz10, thanks!
[1/3] selftests/bpf: xsk: exit with the status test_exit() is given
https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/db5e04c0d837
[2/3] selftests/bpf: xsk: take the fragment limit from the kernel's BTF
https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/af464697646e
[3/3] selftests/bpf: run the xsk veth tests in a network namespace of their own
https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/d9f6317f6c14
--
Konstantin Khorenko,
Virtuozzo Linux Kernel Team
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-10-29 14:00 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-27 18:15 [Devel] [PATCH hci-8.1 v4 0/3] selftests/bpf: run the xsk veth tests in a network namespace of their own Konstantin Khorenko
2026-10-27 18:15 ` [Devel] [PATCH hci-8.1 v4 1/3] selftests/bpf: xsk: exit with the status test_exit() is given Konstantin Khorenko
2026-10-27 18:15 ` [Devel] [PATCH hci-8.1 v4 2/3] selftests/bpf: xsk: take the fragment limit from the kernel's BTF Konstantin Khorenko
2026-10-27 18:15 ` [Devel] [PATCH hci-8.1 v4 3/3] selftests/bpf: run the xsk veth tests in a network namespace of their own Konstantin Khorenko
2026-10-27 18:50 ` [Devel] [PATCH hci-8.1 v4 0/3] " Eva Kurchatova (Virtuozzo)
2026-10-29 13:59 ` Konstantin Khorenko
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.