]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - tools/lib/bpf/bpf.c
libbpf: Auto-detect btf_id of BTF-based raw_tracepoints
[linux.git] / tools / lib / bpf / bpf.c
index cbb933532981f0923b2d37ac3acacf1d5e428b46..79046067720f7b6027c430264e6edbca916c082f 100644 (file)
@@ -228,6 +228,9 @@ int bpf_load_program_xattr(const struct bpf_load_program_attr *load_attr,
        memset(&attr, 0, sizeof(attr));
        attr.prog_type = load_attr->prog_type;
        attr.expected_attach_type = load_attr->expected_attach_type;
+       if (attr.prog_type == BPF_PROG_TYPE_RAW_TRACEPOINT)
+               /* expected_attach_type is ignored for tracing progs */
+               attr.attach_btf_id = attr.expected_attach_type;
        attr.insn_cnt = (__u32)load_attr->insns_cnt;
        attr.insns = ptr_to_u64(load_attr->insns);
        attr.license = ptr_to_u64(load_attr->license);