From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (mail.openvz.org [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id CE21480474 for ; Mon, 26 Oct 2026 01:25:30 +0000 (UTC) Received: from mail.openvz.org (localhost [127.0.0.1]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 69Q1NEfS032276; Mon, 26 Oct 2026 04:23:15 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 69Q1NEfS032276 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="Wll/LJfl" Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 69Q1NC2u032268 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Mon, 26 Oct 2026 04:23:12 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 69Q1NC2u032268 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-48e011829easo1922835f8f.3 for ; Sun, 25 Oct 2026 18:23:12 -0700 (PDT) X-Gm-Message-State: AFq9FYKurpYZrDqFWSC4NnS0nizeLBD2NZv/71bOwXzQXZOkhuTX9FME J9N9hJAdlf8XKzfO5eFleytvpagXyG8QVxnCvwfKahopbbsoejVAq5zjvjQi3CHVu8JeFU/LMp8 KwMLh9LVUouhj7j0bjLCCLBsKXeHRJ9Hm7EN9B3zamY7jA1rxegJx2w== X-Gm-Gg: AYBFou1cq8WVtZGDlp2fDCZ+pAvW4TvzwgNsEMF/k8PznbbArj9obHaKKkMYqWBxMpV IsFFy9/q7teUyhF83iS1fjhA/4T/nCEn1BEWA64RfVejlXmfr0Ys7VOtg8AQcve5IEX/sX+pfvS kANihiVfeSvDtG6E7PCudCdGAMCy+UJfhIX2DNalqCBCs7+/GAwBO7KbLnsEJ5pTcEXbPCk3hjP UthtSAmw/3R1ejcxNLTYJNQQSVh9e7AdNSU9dyX+zJr9qiNZIai2rfkF7LNmz4oamGNSx/T7QrG CphoiH7E2UTj7S5JYTNEl+PZwuPTHlQV6IOIFK75XopAWeWruHiNBB9/L7sumHJIAzS41ARr9QH enyTpGF9kMfjJcjK2mi+sfLdCfA== X-Received: by 2002:a05:6000:46c8:b0:48d:ed30:f863 with SMTP id ffacd0b85a97d-48e3eb8dafemr5512999f8f.30.1792977792437; Sun, 25 Oct 2026 18:23:12 -0700 (PDT) X-Received: by 2002:a05:6000:46c8:b0:48d:ed30:f863 with SMTP id ffacd0b85a97d-48e3eb8dafemr5512979f8f.30.1792977791939; Sun, 25 Oct 2026 18:23:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1792977791; cv=none; d=google.com; s=arc-20260327; b=jn/3iCxL+NAKJV7IwdiKmmJjP04xyBMVOfWNfpPV8CajxrElY6oiBC9fYb9OvKzJIW GlAFxg4Hjq5DL7gz8IAoQkmljJ2BTlmj1ksgt5LpAgwu+wVMOlBmbVynqRgiqPS+w/Bx 5oUYyYOFfbLv9XBKa5w/OfW7cPN5yxboPiFXAncpmyohij/hQnb+WyNX+UZg9lKAleTS UP8fESr5QyEJhIekDydzfpCY9sQAvGXw3P1cstxuCV/Qcoe9OUpSGhqOa+XeHNPKOsZ0 e6jBWQkQuaxN2t1ORLyZsa64JrktdJ2zRg5FTp1165N0bk+KoIoyICnQcekR9KG7R6H3 +W/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=oqmMC/euZIm4ne4noC9akGE5NveSFgtLdslLvznVy8I=; fh=WpT6aB7RBAGHZeWZzqAr71yzRFbPTYkPWKsRagLn48Q=; b=emTMP86vdpfoXWUasFakIcMDuHlHhxVboqxRh5h6y7Z03DjtdcGDaItxXl6ppnV4fw fqWDN7Yxe39Y+86LeRVdQhVQXXErbUwwy3A62Kr2d1rDWluF32xaSKwEWFvxrdEkbLT/ wI/9P54B3kUpwQRjTmD2TDY4JxtXfrYpcIxjgr7unNTgw+OmBVnIrx5CsNOj7pVtcTIk p4zHiIa+5lYt06j+uHcWax1AthQtk/B9dpI1PCzA3JL0+cmdnzGHmivZdfWWQhBs5kf1 Wrg872xc/ulyqqaKkRosKsfA2ILHNHOfZ3NYKExznvpaAYaSnLei0GA+vn+jUIIY6diU 3R8Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b="Wll/LJfl"; spf=pass (google.com: domain of eva.kurchatova@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=eva.kurchatova@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Received: from relay.virtuozzo.com (relay.virtuozzo.com. [130.117.225.111]) by mx.google.com with ESMTPS id ffacd0b85a97d-48e3ecf93ffsi10747147f8f.266.2026.10.25.18.23.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Oct 2026 18:23:11 -0700 (PDT) Received-SPF: pass (google.com: domain of eva.kurchatova@virtuozzo.com designates 130.117.225.111 as permitted sender) client-ip=130.117.225.111; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b="Wll/LJfl"; spf=pass (google.com: domain of eva.kurchatova@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=eva.kurchatova@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-ID:Date:Subject:From: Content-Type; bh=oqmMC/euZIm4ne4noC9akGE5NveSFgtLdslLvznVy8I=; b=Wll/LJflkqNw wRk7+md9bJcFGxZrnAG4k1YlRtesvvB2jc0DR3R94wFPI5xy4pr8xMfB7DZ6LvzWprsySJu8HCvRn v1AszEVhvrEKd9x/LhCti1chwt0bCJGoZKhbhvxJag7pDU629OUbo1AEXEB+5ZA/aAIw9yCOE7R5i zzfoNtT/VM4Uv9+UZ5NbyDLhPMzlIbJPL4uxcR/tUE+OwE9DWjSFeYwh1y1pbt3Fp+A6qeufjRSr9 ExUkk1w+ZF74UQEDj8yuw+pVbJPb4ow2g2dgAXsm/V7sKmeJbmIVkmp6ccCm5BBPlXYNi1IAgPgTv VgeYsuH4ZXSNb0Gadr5lLg==; Received: from ch-vpn.virtuozzo.com ([130.117.225.6] helo=LekKit-T14) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1xL9Mv-0076wY-0n; Mon, 26 Oct 2026 02:23:04 +0100 From: Eva Kurchatova To: khorenko@virtuozzo.com Date: Mon, 26 Oct 2026 03:22:39 +0200 Message-ID: <20261026012309.458048-2-eva.kurchatova@virtuozzo.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261026012309.458048-1-eva.kurchatova@virtuozzo.com> References: <20261026012309.458048-1-eva.kurchatova@virtuozzo.com> MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.1 v3 1/1] selftests/bpf: run the xsk veth tests in a network namespace of their own X-BeenThere: devel@openvz.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: OpenVZ development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: devel-bounces@openvz.org Errors-To: devel-bounces@openvz.org test_xsk.sh makes its veth pair in the namespace it runs in. Whatever the host does with a new interface, address configuration, neighbour discovery, happens on that pair, and the AF_XDP sockets under test receive the host's packets among their own. The tests count and inspect what they receive, so a preconfigured host fails some of them in every mode, and a bare one passes. Run the veth part in an unnamed network namespace with its own sysfs, which drops with its last process whenever the run ends. only -d names it, its pair outlives the run. The fragment limit came from the sysctl max_skb_frags, which has no file outside the initial namespace. Take it from the kernel's BTF as the size of skb_shared_info's frags array, fall back to sysctl as before if this info is missing. When the namespace can't be created, the tests are skipped, as without veth or ip. Other cases after a successful namespace creation fail. Fix test_exit() return status for skips, as since commit 895b62eed2ab ("selftests: xsk: fix reporting of failed tests"), test_exit() exited 1. https://virtuozzo.atlassian.net/browse/VSTOR-150731 Feature: fix selftests Signed-off-by: Eva Kurchatova --- 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(-) diff --git a/tools/testing/selftests/bpf/test_xsk.sh b/tools/testing/selftests/bpf/test_xsk.sh index 65aafe0003db..218528ddcdf8 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 --make-rprivate / && 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=$? diff --git a/tools/testing/selftests/bpf/xsk_prereqs.sh b/tools/testing/selftests/bpf/xsk_prereqs.sh index 47c7b8064f38..12176d85cd6c 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() diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/bpf/xskxceiver.c index 11f047b8af75..a4a0b4e2516c 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 +#include #include #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.56.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel