mirror of
https://github.com/netdata/libbpf.git
synced 2026-03-27 19:59:06 +08:00
libbpf: Add opts-based attach/detach/query API for tcx
Extend libbpf attach opts and add a new detach opts API so this can be used to add/remove fd-based tcx BPF programs. The old-style bpf_prog_detach() and bpf_prog_detach2() APIs are refactored to reuse the new bpf_prog_detach_opts() internally. The bpf_prog_query_opts() API got extended to be able to handle the new link_ids, link_attach_flags and revision fields. For concrete usage examples, see the extensive selftests that have been developed as part of this series. Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/r/20230719140858.13224-4-daniel@iogearbox.net Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
committed by
Andrii Nakryiko
parent
b064c40d94
commit
bb5d7c1be8
12
src/libbpf.c
12
src/libbpf.c
@@ -118,6 +118,8 @@ static const char * const attach_type_name[] = {
|
||||
[BPF_TRACE_KPROBE_MULTI] = "trace_kprobe_multi",
|
||||
[BPF_STRUCT_OPS] = "struct_ops",
|
||||
[BPF_NETFILTER] = "netfilter",
|
||||
[BPF_TCX_INGRESS] = "tcx_ingress",
|
||||
[BPF_TCX_EGRESS] = "tcx_egress",
|
||||
};
|
||||
|
||||
static const char * const link_type_name[] = {
|
||||
@@ -8696,9 +8698,13 @@ static const struct bpf_sec_def section_defs[] = {
|
||||
SEC_DEF("ksyscall+", KPROBE, 0, SEC_NONE, attach_ksyscall),
|
||||
SEC_DEF("kretsyscall+", KPROBE, 0, SEC_NONE, attach_ksyscall),
|
||||
SEC_DEF("usdt+", KPROBE, 0, SEC_NONE, attach_usdt),
|
||||
SEC_DEF("tc", SCHED_CLS, 0, SEC_NONE),
|
||||
SEC_DEF("classifier", SCHED_CLS, 0, SEC_NONE),
|
||||
SEC_DEF("action", SCHED_ACT, 0, SEC_NONE),
|
||||
SEC_DEF("tc/ingress", SCHED_CLS, BPF_TCX_INGRESS, SEC_NONE), /* alias for tcx */
|
||||
SEC_DEF("tc/egress", SCHED_CLS, BPF_TCX_EGRESS, SEC_NONE), /* alias for tcx */
|
||||
SEC_DEF("tcx/ingress", SCHED_CLS, BPF_TCX_INGRESS, SEC_NONE),
|
||||
SEC_DEF("tcx/egress", SCHED_CLS, BPF_TCX_EGRESS, SEC_NONE),
|
||||
SEC_DEF("tc", SCHED_CLS, 0, SEC_NONE), /* deprecated / legacy, use tcx */
|
||||
SEC_DEF("classifier", SCHED_CLS, 0, SEC_NONE), /* deprecated / legacy, use tcx */
|
||||
SEC_DEF("action", SCHED_ACT, 0, SEC_NONE), /* deprecated / legacy, use tcx */
|
||||
SEC_DEF("tracepoint+", TRACEPOINT, 0, SEC_NONE, attach_tp),
|
||||
SEC_DEF("tp+", TRACEPOINT, 0, SEC_NONE, attach_tp),
|
||||
SEC_DEF("raw_tracepoint+", RAW_TRACEPOINT, 0, SEC_NONE, attach_raw_tp),
|
||||
|
||||
Reference in New Issue
Block a user