• Andrii Nakryiko's avatar
    bpf: pass whole link instead of prog when triggering raw tracepoint · d4dfc570
    Andrii Nakryiko authored
    Instead of passing prog as an argument to bpf_trace_runX() helpers, that
    are called from tracepoint triggering calls, store BPF link itself
    (struct bpf_raw_tp_link for raw tracepoints). This will allow to pass
    extra information like BPF cookie into raw tracepoint registration.
    
    Instead of replacing `struct bpf_prog *prog = __data;` with
    corresponding `struct bpf_raw_tp_link *link = __data;` assignment in
    `__bpf_trace_##call` I just passed `__data` through into underlying
    bpf_trace_runX() call. This works well because we implicitly cast `void *`,
    and it also avoids naming clashes with arguments coming from
    tracepoint's "proto" list. We could have run into the same problem with
    "prog", we just happened to not have a tracepoint that has "prog" input
    argument. We are less lucky with "link", as there are tracepoints using
    "link" argument name already. So instead of trying to avoid naming
    conflicts, let's just remove intermediate local variable. It doesn't
    hurt readibility, it's either way a bit of a maze of calls and macros,
    that requires careful reading.
    Acked-by: default avatarStanislav Fomichev <sdf@google.com>
    Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
    Message-ID: <20240319233852.1977493-3-andrii@kernel.org>
    Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    d4dfc570
bpf_probe.h 4.27 KB