aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/prog_tests/bpf_qdisc.c
diff options
context:
space:
mode:
authorAmery Hung <[email protected]>2025-04-09 21:46:05 +0000
committerMartin KaFai Lau <[email protected]>2025-04-17 17:54:41 +0000
commit2b59bd9e4efcfdbb2458bb68da67f7bb40951de9 (patch)
treeeff35f90baaa9f3c3e2e207ab419b72ed42960f9 /tools/testing/selftests/bpf/prog_tests/bpf_qdisc.c
parentselftests/bpf: Add a basic fifo qdisc test (diff)
downloadkernel-2b59bd9e4efcfdbb2458bb68da67f7bb40951de9.tar.gz
kernel-2b59bd9e4efcfdbb2458bb68da67f7bb40951de9.zip
selftests/bpf: Add a bpf fq qdisc to selftest
This test implements a more sophisticated qdisc using bpf. The bpf fair- queueing (fq) qdisc gives each flow an equal chance to transmit data. It also respects the timestamp of skb for rate limiting. Signed-off-by: Amery Hung <[email protected]> Signed-off-by: Martin KaFai Lau <[email protected]> Acked-by: Toke Høiland-Jørgensen <[email protected]> Link: https://patch.msgid.link/[email protected]
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/bpf_qdisc.c')
-rw-r--r--tools/testing/selftests/bpf/prog_tests/bpf_qdisc.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_qdisc.c b/tools/testing/selftests/bpf/prog_tests/bpf_qdisc.c
index 1ec321eb089f..230d8f935303 100644
--- a/tools/testing/selftests/bpf/prog_tests/bpf_qdisc.c
+++ b/tools/testing/selftests/bpf/prog_tests/bpf_qdisc.c
@@ -6,6 +6,7 @@
#include "network_helpers.h"
#include "bpf_qdisc_fifo.skel.h"
+#include "bpf_qdisc_fq.skel.h"
#define LO_IFINDEX 1
@@ -66,6 +67,27 @@ static void test_fifo(void)
bpf_qdisc_fifo__destroy(fifo_skel);
}
+static void test_fq(void)
+{
+ struct bpf_qdisc_fq *fq_skel;
+ struct bpf_link *link;
+
+ fq_skel = bpf_qdisc_fq__open_and_load();
+ if (!ASSERT_OK_PTR(fq_skel, "bpf_qdisc_fq__open_and_load"))
+ return;
+
+ link = bpf_map__attach_struct_ops(fq_skel->maps.fq);
+ if (!ASSERT_OK_PTR(link, "bpf_map__attach_struct_ops")) {
+ bpf_qdisc_fq__destroy(fq_skel);
+ return;
+ }
+
+ do_test("bpf_fq");
+
+ bpf_link__destroy(link);
+ bpf_qdisc_fq__destroy(fq_skel);
+}
+
void test_bpf_qdisc(void)
{
struct netns_obj *netns;
@@ -76,6 +98,8 @@ void test_bpf_qdisc(void)
if (test__start_subtest("fifo"))
test_fifo();
+ if (test__start_subtest("fq"))
+ test_fq();
netns_free(netns);
}