diff options
author | Joe Stringer <joe@ovn.org> | 2017-01-22 20:11:24 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-01-26 09:42:58 -0500 |
commit | 7803ba73099867d1f6ca866857277d92e0da4080 (patch) | |
tree | 9e1676a3a66c645ab52d9d8e388314b8494f9443 /tools | |
parent | ed7940731ac89616b8a516c560a76dca44a152a8 (diff) |
tools lib bpf: Add set/is helpers for all prog types
These bpf_prog_types were exposed in the uapi but there were no
corresponding functions to set these types for programs in libbpf.
Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Wang Nan <wangnan0@huawei.com>
Cc: Alexei Starovoitov <ast@fb.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: netdev@vger.kernel.org
Link: http://lkml.kernel.org/r/20170123011128.26534-4-joe@ovn.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/lib/bpf/libbpf.c | 5 | ||||
-rw-r--r-- | tools/lib/bpf/libbpf.h | 10 |
2 files changed, 15 insertions, 0 deletions
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 371cb40a2304..406838fa9c4f 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c | |||
@@ -1448,8 +1448,13 @@ bool bpf_program__is_##NAME(struct bpf_program *prog) \ | |||
1448 | return bpf_program__is_type(prog, TYPE); \ | 1448 | return bpf_program__is_type(prog, TYPE); \ |
1449 | } \ | 1449 | } \ |
1450 | 1450 | ||
1451 | BPF_PROG_TYPE_FNS(socket_filter, BPF_PROG_TYPE_SOCKET_FILTER); | ||
1451 | BPF_PROG_TYPE_FNS(kprobe, BPF_PROG_TYPE_KPROBE); | 1452 | BPF_PROG_TYPE_FNS(kprobe, BPF_PROG_TYPE_KPROBE); |
1453 | BPF_PROG_TYPE_FNS(sched_cls, BPF_PROG_TYPE_SCHED_CLS); | ||
1454 | BPF_PROG_TYPE_FNS(sched_act, BPF_PROG_TYPE_SCHED_ACT); | ||
1452 | BPF_PROG_TYPE_FNS(tracepoint, BPF_PROG_TYPE_TRACEPOINT); | 1455 | BPF_PROG_TYPE_FNS(tracepoint, BPF_PROG_TYPE_TRACEPOINT); |
1456 | BPF_PROG_TYPE_FNS(xdp, BPF_PROG_TYPE_XDP); | ||
1457 | BPF_PROG_TYPE_FNS(perf_event, BPF_PROG_TYPE_PERF_EVENT); | ||
1453 | 1458 | ||
1454 | int bpf_map__fd(struct bpf_map *map) | 1459 | int bpf_map__fd(struct bpf_map *map) |
1455 | { | 1460 | { |
diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h index a5a8b86a06fe..2188ccdc0e2d 100644 --- a/tools/lib/bpf/libbpf.h +++ b/tools/lib/bpf/libbpf.h | |||
@@ -174,11 +174,21 @@ int bpf_program__nth_fd(struct bpf_program *prog, int n); | |||
174 | /* | 174 | /* |
175 | * Adjust type of bpf program. Default is kprobe. | 175 | * Adjust type of bpf program. Default is kprobe. |
176 | */ | 176 | */ |
177 | int bpf_program__set_socket_filter(struct bpf_program *prog); | ||
177 | int bpf_program__set_tracepoint(struct bpf_program *prog); | 178 | int bpf_program__set_tracepoint(struct bpf_program *prog); |
178 | int bpf_program__set_kprobe(struct bpf_program *prog); | 179 | int bpf_program__set_kprobe(struct bpf_program *prog); |
180 | int bpf_program__set_sched_cls(struct bpf_program *prog); | ||
181 | int bpf_program__set_sched_act(struct bpf_program *prog); | ||
182 | int bpf_program__set_xdp(struct bpf_program *prog); | ||
183 | int bpf_program__set_perf_event(struct bpf_program *prog); | ||
179 | 184 | ||
185 | bool bpf_program__is_socket_filter(struct bpf_program *prog); | ||
180 | bool bpf_program__is_tracepoint(struct bpf_program *prog); | 186 | bool bpf_program__is_tracepoint(struct bpf_program *prog); |
181 | bool bpf_program__is_kprobe(struct bpf_program *prog); | 187 | bool bpf_program__is_kprobe(struct bpf_program *prog); |
188 | bool bpf_program__is_sched_cls(struct bpf_program *prog); | ||
189 | bool bpf_program__is_sched_act(struct bpf_program *prog); | ||
190 | bool bpf_program__is_xdp(struct bpf_program *prog); | ||
191 | bool bpf_program__is_perf_event(struct bpf_program *prog); | ||
182 | 192 | ||
183 | /* | 193 | /* |
184 | * We don't need __attribute__((packed)) now since it is | 194 | * We don't need __attribute__((packed)) now since it is |