STRUCT BPF_STRUCT_OPS(9)
π struct bpf_struct_ops π
okay so welcome to the Kernel API Manual page for struct bpf_struct_ops(9) β yes bestie, this is that struct. It's literally a structure of callbacks that lets a subsystem define a BPF_MAP_TYPE_STRUCT_OPS map type made up of BPF_PROG_TYPE_STRUCT_OPS progs. iconic behavior, no cap π«Ά
β¨ NAME β¨
struct bpf_struct_ops β a structure of callbacks allowing a subsystem to define a BPF_MAP_TYPE_STRUCT_OPS map type composed of BPF_PROG_TYPE_STRUCT_OPS progs. π
πΈ SYNOPSIS πΈ
struct bpf_struct_ops {
const struct bpf_verifier_ops *verifier_ops;
int (*init)(struct btf *btf);
int (*check_member)(const struct btf_type *t, const struct btf_member *member, const struct bpf_prog *prog);
int (*init_member)(const struct btf_type *t, const struct btf_member *member, void *kdata, const void *udata);
int (*reg)(void *kdata, struct bpf_link *link);
void (*unreg)(void *kdata, struct bpf_link *link);
int (*update)(void *kdata, void *old_kdata, struct bpf_link *link);
int (*validate)(void *kdata);
void *cfi_stubs;
struct module *owner;
const char *name;
struct btf_func_model func_models[BPF_STRUCT_OPS_MAX_NR_MEMBERS];
};
π Members π
verifier_opsβ a structure of callbacks that are invoked by the verifier when it's determining whether the struct_ops progs in the struct_ops map are valid. verifier vibe check, literally πinitβ a callback that is invoked a single time, and before any other callback, to initialize the structure. A nonzero return value means the subsystem could not be initialized. first one in, no cap β¨check_memberβ when defined, a callback invoked by the verifier to allow the subsystem to determine if an entry in the struct_ops map is valid. A nonzero return value means that the map is invalid and should be rejected by the verifier. reject the map, periodt π«init_memberβ a callback that is invoked for each member of the struct_ops map to allow the subsystem to initialize the member. A nonzero value means the member could not be initialized. This callback is exclusive with thetype,type_id,value_type, andvalue_idfields. mutually exclusive bestie, don't mix πregβ a callback that is invoked when the struct_ops map has been initialized and is being attached to. Zero means the struct_ops map has been successfully registered and is live. A nonzero return value means the struct_ops map could not be registered. live and registered, slay βunregβ a callback that is invoked when the struct_ops map should be unregistered. time to say bye πupdateβ a callback that is invoked when the live struct_ops map is being updated to contain new values. This callback is only invoked when the struct_ops map is loaded withBPF_F_LINK. If not defined, it is assumed that the struct_ops map cannot be updated. only withBPF_F_LINK, iykyk π₯validateβ a callback that is invoked after all of the members have been initialized. This callback should perform static checks on the map, meaning that it should either fail or succeed deterministically. A struct_ops map that has been validated may not necessarily succeed in being registered if the call toregfails. For example, a valid struct_ops map may be loaded, but then fail to be registered due to there being another active struct_ops map on the system in the subsystem already. For this reason, if this callback is not defined, the check is skipped as the struct_ops map will have final verification performed inreg. deterministic checks only, no chaotic energy π§cfi_stubsβ pointer to a structure of stub functions for CFI. These stubs provide the correct Control Flow Integrity hashes for the trampolines generated by BPF struct_ops. CFI stubs giving correct hashes πownerβ the module that owns this struct_ops. Used for module reference counting to ensure the module providing the struct_ops cannot be unloaded while in use. keeps the module pinned, no unload-while-in-use drama π«Άnameβ the name of thestruct bpf_struct_opsobject. name reveal π«func_modelsβ func models. that's the note, bestie π
π SEE ALSO π
- Kernel file
./include/linux/bpf.hβ go read it if you want the deep lore π
xoxo, your struct_ops bestie π β from ./include/linux, source/version October 2026, all about struct bpf_struct_ops(9) π«Ά
π¦ 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