On Wed, 16 Jan 2019 14:21:14 +0000, Quentin Monnet wrote:
> diff --git a/tools/lib/bpf/libbpf.map b/tools/lib/bpf/libbpf.map
> index cd02cd4e2cc3..6355e4c80a86 100644
> --- a/tools/lib/bpf/libbpf.map
> +++ b/tools/lib/bpf/libbpf.map
> @@ -56,6 +56,7 @@ LIBBPF_0.0.1 {
> bpf_object__unpin_maps;
> bpf_object__unpin_programs;
> bpf_perf_event_read_simple;
> + bpf_probe_prog_type;
I think you have to start a new 0.0.2 section now, no?
> bpf_prog_attach;
> bpf_prog_detach;
> bpf_prog_detach2;
> +bool bpf_probe_prog_type(enum bpf_prog_type prog_type, __u32 ifindex)
> +{
> + struct bpf_insn insns[2] = {
> + BPF_MOV64_IMM(BPF_REG_0, 0),
> + BPF_EXIT_INSN()
> + };
> +
> + if (ifindex && prog_type == BPF_PROG_TYPE_SCHED_CLS)
> + /* nfp returns -EINVAL on exit(0) with TC offload */
> + insns[0].imm = 2;
> +
> + errno = 0;
> + prog_load(prog_type, insns, ARRAY_SIZE(insns), NULL, 0, ifindex);
> +
> + return errno != EINVAL && errno != EOPNOTSUPP;
nit: could you check that errno in the function doing the load? :|
also perhaps name that function probe_load()?
> +}