From nobody Mon Feb 9 06:27:02 2026 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (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 A45CA2E8E00; Fri, 31 Oct 2025 15:55:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761926129; cv=none; b=es79UgZ6amLCI8F0ZMDI1huwcGaMnT5mMkjiYXnar3kx1/LOk7VX6wWWiMHo/GtiHVg032Z5sYguu7/mMBHy7H4pSUoC1TgSf8SMzhWvzkpCO6j1UjCTxXoRrAmatI/oSeXkyIWm0EF3akWkPDvkShJdidZ9CT+2HOAiFNAtYpA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761926129; c=relaxed/simple; bh=y2YwLjlXI824LBCVKOlkoBk28o/Z3o0tUlA3oxiFcls=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=g40EZ/DX7Z63i4FInl3JollxA3GlP6WrybhChKjpYWMRnRA7WTahLTGycx3RGphmXA9e/Aiwu6rLr4YRqFHY7BBNhBdwHtahayF9cqEwQ2v6KqCh/f9Ir984dOUvnxRzX3gGrZ1xXbyQ82/89FiwrvpPvWhov6W6KgbU6K+yNdI= 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=tJ177pes; arc=none smtp.client-ip=185.246.85.4 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="tJ177pes" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 24A904E41443; Fri, 31 Oct 2025 15:55:26 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id F070360704; Fri, 31 Oct 2025 15:55:25 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 1900311818066; Fri, 31 Oct 2025 16:55:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1761926124; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=/YT+5ajEU6aJJ0lNTYWkpsrNNaSWfDxnF665EcKg6Ps=; b=tJ177pesqVpr6TGY/EWGhD8qeHlt7oyipPaVrVN6xBon/QwqHvdv4gEVBVoA6OkNJJYDs0 6w3MJPrKuRALBFAcwICxNt9IukAWROCNss1J4WgTfu/b+t/0yiC1rtkFC5opV/kupQ+8Az zq82gHlANAxaqYdWeVVSRMiD5QqYozhkQGMp8UjlT0ZaSci5WBsunosZPFsza/9GXovJJm LUJCXjjxZlJndvw0M2LGjUoxe1h6ctXZOrEAvXwKCpBn880ZQ9/2d6YVo0l1tdOnVM6XXy LdOB9Q3mz2qTQCn3ohle4wCTmT2wxHpjNZG8NfkF3tBPa1ewVYH28HyZO96OJg== From: =?utf-8?q?Alexis_Lothor=C3=A9_=28eBPF_Foundation=29?= Date: Fri, 31 Oct 2025 16:55:13 +0100 Subject: [PATCH bpf-next 1/4] selftests/bpf: rename test_tc_edt.bpf.c section to expose program type 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: <20251031-tc_edt-v1-1-5d34a5823144@bootlin.com> References: <20251031-tc_edt-v1-0-5d34a5823144@bootlin.com> In-Reply-To: <20251031-tc_edt-v1-0-5d34a5823144@bootlin.com> To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan Cc: ebpf@linuxfoundation.org, Bastien Curutchet , Thomas Petazzoni , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Alexis_Lothor=C3=A9_=28eBPF_Foundation=29?= X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 The test_tc_edt BPF program uses a custom section name, which works fine when manually loading it with tc, but prevents it from being loaded with libbpf. Update the program section name to "tc" to be able to manipulate it with a libbpf-based C test. Signed-off-by: Alexis Lothor=C3=A9 (eBPF Foundation) --- tools/testing/selftests/bpf/progs/test_tc_edt.c | 3 ++- tools/testing/selftests/bpf/test_tc_edt.sh | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/bpf/progs/test_tc_edt.c b/tools/testin= g/selftests/bpf/progs/test_tc_edt.c index 950a70b61e74..9b80109d5c3d 100644 --- a/tools/testing/selftests/bpf/progs/test_tc_edt.c +++ b/tools/testing/selftests/bpf/progs/test_tc_edt.c @@ -99,7 +99,8 @@ static inline int handle_ipv4(struct __sk_buff *skb) return TC_ACT_OK; } =20 -SEC("cls_test") int tc_prog(struct __sk_buff *skb) +SEC("tc") +int tc_prog(struct __sk_buff *skb) { if (skb->protocol =3D=3D bpf_htons(ETH_P_IP)) return handle_ipv4(skb); diff --git a/tools/testing/selftests/bpf/test_tc_edt.sh b/tools/testing/sel= ftests/bpf/test_tc_edt.sh index 76f0bd17061f..8db8e146a431 100755 --- a/tools/testing/selftests/bpf/test_tc_edt.sh +++ b/tools/testing/selftests/bpf/test_tc_edt.sh @@ -55,7 +55,7 @@ ip -netns ${NS_DST} route add ${IP_SRC}/32 dev veth_dst ip netns exec ${NS_SRC} tc qdisc add dev veth_src root fq ip netns exec ${NS_SRC} tc qdisc add dev veth_src clsact ip netns exec ${NS_SRC} tc filter add dev veth_src egress \ - bpf da obj ${BPF_FILE} sec cls_test + bpf da obj ${BPF_FILE} sec tc =20 =20 # start the listener --=20 2.51.1.dirty From nobody Mon Feb 9 06:27:03 2026 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (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 318EC2EFDAD; Fri, 31 Oct 2025 15:55:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761926132; cv=none; b=JUBbDqO3fJ1DF4RTbWqOkz6Dvm3e5Z0JvpwH0kbGoik/CuA4/7+/JhrxfZrjk1pHCRB12S8LIQArzzCBaoWcI6O0sF/9tPybuprI2qeCV2BEZ1mgEjslECsmCHLIpQzsCv93tiPZBw6m0gR8UpklIr0xjiMM+Mkkahpf16KS7vg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761926132; c=relaxed/simple; bh=Rjz9f+zKWciMlcVM4p3FuUpxQ8Eh8F7OuM38t7syijM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZcCgiKS2Y6x9JznauK26AfdjwPIVI6yQLDzZzB74rlKiqoOf7+GdWwNKqWdaO4pTNfm9hDijF+SoleQ8BmQarVSjQ02h7hR4ddB1EWqK6oopWGUJ643GPE+489nA2biylooI03AiRvuNjE/4klkYXxQAY4rflb9a6Dq50oVDKMQ= 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=0ZA7ywlZ; arc=none smtp.client-ip=185.246.85.4 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="0ZA7ywlZ" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 6D0544E41444; Fri, 31 Oct 2025 15:55:28 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 4398160704; Fri, 31 Oct 2025 15:55:28 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 3C5C811818065; Fri, 31 Oct 2025 16:55:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1761926127; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=ww1SYMReWRHpDPvJMI1j1ibpe2gLb3Y94LUqpUX4nY8=; b=0ZA7ywlZdnnl673iMMOsnrHxSlQOgwX7N44ScitXm7xgrsu0arA6BMdwbDV42UnrHsEpHB RecfOAZfoOb2Yr4RgpT4hMj+JB0JGA+jvxPXgpcHImUZK0GDC1oal+hFrSTQTKPhvx4c5F Goz6V7IsUt05Q1hbbwZ8qE2kypkVV5EhTP1YxtUO+kM657ZZ2OLViLETlUj0rlhWZCuqN0 nBQCOzzEYILqpesCklkIYUmh4sA3lWO63KeMTCdy+EjxUpk8d646fLpxD4Oooh+z4NlK2x CvhhydVpX60NjZlKll36LxwxVqgvJNwFawR7kgGtRvi2oep9c4qmHT/GacQLLA== From: =?utf-8?q?Alexis_Lothor=C3=A9_=28eBPF_Foundation=29?= Date: Fri, 31 Oct 2025 16:55:14 +0100 Subject: [PATCH bpf-next 2/4] selftests/bpf: integrate test_tc_edt into test_progs 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: <20251031-tc_edt-v1-2-5d34a5823144@bootlin.com> References: <20251031-tc_edt-v1-0-5d34a5823144@bootlin.com> In-Reply-To: <20251031-tc_edt-v1-0-5d34a5823144@bootlin.com> To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan Cc: ebpf@linuxfoundation.org, Bastien Curutchet , Thomas Petazzoni , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Alexis_Lothor=C3=A9_=28eBPF_Foundation=29?= X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 test_tc_edt.sh uses a pair of veth and a BPF program attached to the TX veth to shape the traffic to 5Mbps. It then checks that the amount of received bytes (at interface level), compared to the TX duration, indeed matches 5Mbps. Convert this test script to the test_progs framework: - keep the double veth setup, isolated in two veths - run a small tcp server, and connect client to server - start pushing bytes continuously, but for a shorter period of time than the original test (to keep CI run duration tolerable) - measure the number or received bytes through /proc/net/dev, compute the resulting rate - ensure that this rate is in a 2% error margin around the target rate This two percent value, while being tight, is hopefully large enough to not make the test too flaky in CI, while also turning it into a small example of BPF-based shaping. Signed-off-by: Alexis Lothor=C3=A9 (eBPF Foundation) --- .../testing/selftests/bpf/prog_tests/test_tc_edt.c | 273 +++++++++++++++++= ++++ 1 file changed, 273 insertions(+) diff --git a/tools/testing/selftests/bpf/prog_tests/test_tc_edt.c b/tools/t= esting/selftests/bpf/prog_tests/test_tc_edt.c new file mode 100644 index 000000000000..a77e48fdf4e4 --- /dev/null +++ b/tools/testing/selftests/bpf/prog_tests/test_tc_edt.c @@ -0,0 +1,273 @@ +// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause + +/* + * BPF-based flow shaping + * + * The test brings up two veth in two isolated namespaces, attach some flow + * shaping program onto it, and ensures that a manual speedtest maximum + * value matches the rate set in the BPF shapers. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "test_progs.h" +#include "network_helpers.h" +#include "test_tc_edt.skel.h" + +#define SERVER_NS "tc-edt-server-ns" +#define CLIENT_NS "tc-edt-client-ns" +#define IP4_ADDR_VETH1 "192.168.1.1" +#define IP4_ADDR_VETH2 "192.168.1.2" +#define IP4_ADDR_VETH2_HEX 0xC0A80102 + +#define BUFFER_LEN 500 +#define TIMEOUT_MS 2000 +#define TEST_PORT 9000 +#define TARGET_RATE_MBPS 5.0 +#define RATE_ERROR_PERCENT 2.0 + +struct connection { + int server_listen_fd; + int server_conn_fd; + int client_conn_fd; +}; + +static char tx_buffer[BUFFER_LEN], rx_buffer[BUFFER_LEN]; +static bool tx_timeout; + +static int start_server_listen(void) +{ + struct nstoken *nstoken =3D open_netns(SERVER_NS); + int server_fd; + + if (!ASSERT_OK_PTR(nstoken, "enter server ns")) + return -1; + + server_fd =3D start_server_str(AF_INET, SOCK_STREAM, IP4_ADDR_VETH2, + TEST_PORT, NULL); + close_netns(nstoken); + return server_fd; +} + +static struct connection *setup_connection(void) +{ + int server_listen_fd, server_conn_fd, client_conn_fd; + struct nstoken *nstoken; + struct connection *conn; + + conn =3D malloc(sizeof(struct connection)); + if (!ASSERT_OK_PTR(conn, "allocate connection")) + goto fail; + server_listen_fd =3D start_server_listen(); + if (!ASSERT_OK_FD(server_listen_fd, "start server")) + goto fail_free_conn; + + nstoken =3D open_netns(CLIENT_NS); + if (!ASSERT_OK_PTR(nstoken, "enter client ns")) + goto fail_close_server; + + client_conn_fd =3D connect_to_addr_str(AF_INET, SOCK_STREAM, + IP4_ADDR_VETH2, TEST_PORT, NULL); + close_netns(nstoken); + if (!ASSERT_OK_FD(client_conn_fd, "connect client")) + goto fail_close_server; + + server_conn_fd =3D accept(server_listen_fd, NULL, NULL); + if (!ASSERT_OK_FD(server_conn_fd, "accept client connection")) + goto fail_close_client; + + conn->server_listen_fd =3D server_listen_fd; + conn->server_conn_fd =3D server_conn_fd; + conn->client_conn_fd =3D client_conn_fd; + return conn; + +fail_close_client: + close(client_conn_fd); +fail_close_server: + close(server_listen_fd); +fail_free_conn: + free(conn); +fail: + return NULL; +} + +static void cleanup_connection(struct connection *conn) +{ + if (!conn) + return; + close(conn->client_conn_fd); + close(conn->server_conn_fd); + close(conn->server_listen_fd); + free(conn); +} + +static void *run_server(void *arg) +{ + int *fd =3D (int *)arg; + int ret; + + while (!tx_timeout) + ret =3D recv(*fd, rx_buffer, BUFFER_LEN, 0); + + return NULL; +} + +static int read_rx_bytes(__u64 *result) +{ + struct nstoken *nstoken =3D open_netns(SERVER_NS); + char line[512]; + FILE *fp; + + if (!ASSERT_OK_PTR(nstoken, "open server ns")) + return -1; + + fp =3D fopen("/proc/net/dev", "r"); + if (!ASSERT_OK_PTR(fp, "open /proc/net/dev")) { + close_netns(nstoken); + return -1; + } + + /* Skip the first two header lines */ + fgets(line, sizeof(line), fp); + fgets(line, sizeof(line), fp); + + while (fgets(line, sizeof(line), fp)) { + char name[32]; + __u64 rx_bytes =3D 0; + + if (sscanf(line, " %31[^:]: %llu", name, &rx_bytes) !=3D 2) + continue; + + if (strcmp(name, "veth2") =3D=3D 0) { + fclose(fp); + close_netns(nstoken); + *result =3D rx_bytes; + return 0; + } + } + + fclose(fp); + close_netns(nstoken); + return -1; +} +static int setup(struct test_tc_edt *skel) +{ + struct nstoken *nstoken_client, *nstoken_server; + int ret; + + if (!ASSERT_OK(make_netns(CLIENT_NS), "create client ns")) + goto fail; + if (!ASSERT_OK(make_netns(SERVER_NS), "create server ns")) + goto fail_delete_client_ns; + + nstoken_client =3D open_netns(CLIENT_NS); + if (!ASSERT_OK_PTR(nstoken_client, "open client ns")) + goto fail_delete_server_ns; + SYS(fail_close_client_ns, "ip link add veth1 type veth peer name %s", + "veth2 netns " SERVER_NS); + SYS(fail_close_client_ns, "ip -4 addr add " IP4_ADDR_VETH1 "/24 dev veth1= "); + SYS(fail_close_client_ns, "ip link set veth1 up"); + SYS(fail_close_client_ns, "tc qdisc add dev veth1 root fq"); + ret =3D tc_prog_attach("veth1", -1, bpf_program__fd(skel->progs.tc_prog)); + if (!ASSERT_OK(ret, "attach bpf prog")) + goto fail_close_client_ns; + + nstoken_server =3D open_netns(SERVER_NS); + if (!ASSERT_OK_PTR(nstoken_server, "enter server ns")) + goto fail_close_client_ns; + SYS(fail_close_server_ns, "ip -4 addr add " IP4_ADDR_VETH2 "/24 dev veth2= "); + SYS(fail_close_server_ns, "ip link set veth2 up"); + close_netns(nstoken_server); + close_netns(nstoken_client); + + return 0; + +fail_close_server_ns: + close_netns(nstoken_server); +fail_close_client_ns: + close_netns(nstoken_client); +fail_delete_server_ns: + remove_netns(SERVER_NS); +fail_delete_client_ns: + remove_netns(CLIENT_NS); +fail: + return -1; +} + +static void cleanup(void) +{ + remove_netns(CLIENT_NS); + remove_netns(SERVER_NS); +} + +static void run_test(void) +{ + __u64 rx_bytes_start, rx_bytes_end; + double rate_mbps, rate_error; + pthread_t server_thread =3D 0; + struct connection *conn; + __u64 ts_start, ts_end; + int ret; + + + conn =3D setup_connection(); + if (!ASSERT_OK_PTR(conn, "setup client and server connection")) + return; + + ret =3D pthread_create(&server_thread, NULL, run_server, + (void *)(&conn->server_conn_fd)); + if (!ASSERT_OK(ret, "start server rx thread")) + goto end_cleanup_conn; + if (!ASSERT_OK(read_rx_bytes(&rx_bytes_start), "read rx_bytes")) + goto end_kill_thread; + ts_start =3D get_time_ns(); + while (true) { + send(conn->client_conn_fd, (void *)tx_buffer, BUFFER_LEN, 0); + ts_end =3D get_time_ns(); + if ((ts_end - ts_start)/100000 >=3D TIMEOUT_MS) { + tx_timeout =3D true; + ret =3D read_rx_bytes(&rx_bytes_end); + if (!ASSERT_OK(ret, "read_rx_bytes")) + goto end_cleanup_conn; + break; + } + } + + rate_mbps =3D (rx_bytes_end - rx_bytes_start) / + ((ts_end - ts_start) / 1000.0); + rate_error =3D + fabs((rate_mbps - TARGET_RATE_MBPS) * 100.0 / TARGET_RATE_MBPS); + fprintf(stderr, "Rate:\t%f\nError:\t%f\n", rate_mbps, rate_error); + + ASSERT_LE(rate_error, RATE_ERROR_PERCENT, + "rate error is lower than threshold"); + +end_kill_thread: + tx_timeout =3D true; +end_cleanup_conn: + cleanup_connection(conn); +} + +void test_tc_edt(void) +{ + struct test_tc_edt *skel; + + skel =3D test_tc_edt__open_and_load(); + if (!ASSERT_OK_PTR(skel, "skel open and load")) + return; + + if (!ASSERT_OK(setup(skel), "global setup")) + return; + + run_test(); + + cleanup(); + test_tc_edt__destroy(skel); +} --=20 2.51.1.dirty From nobody Mon Feb 9 06:27:03 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 103702F1FCF; Fri, 31 Oct 2025 15:55:31 +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=1761926134; cv=none; b=JbLAoqkG+49D/SryB+DSrJZ4JxHs+IIiEg7HMt3v9PqFx0Y2+HUdz8K3b1SYfxxN3LxuBLjixinc66HunuvGAoCXgYDhw2wcBvwrfbKfNJT71LlEafBqmIl4DXfdcB48I66CrhFa1x4OeG9I6iZ5R7PUSZe4XSQR5UINRk515fk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761926134; c=relaxed/simple; bh=FlMQW/zdoeUwy361J2x3EnxoLoLiW3cy367tB6TXpLQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ueFaL8nvNOK7KsOhF1nPiIIqutp0S5BVr9U0qwiXFL8s/yEy1ost4PZ43o3L5RgjZSoB+WCoBy6RVsFCg4I9PHchcylx+BOnoY6fVDSCGCF13Ozkw/0GNWrxSK9iMa7kaV550enEfYGDHC0+0zu1s7Rw9gjDd/54tbeQpm1nNz4= 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=duc4OLqZ; 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="duc4OLqZ" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id F12F7C0E95A; Fri, 31 Oct 2025 15:55:09 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 801B560704; Fri, 31 Oct 2025 15:55:30 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 89C8311818064; Fri, 31 Oct 2025 16:55:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1761926129; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=lTXyjSXSIjBvnWIvqP/bdwEhFOhi3TM275wXbjbaKaI=; b=duc4OLqZwkstgkZTRIsgkmIdBJeMxXGXQth5UyQ2BYkGKD/B+RQ2J5NcM5ayGgUz0QvWri JyYixFKKmf+uwkDYmoTvQjSgXXUrOGDxf8v4eyswz37Hii9aX+bnAvKQmDFuEm68Nw/Phb IsiQ1IIkUyR/U6mZbo79Sj77CeNx3IIiBsOgQsNrB1CcA/mSoVO5HMEcJFB/nZXkzw33AR 7uqzZBp+4nkpQRor+ME3iq08AbHZNKQhcuto3FQrL2vyFEncxd1FPxnlgvU1B16U4A8YEQ Zv5C7NE6eIacGR8OkZSEgHjO4Xpf4Pr2YQW65tqEWziTI/x2vXYfK/YVy6cyoA== From: =?utf-8?q?Alexis_Lothor=C3=A9_=28eBPF_Foundation=29?= Date: Fri, 31 Oct 2025 16:55:15 +0100 Subject: [PATCH bpf-next 3/4] selftests/bpf: remove test_tc_edt.sh 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: <20251031-tc_edt-v1-3-5d34a5823144@bootlin.com> References: <20251031-tc_edt-v1-0-5d34a5823144@bootlin.com> In-Reply-To: <20251031-tc_edt-v1-0-5d34a5823144@bootlin.com> To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan Cc: ebpf@linuxfoundation.org, Bastien Curutchet , Thomas Petazzoni , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Alexis_Lothor=C3=A9_=28eBPF_Foundation=29?= X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 Now that test_tc_edt has been integrated in test_progs, remove the legacy shell script. Signed-off-by: Alexis Lothor=C3=A9 (eBPF Foundation) --- tools/testing/selftests/bpf/Makefile | 2 - tools/testing/selftests/bpf/test_tc_edt.sh | 100 -------------------------= ---- 2 files changed, 102 deletions(-) diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests= /bpf/Makefile index 02981b0d9b03..8793305bcee6 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -99,13 +99,11 @@ TEST_GEN_PROGS +=3D test_progs-cpuv4 TEST_INST_SUBDIRS +=3D cpuv4 endif =20 -TEST_GEN_FILES =3D test_tc_edt.bpf.o TEST_FILES =3D xsk_prereqs.sh $(wildcard progs/btf_dump_test_case_*.c) =20 # Order correspond to 'make run_tests' order TEST_PROGS :=3D test_kmod.sh \ test_lirc_mode2.sh \ - test_tc_edt.sh \ test_xdping.sh \ test_bpftool_build.sh \ test_bpftool.sh \ diff --git a/tools/testing/selftests/bpf/test_tc_edt.sh b/tools/testing/sel= ftests/bpf/test_tc_edt.sh deleted file mode 100755 index 8db8e146a431..000000000000 --- a/tools/testing/selftests/bpf/test_tc_edt.sh +++ /dev/null @@ -1,100 +0,0 @@ -#!/bin/bash -# SPDX-License-Identifier: GPL-2.0 -# -# This test installs a TC bpf program that throttles a TCP flow -# with dst port =3D 9000 down to 5MBps. Then it measures actual -# throughput of the flow. - -BPF_FILE=3D"test_tc_edt.bpf.o" -if [[ $EUID -ne 0 ]]; then - echo "This script must be run as root" - echo "FAIL" - exit 1 -fi - -# check that nc, dd, and timeout are present -command -v nc >/dev/null 2>&1 || \ - { echo >&2 "nc is not available"; exit 1; } -command -v dd >/dev/null 2>&1 || \ - { echo >&2 "nc is not available"; exit 1; } -command -v timeout >/dev/null 2>&1 || \ - { echo >&2 "timeout is not available"; exit 1; } - -readonly NS_SRC=3D"ns-src-$(mktemp -u XXXXXX)" -readonly NS_DST=3D"ns-dst-$(mktemp -u XXXXXX)" - -readonly IP_SRC=3D"172.16.1.100" -readonly IP_DST=3D"172.16.2.100" - -cleanup() -{ - ip netns del ${NS_SRC} - ip netns del ${NS_DST} -} - -trap cleanup EXIT - -set -e # exit on error - -ip netns add "${NS_SRC}" -ip netns add "${NS_DST}" -ip link add veth_src type veth peer name veth_dst -ip link set veth_src netns ${NS_SRC} -ip link set veth_dst netns ${NS_DST} - -ip -netns ${NS_SRC} addr add ${IP_SRC}/24 dev veth_src -ip -netns ${NS_DST} addr add ${IP_DST}/24 dev veth_dst - -ip -netns ${NS_SRC} link set dev veth_src up -ip -netns ${NS_DST} link set dev veth_dst up - -ip -netns ${NS_SRC} route add ${IP_DST}/32 dev veth_src -ip -netns ${NS_DST} route add ${IP_SRC}/32 dev veth_dst - -# set up TC on TX -ip netns exec ${NS_SRC} tc qdisc add dev veth_src root fq -ip netns exec ${NS_SRC} tc qdisc add dev veth_src clsact -ip netns exec ${NS_SRC} tc filter add dev veth_src egress \ - bpf da obj ${BPF_FILE} sec tc - - -# start the listener -ip netns exec ${NS_DST} bash -c \ - "nc -4 -l -p 9000 >/dev/null &" -declare -i NC_PID=3D$! -sleep 1 - -declare -ir TIMEOUT=3D20 -declare -ir EXPECTED_BPS=3D5000000 - -# run the load, capture RX bytes on DST -declare -ir RX_BYTES_START=3D$( ip netns exec ${NS_DST} \ - cat /sys/class/net/veth_dst/statistics/rx_bytes ) - -set +e -ip netns exec ${NS_SRC} bash -c "timeout ${TIMEOUT} dd if=3D/dev/zero \ - bs=3D1000 count=3D1000000 > /dev/tcp/${IP_DST}/9000 2>/dev/null" -set -e - -declare -ir RX_BYTES_END=3D$( ip netns exec ${NS_DST} \ - cat /sys/class/net/veth_dst/statistics/rx_bytes ) - -declare -ir ACTUAL_BPS=3D$(( ($RX_BYTES_END - $RX_BYTES_START) / $TIMEOUT = )) - -echo $TIMEOUT $ACTUAL_BPS $EXPECTED_BPS | \ - awk '{printf "elapsed: %d sec; bps difference: %.2f%%\n", - $1, ($2-$3)*100.0/$3}' - -# Pass the test if the actual bps is within 1% of the expected bps. -# The difference is usually about 0.1% on a 20-sec test, and =3D=3D> zero -# the longer the test runs. -declare -ir RES=3D$( echo $ACTUAL_BPS $EXPECTED_BPS | \ - awk 'function abs(x){return ((x < 0.0) ? -x : x)} - {if (abs(($1-$2)*100.0/$2) > 1.0) { print "1" } - else { print "0"} }' ) -if [ "${RES}" =3D=3D "0" ] ; then - echo "PASS" -else - echo "FAIL" - exit 1 -fi --=20 2.51.1.dirty From nobody Mon Feb 9 06:27:03 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 344D92F28EB; Fri, 31 Oct 2025 15:55:34 +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=1761926136; cv=none; b=mV97t7kfWke//I00tCNRCTjY9UY8cfLvdgpfJsJeekrNGVQimpmdjkT+GHDkhyAVkeVJc049M2Z1/t1OdTKpNaLoN9xqE17lNCmZo5rIlC4SeeH3Jput0krIljtwOqHAzczfG+GTdYaThbKIqXpJJa/MWHNKO6gI5CK7vy8iCMQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761926136; c=relaxed/simple; bh=DS7GdoyTSbp4Av0r2ONCH04vR0freNolpLYPdTzZ/dc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lI4p2PwG4Azllp/tKIhZDrLbrNX0YvTA0tIhs5C98lVUPxA7A045sY1iFwKq9Bf07CJtXREmy7pG2VHK+M7edsC0q9c11Z0q1dP81/7KFMPGF/sqhaNgcnADu0P9izTesW9tBVj2P/hTnIIsVG8nvylAoLlA4z0lUG8zb5WZwac= 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=NMVgH6ou; 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="NMVgH6ou" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 1470AC0E95B; Fri, 31 Oct 2025 15:55:12 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 97A9A60704; Fri, 31 Oct 2025 15:55:32 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id AFAFB11818066; Fri, 31 Oct 2025 16:55:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1761926131; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=/TNq8Noeo82uL94tALlA2YUHtpAfFnqYiA1L+FN+m5w=; b=NMVgH6ourG6tGxcvYLakUnTebijMsJSQ16SZ9ctt+0ulVANK/wrAoz3XVv1Py78ujjDoCS +vIs22BCxK36OLqECqtYWmcxxs6tzODcJ7FY6EDqXoAC8fd0s70+Hp8VOK9yDg5opi3xZK vwY1sIIxbIcA/LOaQLn+u9gAqPbz3edShDiRSLGnt2z8GXYS5Sbyi9fHx/NPldk+hvRuww vssH2eUzE8qZ1GdPOk7TAwKDUGxdAXttbgqy0AKCxaLwN8snUXFmTQMANXrrLrBG4pw6Vo 2bQhIpKGXfzJmos6i5gsMpc8tMRCiZ1ALgdm5wF5Ktvq5qYEZ8xjixfVH6JGtA== From: =?utf-8?q?Alexis_Lothor=C3=A9_=28eBPF_Foundation=29?= Date: Fri, 31 Oct 2025 16:55:16 +0100 Subject: [PATCH bpf-next 4/4] selftests/bpf: do not hardcode target rate in test_tc_edt BPF program 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: <20251031-tc_edt-v1-4-5d34a5823144@bootlin.com> References: <20251031-tc_edt-v1-0-5d34a5823144@bootlin.com> In-Reply-To: <20251031-tc_edt-v1-0-5d34a5823144@bootlin.com> To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan Cc: ebpf@linuxfoundation.org, Bastien Curutchet , Thomas Petazzoni , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Alexis_Lothor=C3=A9_=28eBPF_Foundation=29?= X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 test_tc_edt currently defines the target rate in both the userspace and BPF parts. This value could be defined once in the userspace part if we make it able to configure the BPF program before starting the test. Add a target_rate variable in the BPF part, and make the userspace part set it to the desired rate before attaching the shaping program. Signed-off-by: Alexis Lothor=C3=A9 (eBPF Foundation) --- tools/testing/selftests/bpf/prog_tests/test_tc_edt.c | 1 + tools/testing/selftests/bpf/progs/test_tc_edt.c | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/test_tc_edt.c b/tools/t= esting/selftests/bpf/prog_tests/test_tc_edt.c index a77e48fdf4e4..72b51376df10 100644 --- a/tools/testing/selftests/bpf/prog_tests/test_tc_edt.c +++ b/tools/testing/selftests/bpf/prog_tests/test_tc_edt.c @@ -175,6 +175,7 @@ static int setup(struct test_tc_edt *skel) SYS(fail_close_client_ns, "ip -4 addr add " IP4_ADDR_VETH1 "/24 dev veth1= "); SYS(fail_close_client_ns, "ip link set veth1 up"); SYS(fail_close_client_ns, "tc qdisc add dev veth1 root fq"); + skel->bss->target_rate =3D TARGET_RATE_MBPS * 1000 * 1000; ret =3D tc_prog_attach("veth1", -1, bpf_program__fd(skel->progs.tc_prog)); if (!ASSERT_OK(ret, "attach bpf prog")) goto fail_close_client_ns; diff --git a/tools/testing/selftests/bpf/progs/test_tc_edt.c b/tools/testin= g/selftests/bpf/progs/test_tc_edt.c index 9b80109d5c3d..99bae5e20685 100644 --- a/tools/testing/selftests/bpf/progs/test_tc_edt.c +++ b/tools/testing/selftests/bpf/progs/test_tc_edt.c @@ -14,7 +14,6 @@ #define TIME_HORIZON_NS (2000 * 1000 * 1000) #define NS_PER_SEC 1000000000 #define ECN_HORIZON_NS 5000000 -#define THROTTLE_RATE_BPS (5 * 1000 * 1000) =20 /* flow_key =3D> last_tstamp timestamp used */ struct { @@ -24,12 +23,13 @@ struct { __uint(max_entries, 1); } flow_map SEC(".maps"); =20 +__uint64_t target_rate; + static inline int throttle_flow(struct __sk_buff *skb) { int key =3D 0; uint64_t *last_tstamp =3D bpf_map_lookup_elem(&flow_map, &key); - uint64_t delay_ns =3D ((uint64_t)skb->len) * NS_PER_SEC / - THROTTLE_RATE_BPS; + uint64_t delay_ns =3D ((uint64_t)skb->len) * NS_PER_SEC / target_rate; uint64_t now =3D bpf_ktime_get_ns(); uint64_t tstamp, next_tstamp =3D 0; =20 --=20 2.51.1.dirty