__cgroup_bpf_attach(9)
π
__cgroup_bpf_attach(9) β from the Kernel API Manual, bestie π
okay so picture this: you're deep in the kernel, you've got a cgroup, you've got a prog, and you need them to be together. That's this function. It attaches the program or the link to a cgroup and propagates that change down to all the descendants, like the gossip girl of the cgroup tree β¨
β¨ SYNOPSIS β¨
int __cgroup_bpf_attach (struct cgroup *cgrp , struct bpf_prog *prog ,
struct bpf_prog *replace_prog , struct bpf_cgroup_link *link , enum
bpf_attach_type type , u32 flags , u32 id_or_fd , u64 revision );
it's giving eight whole arguments, and yes we're gonna go through every single one π«Ά
πΈ ARGUMENTS πΈ
cgrpβ the cgroup whose descendants get traversed. like, this is the starting point of the whole propagation moment β¨progβ a program to attach πreplace_progβ a previously attached program you wanna replace, but only ifBPF_F_REPLACEis set. no flag, no replacing, iykyk.linkβ a link to attach π¦typeβ the type of attach operationflagsβ option flagsid_or_fdβ relative prog id or fdrevisionβbpf_prog_listrevision π
π DESCRIPTION π
okay so the actual rules, no cap:
Exactly one of prog or link can be non-null. Exactly one, bestie β not both, not neither, this is not a choose-your-own-adventure π«
β οΈ and it must be called with cgroup_mutex held. that's not a suggestion, that's the vibe check you cannot fail π₯
π SEE ALSO π
- Kernel file
./kernel/bpf/cgroup.c cgroup_bpf_release(9)cgroup_bpf_release_fn(9)cgroup_bpf_inherit(9)__cgroup_bpf_replace(9)purge_effective_progs(9)__cgroup_bpf_detach(9)__cgroup_bpf_run_filter_skb(9)__cgroup_bpf_run_filter_sk(9)__cgroup_bpf_run_filter_sock_addr(9)__cgroup_bpf_run_filter_sock_ops(9)__cgroup_bpf_run_filter_sysctl(9)
aaaand that's the whole page, mwah π straight from ./kernel/bpf, dated October 2026 β so go forth, hold that cgroup_mutex, and attach responsibly ππ§ββοΈ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms