libbpf: Deprecate xdp_cpumap, xdp_devmap and classifier sec definitions
authorLorenzo Bianconi <lorenzo@kernel.org>
Tue, 1 Feb 2022 14:58:08 +0000 (15:58 +0100)
committerAndrii Nakryiko <andrii@kernel.org>
Tue, 1 Feb 2022 17:51:31 +0000 (09:51 -0800)
Deprecate xdp_cpumap, xdp_devmap and classifier sec definitions.
Introduce xdp/devmap and xdp/cpumap definitions according to the
standard for SEC("") in libbpf:
- prog_type.prog_flags/attach_place

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/5c7bd9426b3ce6a31d9a4b1f97eb299e1467fc52.1643727185.git.lorenzo@kernel.org
tools/lib/bpf/libbpf.c

index 4ce94f4..1b0936b 100644 (file)
@@ -237,6 +237,8 @@ enum sec_def_flags {
        SEC_SLOPPY_PFX = 16,
        /* BPF program support non-linear XDP buffer */
        SEC_XDP_FRAGS = 32,
+       /* deprecated sec definitions not supposed to be used */
+       SEC_DEPRECATED = 64,
 };
 
 struct bpf_sec_def {
@@ -6575,6 +6577,10 @@ static int libbpf_preload_prog(struct bpf_program *prog,
        if (prog->type == BPF_PROG_TYPE_XDP && (def & SEC_XDP_FRAGS))
                opts->prog_flags |= BPF_F_XDP_HAS_FRAGS;
 
+       if (def & SEC_DEPRECATED)
+               pr_warn("SEC(\"%s\") is deprecated, please see https://github.com/libbpf/libbpf/wiki/Libbpf-1.0-migration-guide#bpf-program-sec-annotation-deprecations for details\n",
+                       prog->sec_name);
+
        if ((prog->type == BPF_PROG_TYPE_TRACING ||
             prog->type == BPF_PROG_TYPE_LSM ||
             prog->type == BPF_PROG_TYPE_EXT) && !prog->attach_btf_id) {
@@ -8596,7 +8602,7 @@ static const struct bpf_sec_def section_defs[] = {
        SEC_DEF("kretprobe/",           KPROBE, 0, SEC_NONE, attach_kprobe),
        SEC_DEF("uretprobe/",           KPROBE, 0, SEC_NONE),
        SEC_DEF("tc",                   SCHED_CLS, 0, SEC_NONE),
-       SEC_DEF("classifier",           SCHED_CLS, 0, SEC_NONE | SEC_SLOPPY_PFX),
+       SEC_DEF("classifier",           SCHED_CLS, 0, SEC_NONE | SEC_SLOPPY_PFX | SEC_DEPRECATED),
        SEC_DEF("action",               SCHED_ACT, 0, SEC_NONE | SEC_SLOPPY_PFX),
        SEC_DEF("tracepoint/",          TRACEPOINT, 0, SEC_NONE, attach_tp),
        SEC_DEF("tp/",                  TRACEPOINT, 0, SEC_NONE, attach_tp),
@@ -8618,9 +8624,11 @@ static const struct bpf_sec_def section_defs[] = {
        SEC_DEF("iter.s/",              TRACING, BPF_TRACE_ITER, SEC_ATTACH_BTF | SEC_SLEEPABLE, attach_iter),
        SEC_DEF("syscall",              SYSCALL, 0, SEC_SLEEPABLE),
        SEC_DEF("xdp.frags/devmap",     XDP, BPF_XDP_DEVMAP, SEC_XDP_FRAGS),
-       SEC_DEF("xdp_devmap/",          XDP, BPF_XDP_DEVMAP, SEC_ATTACHABLE),
+       SEC_DEF("xdp/devmap",           XDP, BPF_XDP_DEVMAP, SEC_ATTACHABLE),
+       SEC_DEF("xdp_devmap/",          XDP, BPF_XDP_DEVMAP, SEC_ATTACHABLE | SEC_DEPRECATED),
        SEC_DEF("xdp.frags/cpumap",     XDP, BPF_XDP_CPUMAP, SEC_XDP_FRAGS),
-       SEC_DEF("xdp_cpumap/",          XDP, BPF_XDP_CPUMAP, SEC_ATTACHABLE),
+       SEC_DEF("xdp/cpumap",           XDP, BPF_XDP_CPUMAP, SEC_ATTACHABLE),
+       SEC_DEF("xdp_cpumap/",          XDP, BPF_XDP_CPUMAP, SEC_ATTACHABLE | SEC_DEPRECATED),
        SEC_DEF("xdp.frags",            XDP, BPF_XDP, SEC_XDP_FRAGS),
        SEC_DEF("xdp",                  XDP, BPF_XDP, SEC_ATTACHABLE_OPT | SEC_SLOPPY_PFX),
        SEC_DEF("perf_event",           PERF_EVENT, 0, SEC_NONE | SEC_SLOPPY_PFX),