Re: [PATCH bpf-next v8 4/5] libbpf: Init kprobe prog expected_attach_type for kfunc probe
From: Andrii Nakryiko
Date: Mon Feb 24 2025 - 20:15:50 EST
On Mon, Feb 24, 2025 at 9:03 AM Tao Chen <chen.dylane@xxxxxxxxx> wrote:
>
> Kprobe prog type kfuncs like bpf_session_is_return and
> bpf_session_cookie will check the expected_attach_type,
> so init the expected_attach_type here.
>
> Signed-off-by: Tao Chen <chen.dylane@xxxxxxxxx>
> ---
> tools/lib/bpf/libbpf_probes.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/tools/lib/bpf/libbpf_probes.c b/tools/lib/bpf/libbpf_probes.c
> index 8efebc18a215..bb5b457ddc80 100644
> --- a/tools/lib/bpf/libbpf_probes.c
> +++ b/tools/lib/bpf/libbpf_probes.c
> @@ -126,6 +126,7 @@ static int probe_prog_load(enum bpf_prog_type prog_type,
> break;
> case BPF_PROG_TYPE_KPROBE:
> opts.kern_version = get_kernel_version();
> + opts.expected_attach_type = BPF_TRACE_KPROBE_SESSION;
so KPROBE_SESSION is relative recent feature, if we unconditionally
specify this, we'll regress some feature probes for old kernels where
KPROBE_SESSION isn't supported, no?
pw-bot: cr
> break;
> case BPF_PROG_TYPE_LIRC_MODE2:
> opts.expected_attach_type = BPF_LIRC_MODE2;
> --
> 2.43.0
>