bpf_struct_o...or_each_prog(9)
π bpf_struct_ops_for_each_prog(9)
okay bestie, welcome to the Kernel API Manual β¨ β yes this is a real function name, no I did not make it up, and yes it is lowkey a mouthful. we're doing bpf_struct_ops_for_each_prog today and honestly? it's giving little-helper-that-could π«Ά
πΈ NAME πΈ
bpf_struct_ops_for_each_prog β invoke @cb for each member prog π«
β¨ SYNOPSIS β¨
int bpf_struct_ops_for_each_prog (const void *kdata , int (*cb)(struct
bpf_prog *prog, void *data) , void *data );
she's long, she's got a function pointer in the middle, she's iconic. type it carefully bestie π
π ARGUMENTS π
kdataβ the kernel-side struct_ops vmtable. iykyk β this is the samekdataarg you hand to->reg/->update/->unreg. your entry pass ποΈcbβ the callback, invoked once per member prog. super important: a non-zero return from this bad boy stops the iteration. not me ending the whole loop early πdataβ opaque argument, just gets passed straight through tocb. she's a vibe carrier, no questions asked π₯
π¦ DESCRIPTION π¦
so what does she do? she walks the struct_ops member progs that are registered on the map containing kdata β like a little tour guide for your progs π§
this is intended for use from struct_ops ->reg callbacks (and similar) that need to inspect the loaded BPF programs. and fr fr, the classic example: discovering the maps they reference via prog->aux->used_maps π
Return 0 if iteration completed, otherwise the first non-zero cb return. periodt. π
ngl, remember that early-exit rule β the moment your cb returns non-zero, the loop is done, and that value is what comes back out. main character exit energy π
π SEE ALSO π
- Kernel file
./kernel/bpf/bpf_struct_ops.cβ go read the source bestie, she's right there π
and that's the whole page! π brought to you by the fine folks over at ./kernel/bpf, dated October 2026 β mwah, slay, go write some struct_ops π«ΆπΈβ¨
π¦ 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