Libbpf userspace function bpf_program__set_insns
Set BPF program's underlying BPF instructions.
Definition
int bpf_program__set_insns(struct bpf_program *prog, struct bpf_insn *new_insns, size_t new_insn_cnt);
Parameters
prog
: BPF program for which to return instructionsnew_insns
: a pointer to an array of BPF instructionsnew_insn_cnt
: number ofstruct bpf_insn
's that form specified BPF program
Return
0
, on success; negative error code, otherwise
Usage
This function allows a user to modify or replace the BPF instructions of a BPF program right before its about to be loaded into the kernel.
Warning
This is a very advanced libbpf API and users need to know what they are doing. This should be used from prog_prepare_load_fn
callback only.
Example
Docs could be improved
This part of the docs is incomplete, contributions are very welcome