libbpf: support sockopt hooks
authorStanislav Fomichev <sdf@google.com>
Thu, 27 Jun 2019 20:38:49 +0000 (13:38 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 27 Jun 2019 22:25:17 +0000 (15:25 -0700)
Make libbpf aware of new sockopt hooks so it can derive prog type
and hook point from the section names.

Cc: Andrii Nakryiko <andriin@fb.com>
Cc: Martin Lau <kafai@fb.com>
Signed-off-by: Stanislav Fomichev <sdf@google.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/lib/bpf/libbpf.c
tools/lib/bpf/libbpf_probes.c

index 5186b7710430bacfdbd261e86a7352a7cf75f18f..6e6ebef11ba3492c25676231a2e6d5a2bfb2cd55 100644 (file)
@@ -2646,6 +2646,7 @@ static bool bpf_prog_type__needs_kver(enum bpf_prog_type type)
        case BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE:
        case BPF_PROG_TYPE_PERF_EVENT:
        case BPF_PROG_TYPE_CGROUP_SYSCTL:
+       case BPF_PROG_TYPE_CGROUP_SOCKOPT:
                return false;
        case BPF_PROG_TYPE_KPROBE:
        default:
@@ -3604,6 +3605,10 @@ static const struct {
                                                BPF_CGROUP_UDP6_RECVMSG),
        BPF_EAPROG_SEC("cgroup/sysctl",         BPF_PROG_TYPE_CGROUP_SYSCTL,
                                                BPF_CGROUP_SYSCTL),
+       BPF_EAPROG_SEC("cgroup/getsockopt",     BPF_PROG_TYPE_CGROUP_SOCKOPT,
+                                               BPF_CGROUP_GETSOCKOPT),
+       BPF_EAPROG_SEC("cgroup/setsockopt",     BPF_PROG_TYPE_CGROUP_SOCKOPT,
+                                               BPF_CGROUP_SETSOCKOPT),
 };
 
 #undef BPF_PROG_SEC_IMPL
index 6635a31a7a164e7d03cdd697b599774d9c360969..ace1a0708d990792dba80e9c3789171d4d5ea4bc 100644 (file)
@@ -101,6 +101,7 @@ probe_load(enum bpf_prog_type prog_type, const struct bpf_insn *insns,
        case BPF_PROG_TYPE_SK_REUSEPORT:
        case BPF_PROG_TYPE_FLOW_DISSECTOR:
        case BPF_PROG_TYPE_CGROUP_SYSCTL:
+       case BPF_PROG_TYPE_CGROUP_SOCKOPT:
        default:
                break;
        }