net/sched/bpf_qdisc.c
Source file repositories/reference/linux-study-clean/net/sched/bpf_qdisc.c
File Facts
- System
- Linux kernel
- Corpus path
net/sched/bpf_qdisc.c- Extension
.c- Size
- 13149 bytes
- Lines
- 479
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/types.hlinux/bpf_verifier.hlinux/bpf.hlinux/btf.hlinux/filter.hnet/pkt_sched.hnet/pkt_cls.h
Detected Declarations
struct bpf_sched_datastruct bpf_sk_buff_ptrenum qdisc_ops_kf_flagsfunction bpf_qdisc_initfunction bpf_qdisc_is_valid_accessfunction bpf_qdisc_qdisc_accessfunction bpf_qdisc_sk_buff_accessfunction bpf_qdisc_btf_struct_accessfunction bpf_qdisc_gen_prologuefunction bpf_qdisc_gen_epiloguefunction bpf_skb_get_hashfunction bpf_kfree_skbfunction bpf_kfree_skb_dtorfunction bpf_qdisc_skb_dropfunction bpf_qdisc_watchdog_schedulefunction bpf_qdisc_init_prologuefunction bpf_qdisc_reset_destroy_epiloguefunction bpf_qdisc_bstats_updatefunction bpf_qdisc_kfunc_filterfunction bpf_qdisc_init_memberfunction bpf_qdisc_regfunction bpf_qdisc_unregfunction bpf_qdisc_validatefunction Qdisc_ops__enqueuefunction Qdisc_ops__initfunction Qdisc_ops__resetfunction bpf_qdisc_kfunc_init
Annotated Snippet
struct bpf_sched_data {
struct qdisc_watchdog watchdog;
};
struct bpf_sk_buff_ptr {
struct sk_buff *skb;
};
static int bpf_qdisc_init(struct btf *btf)
{
return 0;
}
BTF_ID_LIST_SINGLE(bpf_qdisc_ids, struct, Qdisc)
BTF_ID_LIST_SINGLE(bpf_sk_buff_ids, struct, sk_buff)
BTF_ID_LIST_SINGLE(bpf_sk_buff_ptr_ids, struct, bpf_sk_buff_ptr)
static bool bpf_qdisc_is_valid_access(int off, int size,
enum bpf_access_type type,
const struct bpf_prog *prog,
struct bpf_insn_access_aux *info)
{
struct btf *btf = prog->aux->attach_btf;
u32 arg;
arg = btf_ctx_arg_idx(btf, prog->aux->attach_func_proto, off);
if (prog->aux->attach_st_ops_member_off == offsetof(struct Qdisc_ops, enqueue)) {
if (arg == 2 && type == BPF_READ) {
info->reg_type = PTR_TO_BTF_ID | PTR_TRUSTED;
info->btf = btf;
info->btf_id = bpf_sk_buff_ptr_ids[0];
return true;
}
}
return bpf_tracing_btf_ctx_access(off, size, type, prog, info);
}
static int bpf_qdisc_qdisc_access(struct bpf_verifier_log *log,
const struct bpf_reg_state *reg,
int off, size_t *end)
{
switch (off) {
case offsetof(struct Qdisc, limit):
*end = offsetofend(struct Qdisc, limit);
break;
case offsetof(struct Qdisc, q) + offsetof(struct qdisc_skb_head, qlen):
*end = offsetof(struct Qdisc, q) + offsetofend(struct qdisc_skb_head, qlen);
break;
case offsetof(struct Qdisc, qstats) ... offsetofend(struct Qdisc, qstats) - 1:
*end = offsetofend(struct Qdisc, qstats);
break;
default:
return -EACCES;
}
return 0;
}
static int bpf_qdisc_sk_buff_access(struct bpf_verifier_log *log,
const struct bpf_reg_state *reg,
int off, size_t *end)
{
switch (off) {
case offsetof(struct sk_buff, tstamp):
*end = offsetofend(struct sk_buff, tstamp);
break;
case offsetof(struct sk_buff, cb) + offsetof(struct qdisc_skb_cb, data[0]) ...
offsetof(struct sk_buff, cb) + offsetof(struct qdisc_skb_cb,
data[QDISC_CB_PRIV_LEN - 1]):
*end = offsetof(struct sk_buff, cb) +
offsetofend(struct qdisc_skb_cb, data[QDISC_CB_PRIV_LEN - 1]);
break;
default:
return -EACCES;
}
return 0;
}
static int bpf_qdisc_btf_struct_access(struct bpf_verifier_log *log,
const struct bpf_reg_state *reg,
int off, int size)
{
const struct btf_type *t, *skbt, *qdisct;
size_t end;
int err;
skbt = btf_type_by_id(reg->btf, bpf_sk_buff_ids[0]);
qdisct = btf_type_by_id(reg->btf, bpf_qdisc_ids[0]);
Annotation
- Immediate include surface: `linux/types.h`, `linux/bpf_verifier.h`, `linux/bpf.h`, `linux/btf.h`, `linux/filter.h`, `net/pkt_sched.h`, `net/pkt_cls.h`.
- Detected declarations: `struct bpf_sched_data`, `struct bpf_sk_buff_ptr`, `enum qdisc_ops_kf_flags`, `function bpf_qdisc_init`, `function bpf_qdisc_is_valid_access`, `function bpf_qdisc_qdisc_access`, `function bpf_qdisc_sk_buff_access`, `function bpf_qdisc_btf_struct_access`, `function bpf_qdisc_gen_prologue`, `function bpf_qdisc_gen_epilogue`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
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.