Skip to content

Commit

Permalink
selftests: Add a bpf fq qdisc to selftest
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Amery Hung authored and Kernel Patches Daemon committed Dec 20, 2024
1 parent 975df34 commit ba12be6
Show file tree
Hide file tree
Showing 2 changed files with 750 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tools/testing/selftests/bpf/prog_tests/bpf_qdisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "network_helpers.h"
#include "bpf_qdisc_fifo.skel.h"
#include "bpf_qdisc_fq.skel.h"

#ifndef ENOTSUPP
#define ENOTSUPP 524
Expand Down Expand Up @@ -154,8 +155,31 @@ 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)
{
if (test__start_subtest("fifo"))
test_fifo();
if (test__start_subtest("fq"))
test_fq();
}
Loading

0 comments on commit ba12be6

Please sign in to comment.