From nobody Tue Jun 16 08:53:49 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 84E7B3845C1 for ; Wed, 22 Apr 2026 16:20:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776874846; cv=none; b=jkCgHTmJbYJJDLcC2I6VVnc9KFBZdGC6c3E0WLD3GHUzEZijz9q9XB1ZEVGNOjxs4Aq815xy3e76faG/WpMykd2mh5DjmQ84UF8NcHgNjKFGWFBc0y9KqkZ7rV0BEXUTKqYl05Yvm95g6O5RcqSPt2/oldKPukfoV3cvVbyHZak= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776874846; c=relaxed/simple; bh=6/OMqD+59TuORkuwHoA/SFCxiAHmkdbLz9aAfiTuwLc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XkeGUE0edfCfFs4omz7kJ7Fbf3U5MZyehyFsfq1GjI8n/qHh6fnGguvHIvKXfE4gPE/ApjQXF8VMscAtnCRZYuCu+BKdujcEi/QOst1YvUUxe47E8BSTnxQiOOJvTCEY1P42Fp5BE2/SXbgphKm9G8+srblU3SdZDcsokcZe8Ns= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=SxQ4fz7N; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="SxQ4fz7N" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id D56E51A33A7; Wed, 22 Apr 2026 16:20:42 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id AA25B5FA8F; Wed, 22 Apr 2026 16:20:42 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id AE355104608C5; Wed, 22 Apr 2026 18:20:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1776874841; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=/OeQaPHqgxOT0nI16nQdUnS3gmk63KqT0dFXD3w7yZ4=; b=SxQ4fz7NUAZBTDtaJecUlJqQlga5tLD/ljcSe5zjWI5wSxT9J1Pr30P4/cmBUoHC1PDeos hFuh89yrE01a0HKZU8ypIWnpZelBMyRJt+ZxbMahAaKh3Cak+EtZ7q+LKE937zxgIkhLXW ogqG4r+UnxGqYSSB0CWXoYnFHPyHZzvkCzKEkbx2Yc+WMqj3tSlP0b/Fe+McayUlaGcx0o H8gIK1ApmgRXlGHRwLc4roq3t9OyU1jcOn5H2eU2sYad8Wdp1P7plboL0BrsJ4n0EqDR/l BfX3ZPlmoGBi8BxkoZMHqCSKg9MTMsluUogtn2RbEmRic1YeRGoDTo17AUcKDg== From: =?utf-8?q?Alexis_Lothor=C3=A9_=28eBPF_Foundation=29?= Date: Wed, 22 Apr 2026 18:20:24 +0200 Subject: [PATCH bpf-next v2 1/2] selftests/bpf: make btf_dump use xdp_dummy rather than xdping_kern Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260422-xdping-v2-1-c0f8ccedcf91@bootlin.com> References: <20260422-xdping-v2-0-c0f8ccedcf91@bootlin.com> In-Reply-To: <20260422-xdping-v2-0-c0f8ccedcf91@bootlin.com> To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Kumar Kartikeya Dwivedi , Song Liu , Yonghong Song , Jiri Olsa , Shuah Khan , "David S. Miller" , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev Cc: ebpf@linuxfoundation.org, Bastien Curutchet , Thomas Petazzoni , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, =?utf-8?q?Alexis_Lothor=C3=A9_=28eBPF_Foundation=29?= X-Mailer: b4 0.15.2 X-Last-TLS-Session-Version: TLSv1.3 In order to prepare xdping tool removal from the BPF selftests directory, make the btf_dump test use another BPF program for the btf datasec dump test. Use xdp_dummy.bpf.o, as it is already used by various other tests. Signed-off-by: Alexis Lothor=C3=A9 (eBPF Foundation) Acked-by: Paul Chaignon --- tools/testing/selftests/bpf/prog_tests/btf_dump.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/btf_dump.c b/tools/test= ing/selftests/bpf/prog_tests/btf_dump.c index f1642794f70e..9f1b50e07a29 100644 --- a/tools/testing/selftests/bpf/prog_tests/btf_dump.c +++ b/tools/testing/selftests/bpf/prog_tests/btf_dump.c @@ -1027,8 +1027,8 @@ static void test_btf_dump_datasec_data(char *str) char license[4] =3D "GPL"; struct btf_dump *d; =20 - btf =3D btf__parse("xdping_kern.bpf.o", NULL); - if (!ASSERT_OK_PTR(btf, "xdping_kern.bpf.o BTF not found")) + btf =3D btf__parse("xdp_dummy.bpf.o", NULL); + if (!ASSERT_OK_PTR(btf, "xdp_dummy.bpf.o BTF not found")) return; =20 d =3D btf_dump__new(btf, btf_dump_snprintf, str, NULL); --=20 2.53.0 From nobody Tue Jun 16 08:53:49 2026 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C61338C2DF; Wed, 22 Apr 2026 16:20:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776874848; cv=none; b=OlmdEAAn/rcoou9PRWz7VNnD7Xjos1yw8MuoXm9asVd4FRyeCfWYVPiKIystcM0cBczBKjxQ1EPtWiCcJFvmgcAtkNNIveOhn1GYYIy8wtCiYHN6lWEj0uFLpurHkVKr16h9HwRrtNyw8Oim2w+ytI3BcBxHubC5r8jeK2T4Sjc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776874848; c=relaxed/simple; bh=h3xv39jUZ/R+lfGs6ko1ajmxnX4uTAA68skLyghAfZU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=eenaOccWNTPB7V7thnysGgFWUOAhaCVT/QE9rbdybRtMSfNQa019g5ZzuUgUyvJJCltIacUCZcXXJDQ6KrNK4X1pU+pAIYb0GCzW5+lLH2CuLo8gBFJa4zfmkGf/XBA1DK61bSxzTeZQNfGCTmATGc/CPLqYJ1YZPy12ssRpJR8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=eA5OjckL; arc=none smtp.client-ip=185.171.202.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="eA5OjckL" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 365FAC5B1BE; Wed, 22 Apr 2026 16:21:26 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 553775FA8F; Wed, 22 Apr 2026 16:20:45 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id EB9AF10460BF0; Wed, 22 Apr 2026 18:20:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1776874844; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=Q3PA2FXpnk6YdWcpbs4KcZaHnJZnOtGX1Ufqkx8Nrns=; b=eA5OjckLYd+do2birui7IIshr7p50dsHtGqbEqskX7Vj1bRcCNx2wzr/yukAHaBfg4DTJi dwqXoVCSK11kEK1Zj8gMbXS3V1lKqTh1xWcTLolDd8SIS+7xC4QuMcElEyXF2LPDqCSDxd SAFrlfbtDIYaTk0MWrBRslV5CD+NY0nhl5M0Qo6CZ7RBXYN0q1gT5+2QJuaQ5j88Klqyxp uV8v95DTg8J9D5e9nW070pfWaKJZJG5pvmA+K1pAS1hYHzpwhqYzfYKJ7POUzwUe1Yprks pyTq9MCTjD54Xwd8XcC1D04eJsbsCJcF7jWevkv1GGwleYsSPByBbe+3C8HdSg== From: =?utf-8?q?Alexis_Lothor=C3=A9_=28eBPF_Foundation=29?= Date: Wed, 22 Apr 2026 18:20:25 +0200 Subject: [PATCH bpf-next v2 2/2] selftests/bpf: drop xdping tool Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260422-xdping-v2-2-c0f8ccedcf91@bootlin.com> References: <20260422-xdping-v2-0-c0f8ccedcf91@bootlin.com> In-Reply-To: <20260422-xdping-v2-0-c0f8ccedcf91@bootlin.com> To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Kumar Kartikeya Dwivedi , Song Liu , Yonghong Song , Jiri Olsa , Shuah Khan , "David S. Miller" , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev Cc: ebpf@linuxfoundation.org, Bastien Curutchet , Thomas Petazzoni , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, =?utf-8?q?Alexis_Lothor=C3=A9_=28eBPF_Foundation=29?= , Alan Maguire X-Mailer: b4 0.15.2 X-Last-TLS-Session-Version: TLSv1.3 As part of a larger cleanup effort in the bpf selftests directory, tests and scripts are either being converted to the test_progs framework (so they are executed automatically in bpf CI), or removed if not relevant for such integration. The test_xdping.sh script (with the associated xdping.c) acts as a RTT measurement tool, by attaching two small xdp programs to two interfaces. Converting this test to test_progs may not make much sense: - RTT measurement does not really fit in the scope of a functional test, this is rather about measuring some performance level. - there are other existing tests in test_progs that actively validate XDP features like program attachment, return value processing, packet modification, etc Drop test_xdping.sh, the corresponding xdping.c userspace part, the xdping_kern.c program, and the shared header, xdping.h Signed-off-by: Alexis Lothor=C3=A9 (eBPF Foundation) Reviewed-by: Alan Maguire Acked-by: Paul Chaignon --- tools/testing/selftests/bpf/.gitignore | 1 - tools/testing/selftests/bpf/Makefile | 3 - tools/testing/selftests/bpf/progs/xdping_kern.c | 183 ----------------- tools/testing/selftests/bpf/test_xdping.sh | 103 ---------- tools/testing/selftests/bpf/xdping.c | 254 --------------------= ---- tools/testing/selftests/bpf/xdping.h | 13 -- 6 files changed, 557 deletions(-) diff --git a/tools/testing/selftests/bpf/.gitignore b/tools/testing/selftes= ts/bpf/.gitignore index bfdc5518ecc8..986a6389186b 100644 --- a/tools/testing/selftests/bpf/.gitignore +++ b/tools/testing/selftests/bpf/.gitignore @@ -21,7 +21,6 @@ test_lirc_mode2_user flow_dissector_load test_tcpnotify_user test_libbpf -xdping test_cpp *.d *.subskel.h diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests= /bpf/Makefile index 78e60040811e..00a986a7d088 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -111,7 +111,6 @@ TEST_FILES =3D xsk_prereqs.sh $(wildcard progs/btf_dump= _test_case_*.c) # Order correspond to 'make run_tests' order TEST_PROGS :=3D test_kmod.sh \ test_lirc_mode2.sh \ - test_xdping.sh \ test_bpftool_build.sh \ test_doc_build.sh \ test_xsk.sh \ @@ -134,7 +133,6 @@ TEST_GEN_PROGS_EXTENDED =3D \ xdp_features \ xdp_hw_metadata \ xdp_synproxy \ - xdping \ xskxceiver =20 TEST_GEN_FILES +=3D $(TEST_KMODS) liburandom_read.so urandom_read sign-fil= e uprobe_multi @@ -320,7 +318,6 @@ $(OUTPUT)/test_tcpnotify_user: $(CGROUP_HELPERS) $(TEST= ING_HELPERS) $(TRACE_HELP $(OUTPUT)/test_sock_fields: $(CGROUP_HELPERS) $(TESTING_HELPERS) $(OUTPUT)/test_tag: $(TESTING_HELPERS) $(OUTPUT)/test_lirc_mode2_user: $(TESTING_HELPERS) -$(OUTPUT)/xdping: $(TESTING_HELPERS) $(OUTPUT)/flow_dissector_load: $(TESTING_HELPERS) $(OUTPUT)/test_maps: $(TESTING_HELPERS) $(OUTPUT)/test_verifier: $(TESTING_HELPERS) $(CAP_HELPERS) $(UNPRIV_HELPER= S) diff --git a/tools/testing/selftests/bpf/progs/xdping_kern.c b/tools/testin= g/selftests/bpf/progs/xdping_kern.c deleted file mode 100644 index 44e2b0ef23ae..000000000000 --- a/tools/testing/selftests/bpf/progs/xdping_kern.c +++ /dev/null @@ -1,183 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. = */ - -#define KBUILD_MODNAME "foo" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "bpf_compiler.h" -#include "xdping.h" - -struct { - __uint(type, BPF_MAP_TYPE_HASH); - __uint(max_entries, 256); - __type(key, __u32); - __type(value, struct pinginfo); -} ping_map SEC(".maps"); - -static __always_inline void swap_src_dst_mac(void *data) -{ - unsigned short *p =3D data; - unsigned short dst[3]; - - dst[0] =3D p[0]; - dst[1] =3D p[1]; - dst[2] =3D p[2]; - p[0] =3D p[3]; - p[1] =3D p[4]; - p[2] =3D p[5]; - p[3] =3D dst[0]; - p[4] =3D dst[1]; - p[5] =3D dst[2]; -} - -static __always_inline __u16 csum_fold_helper(__wsum sum) -{ - sum =3D (sum & 0xffff) + (sum >> 16); - return ~((sum & 0xffff) + (sum >> 16)); -} - -static __always_inline __u16 ipv4_csum(void *data_start, int data_size) -{ - __wsum sum; - - sum =3D bpf_csum_diff(0, 0, data_start, data_size, 0); - return csum_fold_helper(sum); -} - -#define ICMP_ECHO_LEN 64 - -static __always_inline int icmp_check(struct xdp_md *ctx, int type) -{ - void *data_end =3D (void *)(long)ctx->data_end; - void *data =3D (void *)(long)ctx->data; - struct ethhdr *eth =3D data; - struct icmphdr *icmph; - struct iphdr *iph; - - if (data + sizeof(*eth) + sizeof(*iph) + ICMP_ECHO_LEN > data_end) - return XDP_PASS; - - if (eth->h_proto !=3D bpf_htons(ETH_P_IP)) - return XDP_PASS; - - iph =3D data + sizeof(*eth); - - if (iph->protocol !=3D IPPROTO_ICMP) - return XDP_PASS; - - if (bpf_ntohs(iph->tot_len) - sizeof(*iph) !=3D ICMP_ECHO_LEN) - return XDP_PASS; - - icmph =3D data + sizeof(*eth) + sizeof(*iph); - - if (icmph->type !=3D type) - return XDP_PASS; - - return XDP_TX; -} - -SEC("xdp") -int xdping_client(struct xdp_md *ctx) -{ - void *data =3D (void *)(long)ctx->data; - struct pinginfo *pinginfo =3D NULL; - struct ethhdr *eth =3D data; - struct icmphdr *icmph; - struct iphdr *iph; - __u64 recvtime; - __be32 raddr; - __be16 seq; - int ret; - __u8 i; - - ret =3D icmp_check(ctx, ICMP_ECHOREPLY); - - if (ret !=3D XDP_TX) - return ret; - - iph =3D data + sizeof(*eth); - icmph =3D data + sizeof(*eth) + sizeof(*iph); - raddr =3D iph->saddr; - - /* Record time reply received. */ - recvtime =3D bpf_ktime_get_ns(); - pinginfo =3D bpf_map_lookup_elem(&ping_map, &raddr); - if (!pinginfo || pinginfo->seq !=3D icmph->un.echo.sequence) - return XDP_PASS; - - if (pinginfo->start) { - __pragma_loop_unroll_full - for (i =3D 0; i < XDPING_MAX_COUNT; i++) { - if (pinginfo->times[i] =3D=3D 0) - break; - } - /* verifier is fussy here... */ - if (i < XDPING_MAX_COUNT) { - pinginfo->times[i] =3D recvtime - - pinginfo->start; - pinginfo->start =3D 0; - i++; - } - /* No more space for values? */ - if (i =3D=3D pinginfo->count || i =3D=3D XDPING_MAX_COUNT) - return XDP_PASS; - } - - /* Now convert reply back into echo request. */ - swap_src_dst_mac(data); - iph->saddr =3D iph->daddr; - iph->daddr =3D raddr; - icmph->type =3D ICMP_ECHO; - seq =3D bpf_htons(bpf_ntohs(icmph->un.echo.sequence) + 1); - icmph->un.echo.sequence =3D seq; - icmph->checksum =3D 0; - icmph->checksum =3D ipv4_csum(icmph, ICMP_ECHO_LEN); - - pinginfo->seq =3D seq; - pinginfo->start =3D bpf_ktime_get_ns(); - - return XDP_TX; -} - -SEC("xdp") -int xdping_server(struct xdp_md *ctx) -{ - void *data =3D (void *)(long)ctx->data; - struct ethhdr *eth =3D data; - struct icmphdr *icmph; - struct iphdr *iph; - __be32 raddr; - int ret; - - ret =3D icmp_check(ctx, ICMP_ECHO); - - if (ret !=3D XDP_TX) - return ret; - - iph =3D data + sizeof(*eth); - icmph =3D data + sizeof(*eth) + sizeof(*iph); - raddr =3D iph->saddr; - - /* Now convert request into echo reply. */ - swap_src_dst_mac(data); - iph->saddr =3D iph->daddr; - iph->daddr =3D raddr; - icmph->type =3D ICMP_ECHOREPLY; - icmph->checksum =3D 0; - icmph->checksum =3D ipv4_csum(icmph, ICMP_ECHO_LEN); - - return XDP_TX; -} - -char _license[] SEC("license") =3D "GPL"; diff --git a/tools/testing/selftests/bpf/test_xdping.sh b/tools/testing/sel= ftests/bpf/test_xdping.sh deleted file mode 100755 index c3d82e0a7378..000000000000 --- a/tools/testing/selftests/bpf/test_xdping.sh +++ /dev/null @@ -1,103 +0,0 @@ -#!/bin/bash -# SPDX-License-Identifier: GPL-2.0 - -# xdping tests -# Here we setup and teardown configuration required to run -# xdping, exercising its options. -# -# Setup is similar to test_tunnel tests but without the tunnel. -# -# Topology: -# --------- -# root namespace | tc_ns0 namespace -# | -# ---------- | ---------- -# | veth1 | --------- | veth0 | -# ---------- peer ---------- -# -# Device Configuration -# -------------------- -# Root namespace with BPF -# Device names and addresses: -# veth1 IP: 10.1.1.200 -# xdp added to veth1, xdpings originate from here. -# -# Namespace tc_ns0 with BPF -# Device names and addresses: -# veth0 IPv4: 10.1.1.100 -# For some tests xdping run in server mode here. -# - -readonly TARGET_IP=3D"10.1.1.100" -readonly TARGET_NS=3D"xdp_ns0" - -readonly LOCAL_IP=3D"10.1.1.200" - -setup() -{ - ip netns add $TARGET_NS - ip link add veth0 type veth peer name veth1 - ip link set veth0 netns $TARGET_NS - ip netns exec $TARGET_NS ip addr add ${TARGET_IP}/24 dev veth0 - ip addr add ${LOCAL_IP}/24 dev veth1 - ip netns exec $TARGET_NS ip link set veth0 up - ip link set veth1 up -} - -cleanup() -{ - set +e - ip netns delete $TARGET_NS 2>/dev/null - ip link del veth1 2>/dev/null - if [[ $server_pid -ne 0 ]]; then - kill -TERM $server_pid - fi -} - -test() -{ - client_args=3D"$1" - server_args=3D"$2" - - echo "Test client args '$client_args'; server args '$server_args'" - - server_pid=3D0 - if [[ -n "$server_args" ]]; then - ip netns exec $TARGET_NS ./xdping $server_args & - server_pid=3D$! - sleep 10 - fi - ./xdping $client_args $TARGET_IP - - if [[ $server_pid -ne 0 ]]; then - kill -TERM $server_pid - server_pid=3D0 - fi - - echo "Test client args '$client_args'; server args '$server_args': PASS" -} - -set -e - -server_pid=3D0 - -trap cleanup EXIT - -setup - -for server_args in "" "-I veth0 -s -S" ; do - # client in skb mode - client_args=3D"-I veth1 -S" - test "$client_args" "$server_args" - - # client with count of 10 RTT measurements. - client_args=3D"-I veth1 -S -c 10" - test "$client_args" "$server_args" -done - -# Test drv mode -test "-I veth1 -N" "-I veth0 -s -N" -test "-I veth1 -N -c 10" "-I veth0 -s -N" - -echo "OK. All tests passed" -exit 0 diff --git a/tools/testing/selftests/bpf/xdping.c b/tools/testing/selftests= /bpf/xdping.c deleted file mode 100644 index 9ed8c796645d..000000000000 --- a/tools/testing/selftests/bpf/xdping.c +++ /dev/null @@ -1,254 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. = */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "bpf/bpf.h" -#include "bpf/libbpf.h" - -#include "xdping.h" -#include "testing_helpers.h" - -static int ifindex; -static __u32 xdp_flags =3D XDP_FLAGS_UPDATE_IF_NOEXIST; - -static void cleanup(int sig) -{ - bpf_xdp_detach(ifindex, xdp_flags, NULL); - if (sig) - exit(1); -} - -static int get_stats(int fd, __u16 count, __u32 raddr) -{ - struct pinginfo pinginfo =3D { 0 }; - char inaddrbuf[INET_ADDRSTRLEN]; - struct in_addr inaddr; - __u16 i; - - inaddr.s_addr =3D raddr; - - printf("\nXDP RTT data:\n"); - - if (bpf_map_lookup_elem(fd, &raddr, &pinginfo)) { - perror("bpf_map_lookup elem"); - return 1; - } - - for (i =3D 0; i < count; i++) { - if (pinginfo.times[i] =3D=3D 0) - break; - - printf("64 bytes from %s: icmp_seq=3D%d ttl=3D64 time=3D%#.5f ms\n", - inet_ntop(AF_INET, &inaddr, inaddrbuf, - sizeof(inaddrbuf)), - count + i + 1, - (double)pinginfo.times[i]/1000000); - } - - if (i < count) { - fprintf(stderr, "Expected %d samples, got %d.\n", count, i); - return 1; - } - - bpf_map_delete_elem(fd, &raddr); - - return 0; -} - -static void show_usage(const char *prog) -{ - fprintf(stderr, - "usage: %s [OPTS] -I interface destination\n\n" - "OPTS:\n" - " -c count Stop after sending count requests\n" - " (default %d, max %d)\n" - " -I interface interface name\n" - " -N Run in driver mode\n" - " -s Server mode\n" - " -S Run in skb mode\n", - prog, XDPING_DEFAULT_COUNT, XDPING_MAX_COUNT); -} - -int main(int argc, char **argv) -{ - __u32 mode_flags =3D XDP_FLAGS_DRV_MODE | XDP_FLAGS_SKB_MODE; - struct addrinfo *a, hints =3D { .ai_family =3D AF_INET }; - __u16 count =3D XDPING_DEFAULT_COUNT; - struct pinginfo pinginfo =3D { 0 }; - const char *optstr =3D "c:I:NsS"; - struct bpf_program *main_prog; - int prog_fd =3D -1, map_fd =3D -1; - struct sockaddr_in rin; - struct bpf_object *obj; - struct bpf_map *map; - char *ifname =3D NULL; - char filename[256]; - int opt, ret =3D 1; - __u32 raddr =3D 0; - int server =3D 0; - char cmd[256]; - - while ((opt =3D getopt(argc, argv, optstr)) !=3D -1) { - switch (opt) { - case 'c': - count =3D atoi(optarg); - if (count < 1 || count > XDPING_MAX_COUNT) { - fprintf(stderr, - "min count is 1, max count is %d\n", - XDPING_MAX_COUNT); - return 1; - } - break; - case 'I': - ifname =3D optarg; - ifindex =3D if_nametoindex(ifname); - if (!ifindex) { - fprintf(stderr, "Could not get interface %s\n", - ifname); - return 1; - } - break; - case 'N': - xdp_flags |=3D XDP_FLAGS_DRV_MODE; - break; - case 's': - /* use server program */ - server =3D 1; - break; - case 'S': - xdp_flags |=3D XDP_FLAGS_SKB_MODE; - break; - default: - show_usage(basename(argv[0])); - return 1; - } - } - - if (!ifname) { - show_usage(basename(argv[0])); - return 1; - } - if (!server && optind =3D=3D argc) { - show_usage(basename(argv[0])); - return 1; - } - - if ((xdp_flags & mode_flags) =3D=3D mode_flags) { - fprintf(stderr, "-N or -S can be specified, not both.\n"); - show_usage(basename(argv[0])); - return 1; - } - - if (!server) { - /* Only supports IPv4; see hints initialization above. */ - if (getaddrinfo(argv[optind], NULL, &hints, &a) || !a) { - fprintf(stderr, "Could not resolve %s\n", argv[optind]); - return 1; - } - memcpy(&rin, a->ai_addr, sizeof(rin)); - raddr =3D rin.sin_addr.s_addr; - freeaddrinfo(a); - } - - /* Use libbpf 1.0 API mode */ - libbpf_set_strict_mode(LIBBPF_STRICT_ALL); - - snprintf(filename, sizeof(filename), "%s_kern.bpf.o", argv[0]); - - if (bpf_prog_test_load(filename, BPF_PROG_TYPE_XDP, &obj, &prog_fd)) { - fprintf(stderr, "load of %s failed\n", filename); - return 1; - } - - main_prog =3D bpf_object__find_program_by_name(obj, - server ? "xdping_server" : "xdping_client"); - if (main_prog) - prog_fd =3D bpf_program__fd(main_prog); - if (!main_prog || prog_fd < 0) { - fprintf(stderr, "could not find xdping program"); - return 1; - } - - map =3D bpf_object__next_map(obj, NULL); - if (map) - map_fd =3D bpf_map__fd(map); - if (!map || map_fd < 0) { - fprintf(stderr, "Could not find ping map"); - goto done; - } - - signal(SIGINT, cleanup); - signal(SIGTERM, cleanup); - - printf("Setting up XDP for %s, please wait...\n", ifname); - - printf("XDP setup disrupts network connectivity, hit Ctrl+C to quit\n"); - - if (bpf_xdp_attach(ifindex, prog_fd, xdp_flags, NULL) < 0) { - fprintf(stderr, "Link set xdp fd failed for %s\n", ifname); - goto done; - } - - if (server) { - close(prog_fd); - close(map_fd); - printf("Running server on %s; press Ctrl+C to exit...\n", - ifname); - do { } while (1); - } - - /* Start xdping-ing from last regular ping reply, e.g. for a count - * of 10 ICMP requests, we start xdping-ing using reply with seq number - * 10. The reason the last "real" ping RTT is much higher is that - * the ping program sees the ICMP reply associated with the last - * XDP-generated packet, so ping doesn't get a reply until XDP is done. - */ - pinginfo.seq =3D htons(count); - pinginfo.count =3D count; - - if (bpf_map_update_elem(map_fd, &raddr, &pinginfo, BPF_ANY)) { - fprintf(stderr, "could not communicate with BPF map: %s\n", - strerror(errno)); - cleanup(0); - goto done; - } - - /* We need to wait for XDP setup to complete. */ - sleep(10); - - snprintf(cmd, sizeof(cmd), "ping -c %d -I %s %s", - count, ifname, argv[optind]); - - printf("\nNormal ping RTT data\n"); - printf("[Ignore final RTT; it is distorted by XDP using the reply]\n"); - - ret =3D system(cmd); - - if (!ret) - ret =3D get_stats(map_fd, count, raddr); - - cleanup(0); - -done: - if (prog_fd > 0) - close(prog_fd); - if (map_fd > 0) - close(map_fd); - - return ret; -} diff --git a/tools/testing/selftests/bpf/xdping.h b/tools/testing/selftests= /bpf/xdping.h deleted file mode 100644 index afc578df77be..000000000000 --- a/tools/testing/selftests/bpf/xdping.h +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. = */ - -#define XDPING_MAX_COUNT 10 -#define XDPING_DEFAULT_COUNT 4 - -struct pinginfo { - __u64 start; - __be16 seq; - __u16 count; - __u32 pad; - __u64 times[XDPING_MAX_COUNT]; -}; --=20 2.53.0