Skip to content

Commit 69dfd77

Browse files
Amery HungMartin KaFai Lau
Amery Hung
authored and
Martin KaFai Lau
committed
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]
1 parent cb7e598 commit 69dfd77

File tree

2 files changed

+774
-0
lines changed

2 files changed

+774
-0
lines changed

tools/testing/selftests/bpf/prog_tests/bpf_qdisc.c

+24
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include "network_helpers.h"
88
#include "bpf_qdisc_fifo.skel.h"
9+
#include "bpf_qdisc_fq.skel.h"
910

1011
#define LO_IFINDEX 1
1112

@@ -66,6 +67,27 @@ static void test_fifo(void)
6667
bpf_qdisc_fifo__destroy(fifo_skel);
6768
}
6869

70+
static void test_fq(void)
71+
{
72+
struct bpf_qdisc_fq *fq_skel;
73+
struct bpf_link *link;
74+
75+
fq_skel = bpf_qdisc_fq__open_and_load();
76+
if (!ASSERT_OK_PTR(fq_skel, "bpf_qdisc_fq__open_and_load"))
77+
return;
78+
79+
link = bpf_map__attach_struct_ops(fq_skel->maps.fq);
80+
if (!ASSERT_OK_PTR(link, "bpf_map__attach_struct_ops")) {
81+
bpf_qdisc_fq__destroy(fq_skel);
82+
return;
83+
}
84+
85+
do_test("bpf_fq");
86+
87+
bpf_link__destroy(link);
88+
bpf_qdisc_fq__destroy(fq_skel);
89+
}
90+
6991
void test_bpf_qdisc(void)
7092
{
7193
struct netns_obj *netns;
@@ -76,6 +98,8 @@ void test_bpf_qdisc(void)
7698

7799
if (test__start_subtest("fifo"))
78100
test_fifo();
101+
if (test__start_subtest("fq"))
102+
test_fq();
79103

80104
netns_free(netns);
81105
}

0 commit comments

Comments
 (0)