__cgroup_bpf_attach(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… __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 if BPF_F_REPLACE is set. no flag, no replacing, iykyk.
  • link β€” a link to attach πŸ¦‹
  • type β€” the type of attach operation
  • flags β€” option flags
  • id_or_fd β€” relative prog id or fd
  • revision β€” bpf_prog_list revision πŸ‘‘

πŸ’€ 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 πŸ‘€


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