tools/testing/selftests/bpf/prog_tests/bpf_qdisc.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/prog_tests/bpf_qdisc.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/prog_tests/bpf_qdisc.c- Extension
.c- Size
- 6050 bytes
- Lines
- 240
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/pkt_sched.hlinux/rtnetlink.htest_progs.hnetwork_helpers.hbpf_qdisc_fifo.skel.hbpf_qdisc_fq.skel.hbpf_qdisc_fail__incompl_ops.skel.hbpf_qdisc_fail__invalid_dynptr.skel.hbpf_qdisc_fail__invalid_dynptr_slice.skel.hbpf_qdisc_fail__invalid_dynptr_cross_frame.skel.hbpf_qdisc_dynptr_use_after_invalidate_clone.skel.h
Detected Declarations
function do_testfunction test_fifofunction test_fqfunction test_qdisc_attach_to_mqfunction test_qdisc_attach_to_non_rootfunction test_incompl_opsfunction get_default_qdiscfunction test_default_qdisc_attach_to_mqfunction test_ns_bpf_qdiscfunction serial_test_bpf_qdisc_default
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
#include <linux/pkt_sched.h>
#include <linux/rtnetlink.h>
#include <test_progs.h>
#include "network_helpers.h"
#include "bpf_qdisc_fifo.skel.h"
#include "bpf_qdisc_fq.skel.h"
#include "bpf_qdisc_fail__incompl_ops.skel.h"
#include "bpf_qdisc_fail__invalid_dynptr.skel.h"
#include "bpf_qdisc_fail__invalid_dynptr_slice.skel.h"
#include "bpf_qdisc_fail__invalid_dynptr_cross_frame.skel.h"
#include "bpf_qdisc_dynptr_use_after_invalidate_clone.skel.h"
#define LO_IFINDEX 1
static const unsigned int total_bytes = 10 * 1024 * 1024;
static void do_test(char *qdisc)
{
DECLARE_LIBBPF_OPTS(bpf_tc_hook, hook, .ifindex = LO_IFINDEX,
.attach_point = BPF_TC_QDISC,
.parent = TC_H_ROOT,
.handle = 0x8000000,
.qdisc = qdisc);
int srv_fd = -1, cli_fd = -1;
int err;
err = bpf_tc_hook_create(&hook);
if (!ASSERT_OK(err, "attach qdisc"))
return;
srv_fd = start_server(AF_INET6, SOCK_STREAM, NULL, 0, 0);
if (!ASSERT_OK_FD(srv_fd, "start server"))
goto done;
cli_fd = connect_to_fd(srv_fd, 0);
if (!ASSERT_OK_FD(cli_fd, "connect to client"))
goto done;
err = send_recv_data(srv_fd, cli_fd, total_bytes);
ASSERT_OK(err, "send_recv_data");
done:
if (srv_fd != -1)
close(srv_fd);
if (cli_fd != -1)
close(cli_fd);
bpf_tc_hook_destroy(&hook);
}
static void test_fifo(void)
{
struct bpf_qdisc_fifo *fifo_skel;
fifo_skel = bpf_qdisc_fifo__open_and_load();
if (!ASSERT_OK_PTR(fifo_skel, "bpf_qdisc_fifo__open_and_load"))
return;
if (!ASSERT_OK(bpf_qdisc_fifo__attach(fifo_skel), "bpf_qdisc_fifo__attach"))
goto out;
do_test("bpf_fifo");
out:
bpf_qdisc_fifo__destroy(fifo_skel);
}
static void test_fq(void)
{
struct bpf_qdisc_fq *fq_skel;
fq_skel = bpf_qdisc_fq__open_and_load();
if (!ASSERT_OK_PTR(fq_skel, "bpf_qdisc_fq__open_and_load"))
return;
if (!ASSERT_OK(bpf_qdisc_fq__attach(fq_skel), "bpf_qdisc_fq__attach"))
goto out;
do_test("bpf_fq");
out:
bpf_qdisc_fq__destroy(fq_skel);
}
static void test_qdisc_attach_to_mq(void)
{
DECLARE_LIBBPF_OPTS(bpf_tc_hook, hook,
.attach_point = BPF_TC_QDISC,
.parent = TC_H_MAKE(1 << 16, 1),
Annotation
- Immediate include surface: `linux/pkt_sched.h`, `linux/rtnetlink.h`, `test_progs.h`, `network_helpers.h`, `bpf_qdisc_fifo.skel.h`, `bpf_qdisc_fq.skel.h`, `bpf_qdisc_fail__incompl_ops.skel.h`, `bpf_qdisc_fail__invalid_dynptr.skel.h`.
- Detected declarations: `function do_test`, `function test_fifo`, `function test_fq`, `function test_qdisc_attach_to_mq`, `function test_qdisc_attach_to_non_root`, `function test_incompl_ops`, `function get_default_qdisc`, `function test_default_qdisc_attach_to_mq`, `function test_ns_bpf_qdisc`, `function serial_test_bpf_qdisc_default`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.