diff options
| author | Toke Høiland-Jørgensen <[email protected]> | 2019-11-09 20:37:32 +0000 |
|---|---|---|
| committer | Alexei Starovoitov <[email protected]> | 2019-11-11 03:26:30 +0000 |
| commit | 1a734efe06948c17122808f74f0c8cc550c10cf5 (patch) | |
| tree | 051f5faf97bf712570b11f65b035a812daab7703 /tools/lib/bpf/libbpf.c | |
| parent | libbpf: Add bpf_get_link_xdp_info() function to get more XDP information (diff) | |
| download | kernel-1a734efe06948c17122808f74f0c8cc550c10cf5.tar.gz kernel-1a734efe06948c17122808f74f0c8cc550c10cf5.zip | |
libbpf: Add getter for program size
This adds a new getter for the BPF program size (in bytes). This is useful
for a caller that is trying to predict how much memory will be locked by
loading a BPF object into the kernel.
Signed-off-by: Toke Høiland-Jørgensen <[email protected]>
Signed-off-by: Alexei Starovoitov <[email protected]>
Acked-by: Andrii Nakryiko <[email protected]>
Acked-by: David S. Miller <[email protected]>
Acked-by: Song Liu <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
Diffstat (limited to 'tools/lib/bpf/libbpf.c')
| -rw-r--r-- | tools/lib/bpf/libbpf.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 847b62895f9b..96ef18cfeffb 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -4782,6 +4782,11 @@ int bpf_program__fd(const struct bpf_program *prog) return bpf_program__nth_fd(prog, 0); } +size_t bpf_program__size(const struct bpf_program *prog) +{ + return prog->insns_cnt * sizeof(struct bpf_insn); +} + int bpf_program__set_prep(struct bpf_program *prog, int nr_instances, bpf_program_prep_t prep) { |
