[Devel] [PATCH hci-8.1 v2 1/1] selftests/bpf: run the xsk veth tests in a network namespace of their own

Konstantin Khorenko khorenko at virtuozzo.com
Thu Oct 22 19:14:48 MSK 2026


Hi Eva,

> +		trap "ip netns del ${XSK_NETNS}" EXIT

The parent still has "trap ctrl_c INT" from the top of the script. On
Ctrl-C it runs cleanup_exit ${VETH0} ${VETH1} in the host namespace,
for its own random ve#### names that it never created. If the host
happens to have an interface with that name, it gets deleted.

Fix: in the parent, before the re-exec, replace the INT trap with
"exit 1". The EXIT trap then deletes the namespace, and the pair goes
with it.

> +		# The pair stays up for a run by hand
> +		[[ $debug -eq 1 ]] && trap - EXIT && \
> +			echo "The pair is up in network namespace ${XSK_NETNS}," \
> +				"use ip netns exec ${XSK_NETNS}"

With -d the child prints "-i VETH0 -i VETH1" for the hand run, but not
-f. A hand run of xskxceiver inside the namespace cannot read the
sysctl and falls back to 17 frags, so on a kernel built with
CONFIG_MAX_SKB_FRAGS=45 too_many_frags fails.

Fix: add the value to the child's debug line:

	echo "-i" ${VETH0} "-i" ${VETH1} ${FRAGS:+"-f" ${FRAGS}}

Mainline
--------

Mainline has the same two problems, so please file a bug for sending
the fixes there and put the lore link to the mainline series into it.

The test in mainline is different: since v6.19-rc1 (d1aec26fce257
"selftests/bpf: test_xsk: Integrate test_xsk.c to test_progs
framework") most xsk tests run from test_progs, the rest stays in
test_xsk.sh. So the patches will not be a port of this one, but
please fix it now, while the details are fresh:

- test_xsk.sh creates the veth pair in the caller's namespace.
  Fix: run the veth part in a namespace of its own, as here.

- test_ns_xsk_skb and test_ns_xsk_drv (prog_tests/xsk.c) already run
  in a namespace that test_progs creates for every ns_ test. But they
  read /proc/sys/net/core/max_skb_frags from inside it, the file is
  not there, and they silently use 17.
  Fix: take the limit from vmlinux BTF, the element count of
  struct skb_shared_info.frags (btf__load_vmlinux_btf(),
  btf__find_by_name_kind(), btf_array()->nelems). It works in any
  namespace, so test_xsk.sh needs no -f option in mainline, and it is
  the limit AF_XDP really checks (see the last item below).

Suggested order: the BTF patch first, then the test_xsk.sh namespace
patch on top of it.

Not part of this series
-----------------------

I will take this series once the comments above are addressed; the
issues below are not caused by it and should not hold it. They are in
the same test though, so please file two more tasks, one for vz and
one for mainline, and fix them in both places:

- test_exit() in xsk_prereqs.sh always exits 1, so every "skip all
  tests" (no veth, no ip, no netns) is a failure for the kselftest
  runner.
  Fix: "exit $1". The callers pass $ksft_fail or $ksft_skip.
  vz and mainline.

- test_xsk.sh exits 0 when tests failed: it ends with
  "if [ $failures -eq 0 ]" without an else.
  Fix: backport 2a912258c90e8 ("selftests/bpf: Upon failures, exit
  with code 1 in test_xsk.sh", v6.18-rc1).
  vz only, mainline already has it.

- The test takes the frag limit from the max_skb_frags sysctl, but
  AF_XDP copy mode checks the compile-time MAX_SKB_FRAGS
  (xsk_build_skb() in net/xdp/xsk.c). The sysctl caps TCP and MPTCP
  only. Once an admin lowers it, too_many_frags checks the wrong
  limit.
  Fix in vz: take the limit from vmlinux BTF as described above and
  drop the -f option this series adds.
  In mainline the BTF patch above already covers it.

Please link all new bugs to VSTOR-150731.

Thanks,
Konstantin

-- 
Konstantin Khorenko,
Virtuozzo Linux Kernel Team



More information about the Devel mailing list