selftests/bpf: Switch SEC("classifier*") usage to a strict SEC("tc")
authorAndrii Nakryiko <andrii@kernel.org>
Tue, 28 Sep 2021 16:19:39 +0000 (09:19 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 28 Sep 2021 20:51:19 +0000 (13:51 -0700)
Convert all SEC("classifier*") uses to a new and strict SEC("tc")
section name. In reference_tracking selftests switch from ambiguous
searching by program title (section name) to non-ambiguous searching by
name in some selftests, getting closer to completely removing
bpf_object__find_program_by_title().

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20210928161946.2512801-4-andrii@kernel.org
39 files changed:
tools/testing/selftests/bpf/prog_tests/reference_tracking.c
tools/testing/selftests/bpf/prog_tests/sk_assign.c
tools/testing/selftests/bpf/prog_tests/tailcalls.c
tools/testing/selftests/bpf/progs/for_each_array_map_elem.c
tools/testing/selftests/bpf/progs/for_each_hash_map_elem.c
tools/testing/selftests/bpf/progs/kfunc_call_test.c
tools/testing/selftests/bpf/progs/kfunc_call_test_subprog.c
tools/testing/selftests/bpf/progs/skb_pkt_end.c
tools/testing/selftests/bpf/progs/tailcall1.c
tools/testing/selftests/bpf/progs/tailcall2.c
tools/testing/selftests/bpf/progs/tailcall3.c
tools/testing/selftests/bpf/progs/tailcall4.c
tools/testing/selftests/bpf/progs/tailcall5.c
tools/testing/selftests/bpf/progs/tailcall6.c
tools/testing/selftests/bpf/progs/tailcall_bpf2bpf1.c
tools/testing/selftests/bpf/progs/tailcall_bpf2bpf2.c
tools/testing/selftests/bpf/progs/tailcall_bpf2bpf3.c
tools/testing/selftests/bpf/progs/tailcall_bpf2bpf4.c
tools/testing/selftests/bpf/progs/test_btf_skc_cls_ingress.c
tools/testing/selftests/bpf/progs/test_check_mtu.c
tools/testing/selftests/bpf/progs/test_cls_redirect.c
tools/testing/selftests/bpf/progs/test_global_data.c
tools/testing/selftests/bpf/progs/test_global_func1.c
tools/testing/selftests/bpf/progs/test_global_func3.c
tools/testing/selftests/bpf/progs/test_global_func5.c
tools/testing/selftests/bpf/progs/test_global_func6.c
tools/testing/selftests/bpf/progs/test_global_func7.c
tools/testing/selftests/bpf/progs/test_pkt_access.c
tools/testing/selftests/bpf/progs/test_pkt_md_access.c
tools/testing/selftests/bpf/progs/test_sk_assign.c
tools/testing/selftests/bpf/progs/test_sk_lookup_kern.c
tools/testing/selftests/bpf/progs/test_skb_helpers.c
tools/testing/selftests/bpf/progs/test_sockmap_update.c
tools/testing/selftests/bpf/progs/test_tc_bpf.c
tools/testing/selftests/bpf/progs/test_tc_neigh.c
tools/testing/selftests/bpf/progs/test_tc_neigh_fib.c
tools/testing/selftests/bpf/progs/test_tc_peer.c
tools/testing/selftests/bpf/progs/test_tcp_check_syncookie_kern.c
tools/testing/selftests/bpf/test_tcp_check_syncookie.sh

index ded2dc8..873323f 100644 (file)
@@ -2,14 +2,14 @@
 #include <test_progs.h>
 
 static void toggle_object_autoload_progs(const struct bpf_object *obj,
-                                        const char *title_load)
+                                        const char *name_load)
 {
        struct bpf_program *prog;
 
        bpf_object__for_each_program(prog, obj) {
-               const char *title = bpf_program__section_name(prog);
+               const char *name = bpf_program__name(prog);
 
-               if (!strcmp(title_load, title))
+               if (!strcmp(name_load, name))
                        bpf_program__set_autoload(prog, true);
                else
                        bpf_program__set_autoload(prog, false);
@@ -39,23 +39,19 @@ void test_reference_tracking(void)
                goto cleanup;
 
        bpf_object__for_each_program(prog, obj_iter) {
-               const char *title;
+               const char *name;
 
-               /* Ignore .text sections */
-               title = bpf_program__section_name(prog);
-               if (strstr(title, ".text") != NULL)
-                       continue;
-
-               if (!test__start_subtest(title))
+               name = bpf_program__name(prog);
+               if (!test__start_subtest(name))
                        continue;
 
                obj = bpf_object__open_file(file, &open_opts);
                if (!ASSERT_OK_PTR(obj, "obj_open_file"))
                        goto cleanup;
 
-               toggle_object_autoload_progs(obj, title);
+               toggle_object_autoload_progs(obj, name);
                /* Expect verifier failure if test name has 'err' */
-               if (strstr(title, "err_") != NULL) {
+               if (strncmp(name, "err_", sizeof("err_") - 1) == 0) {
                        libbpf_print_fn_t old_print_fn;
 
                        old_print_fn = libbpf_set_print(NULL);
@@ -64,7 +60,8 @@ void test_reference_tracking(void)
                } else {
                        err = bpf_object__load(obj);
                }
-               CHECK(err, title, "\n");
+               ASSERT_OK(err, name);
+
                bpf_object__close(obj);
                obj = NULL;
        }
index 3a46909..1d272e0 100644 (file)
@@ -48,7 +48,7 @@ configure_stack(void)
                return false;
        sprintf(tc_cmd, "%s %s %s %s", "tc filter add dev lo ingress bpf",
                       "direct-action object-file ./test_sk_assign.o",
-                      "section classifier/sk_assign_test",
+                      "section tc",
                       (env.verbosity < VERBOSE_VERY) ? " 2>/dev/null" : "verbose");
        if (CHECK(system(tc_cmd), "BPF load failed;",
                  "run with -vv for more info\n"))
index 7bf3a7a..9825f1f 100644 (file)
@@ -21,7 +21,7 @@ static void test_tailcall_1(void)
        if (CHECK_FAIL(err))
                return;
 
-       prog = bpf_object__find_program_by_title(obj, "classifier");
+       prog = bpf_object__find_program_by_name(obj, "entry");
        if (CHECK_FAIL(!prog))
                goto out;
 
@@ -38,9 +38,9 @@ static void test_tailcall_1(void)
                goto out;
 
        for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) {
-               snprintf(prog_name, sizeof(prog_name), "classifier/%i", i);
+               snprintf(prog_name, sizeof(prog_name), "classifier_%d", i);
 
-               prog = bpf_object__find_program_by_title(obj, prog_name);
+               prog = bpf_object__find_program_by_name(obj, prog_name);
                if (CHECK_FAIL(!prog))
                        goto out;
 
@@ -70,9 +70,9 @@ static void test_tailcall_1(void)
              err, errno, retval);
 
        for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) {
-               snprintf(prog_name, sizeof(prog_name), "classifier/%i", i);
+               snprintf(prog_name, sizeof(prog_name), "classifier_%d", i);
 
-               prog = bpf_object__find_program_by_title(obj, prog_name);
+               prog = bpf_object__find_program_by_name(obj, prog_name);
                if (CHECK_FAIL(!prog))
                        goto out;
 
@@ -92,9 +92,9 @@ static void test_tailcall_1(void)
 
        for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) {
                j = bpf_map__def(prog_array)->max_entries - 1 - i;
-               snprintf(prog_name, sizeof(prog_name), "classifier/%i", j);
+               snprintf(prog_name, sizeof(prog_name), "classifier_%d", j);
 
-               prog = bpf_object__find_program_by_title(obj, prog_name);
+               prog = bpf_object__find_program_by_name(obj, prog_name);
                if (CHECK_FAIL(!prog))
                        goto out;
 
@@ -159,7 +159,7 @@ static void test_tailcall_2(void)
        if (CHECK_FAIL(err))
                return;
 
-       prog = bpf_object__find_program_by_title(obj, "classifier");
+       prog = bpf_object__find_program_by_name(obj, "entry");
        if (CHECK_FAIL(!prog))
                goto out;
 
@@ -176,9 +176,9 @@ static void test_tailcall_2(void)
                goto out;
 
        for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) {
-               snprintf(prog_name, sizeof(prog_name), "classifier/%i", i);
+               snprintf(prog_name, sizeof(prog_name), "classifier_%d", i);
 
-               prog = bpf_object__find_program_by_title(obj, prog_name);
+               prog = bpf_object__find_program_by_name(obj, prog_name);
                if (CHECK_FAIL(!prog))
                        goto out;
 
@@ -233,7 +233,7 @@ static void test_tailcall_count(const char *which)
        if (CHECK_FAIL(err))
                return;
 
-       prog = bpf_object__find_program_by_title(obj, "classifier");
+       prog = bpf_object__find_program_by_name(obj, "entry");
        if (CHECK_FAIL(!prog))
                goto out;
 
@@ -249,7 +249,7 @@ static void test_tailcall_count(const char *which)
        if (CHECK_FAIL(map_fd < 0))
                goto out;
 
-       prog = bpf_object__find_program_by_title(obj, "classifier/0");
+       prog = bpf_object__find_program_by_name(obj, "classifier_0");
        if (CHECK_FAIL(!prog))
                goto out;
 
@@ -329,7 +329,7 @@ static void test_tailcall_4(void)
        if (CHECK_FAIL(err))
                return;
 
-       prog = bpf_object__find_program_by_title(obj, "classifier");
+       prog = bpf_object__find_program_by_name(obj, "entry");
        if (CHECK_FAIL(!prog))
                goto out;
 
@@ -354,9 +354,9 @@ static void test_tailcall_4(void)
                return;
 
        for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) {
-               snprintf(prog_name, sizeof(prog_name), "classifier/%i", i);
+               snprintf(prog_name, sizeof(prog_name), "classifier_%d", i);
 
-               prog = bpf_object__find_program_by_title(obj, prog_name);
+               prog = bpf_object__find_program_by_name(obj, prog_name);
                if (CHECK_FAIL(!prog))
                        goto out;
 
@@ -417,7 +417,7 @@ static void test_tailcall_5(void)
        if (CHECK_FAIL(err))
                return;
 
-       prog = bpf_object__find_program_by_title(obj, "classifier");
+       prog = bpf_object__find_program_by_name(obj, "entry");
        if (CHECK_FAIL(!prog))
                goto out;
 
@@ -442,9 +442,9 @@ static void test_tailcall_5(void)
                return;
 
        for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) {
-               snprintf(prog_name, sizeof(prog_name), "classifier/%i", i);
+               snprintf(prog_name, sizeof(prog_name), "classifier_%d", i);
 
-               prog = bpf_object__find_program_by_title(obj, prog_name);
+               prog = bpf_object__find_program_by_name(obj, prog_name);
                if (CHECK_FAIL(!prog))
                        goto out;
 
@@ -503,7 +503,7 @@ static void test_tailcall_bpf2bpf_1(void)
        if (CHECK_FAIL(err))
                return;
 
-       prog = bpf_object__find_program_by_title(obj, "classifier");
+       prog = bpf_object__find_program_by_name(obj, "entry");
        if (CHECK_FAIL(!prog))
                goto out;
 
@@ -521,9 +521,9 @@ static void test_tailcall_bpf2bpf_1(void)
 
        /* nop -> jmp */
        for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) {
-               snprintf(prog_name, sizeof(prog_name), "classifier/%i", i);
+               snprintf(prog_name, sizeof(prog_name), "classifier_%d", i);
 
-               prog = bpf_object__find_program_by_title(obj, prog_name);
+               prog = bpf_object__find_program_by_name(obj, prog_name);
                if (CHECK_FAIL(!prog))
                        goto out;
 
@@ -587,7 +587,7 @@ static void test_tailcall_bpf2bpf_2(void)
        if (CHECK_FAIL(err))
                return;
 
-       prog = bpf_object__find_program_by_title(obj, "classifier");
+       prog = bpf_object__find_program_by_name(obj, "entry");
        if (CHECK_FAIL(!prog))
                goto out;
 
@@ -603,7 +603,7 @@ static void test_tailcall_bpf2bpf_2(void)
        if (CHECK_FAIL(map_fd < 0))
                goto out;
 
-       prog = bpf_object__find_program_by_title(obj, "classifier/0");
+       prog = bpf_object__find_program_by_name(obj, "classifier_0");
        if (CHECK_FAIL(!prog))
                goto out;
 
@@ -665,7 +665,7 @@ static void test_tailcall_bpf2bpf_3(void)
        if (CHECK_FAIL(err))
                return;
 
-       prog = bpf_object__find_program_by_title(obj, "classifier");
+       prog = bpf_object__find_program_by_name(obj, "entry");
        if (CHECK_FAIL(!prog))
                goto out;
 
@@ -682,9 +682,9 @@ static void test_tailcall_bpf2bpf_3(void)
                goto out;
 
        for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) {
-               snprintf(prog_name, sizeof(prog_name), "classifier/%i", i);
+               snprintf(prog_name, sizeof(prog_name), "classifier_%d", i);
 
-               prog = bpf_object__find_program_by_title(obj, prog_name);
+               prog = bpf_object__find_program_by_name(obj, prog_name);
                if (CHECK_FAIL(!prog))
                        goto out;
 
@@ -762,7 +762,7 @@ static void test_tailcall_bpf2bpf_4(bool noise)
        if (CHECK_FAIL(err))
                return;
 
-       prog = bpf_object__find_program_by_title(obj, "classifier");
+       prog = bpf_object__find_program_by_name(obj, "entry");
        if (CHECK_FAIL(!prog))
                goto out;
 
@@ -779,9 +779,9 @@ static void test_tailcall_bpf2bpf_4(bool noise)
                goto out;
 
        for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) {
-               snprintf(prog_name, sizeof(prog_name), "classifier/%i", i);
+               snprintf(prog_name, sizeof(prog_name), "classifier_%d", i);
 
-               prog = bpf_object__find_program_by_title(obj, prog_name);
+               prog = bpf_object__find_program_by_name(obj, prog_name);
                if (CHECK_FAIL(!prog))
                        goto out;
 
index 75e8e10..df918b2 100644 (file)
@@ -47,7 +47,7 @@ check_percpu_elem(struct bpf_map *map, __u32 *key, __u64 *val,
 
 u32 arraymap_output = 0;
 
-SEC("classifier")
+SEC("tc")
 int test_pkt_access(struct __sk_buff *skb)
 {
        struct callback_ctx data;
index 913dd91..276994d 100644 (file)
@@ -78,7 +78,7 @@ int hashmap_output = 0;
 int hashmap_elems = 0;
 int percpu_map_elems = 0;
 
-SEC("classifier")
+SEC("tc")
 int test_pkt_access(struct __sk_buff *skb)
 {
        struct callback_ctx data;
index 470f872..8a8cf59 100644 (file)
@@ -8,7 +8,7 @@ extern int bpf_kfunc_call_test2(struct sock *sk, __u32 a, __u32 b) __ksym;
 extern __u64 bpf_kfunc_call_test1(struct sock *sk, __u32 a, __u64 b,
                                  __u32 c, __u64 d) __ksym;
 
-SEC("classifier")
+SEC("tc")
 int kfunc_call_test2(struct __sk_buff *skb)
 {
        struct bpf_sock *sk = skb->sk;
@@ -23,7 +23,7 @@ int kfunc_call_test2(struct __sk_buff *skb)
        return bpf_kfunc_call_test2((struct sock *)sk, 1, 2);
 }
 
-SEC("classifier")
+SEC("tc")
 int kfunc_call_test1(struct __sk_buff *skb)
 {
        struct bpf_sock *sk = skb->sk;
index 5fbd9e2..c1fdeca 100644 (file)
@@ -33,7 +33,7 @@ int __noinline f1(struct __sk_buff *skb)
        return (__u32)bpf_kfunc_call_test1((struct sock *)sk, 1, 2, 3, 4);
 }
 
-SEC("classifier")
+SEC("tc")
 int kfunc_call_test1(struct __sk_buff *skb)
 {
        return f1(skb);
index 7f2eaa2..992b786 100644 (file)
@@ -25,7 +25,7 @@ out:
        return ip;
 }
 
-SEC("classifier/cls")
+SEC("tc")
 int main_prog(struct __sk_buff *skb)
 {
        struct iphdr *ip = NULL;
index 7115bce..8159a0b 100644 (file)
@@ -11,8 +11,8 @@ struct {
 } jmp_table SEC(".maps");
 
 #define TAIL_FUNC(x)                           \
-       SEC("classifier/" #x)                   \
-       int bpf_func_##x(struct __sk_buff *skb) \
+       SEC("tc")                               \
+       int classifier_##x(struct __sk_buff *skb)       \
        {                                       \
                return x;                       \
        }
@@ -20,7 +20,7 @@ TAIL_FUNC(0)
 TAIL_FUNC(1)
 TAIL_FUNC(2)
 
-SEC("classifier")
+SEC("tc")
 int entry(struct __sk_buff *skb)
 {
        /* Multiple locations to make sure we patch
@@ -45,4 +45,3 @@ int entry(struct __sk_buff *skb)
 }
 
 char __license[] SEC("license") = "GPL";
-int _version SEC("version") = 1;
index 0431e4f..a5ff53e 100644 (file)
@@ -10,41 +10,41 @@ struct {
        __uint(value_size, sizeof(__u32));
 } jmp_table SEC(".maps");
 
-SEC("classifier/0")
-int bpf_func_0(struct __sk_buff *skb)
+SEC("tc")
+int classifier_0(struct __sk_buff *skb)
 {
        bpf_tail_call_static(skb, &jmp_table, 1);
        return 0;
 }
 
-SEC("classifier/1")
-int bpf_func_1(struct __sk_buff *skb)
+SEC("tc")
+int classifier_1(struct __sk_buff *skb)
 {
        bpf_tail_call_static(skb, &jmp_table, 2);
        return 1;
 }
 
-SEC("classifier/2")
-int bpf_func_2(struct __sk_buff *skb)
+SEC("tc")
+int classifier_2(struct __sk_buff *skb)
 {
        return 2;
 }
 
-SEC("classifier/3")
-int bpf_func_3(struct __sk_buff *skb)
+SEC("tc")
+int classifier_3(struct __sk_buff *skb)
 {
        bpf_tail_call_static(skb, &jmp_table, 4);
        return 3;
 }
 
-SEC("classifier/4")
-int bpf_func_4(struct __sk_buff *skb)
+SEC("tc")
+int classifier_4(struct __sk_buff *skb)
 {
        bpf_tail_call_static(skb, &jmp_table, 3);
        return 4;
 }
 
-SEC("classifier")
+SEC("tc")
 int entry(struct __sk_buff *skb)
 {
        bpf_tail_call_static(skb, &jmp_table, 0);
@@ -56,4 +56,3 @@ int entry(struct __sk_buff *skb)
 }
 
 char __license[] SEC("license") = "GPL";
-int _version SEC("version") = 1;
index 910858f..f60bcd7 100644 (file)
@@ -12,15 +12,15 @@ struct {
 
 int count = 0;
 
-SEC("classifier/0")
-int bpf_func_0(struct __sk_buff *skb)
+SEC("tc")
+int classifier_0(struct __sk_buff *skb)
 {
        count++;
        bpf_tail_call_static(skb, &jmp_table, 0);
        return 1;
 }
 
-SEC("classifier")
+SEC("tc")
 int entry(struct __sk_buff *skb)
 {
        bpf_tail_call_static(skb, &jmp_table, 0);
@@ -28,4 +28,3 @@ int entry(struct __sk_buff *skb)
 }
 
 char __license[] SEC("license") = "GPL";
-int _version SEC("version") = 1;
index bd4be13..a56bbc2 100644 (file)
@@ -13,8 +13,8 @@ struct {
 int selector = 0;
 
 #define TAIL_FUNC(x)                           \
-       SEC("classifier/" #x)                   \
-       int bpf_func_##x(struct __sk_buff *skb) \
+       SEC("tc")                               \
+       int classifier_##x(struct __sk_buff *skb)       \
        {                                       \
                return x;                       \
        }
@@ -22,7 +22,7 @@ TAIL_FUNC(0)
 TAIL_FUNC(1)
 TAIL_FUNC(2)
 
-SEC("classifier")
+SEC("tc")
 int entry(struct __sk_buff *skb)
 {
        bpf_tail_call(skb, &jmp_table, selector);
@@ -30,4 +30,3 @@ int entry(struct __sk_buff *skb)
 }
 
 char __license[] SEC("license") = "GPL";
-int _version SEC("version") = 1;
index adf30a3..8d03496 100644 (file)
@@ -13,8 +13,8 @@ struct {
 int selector = 0;
 
 #define TAIL_FUNC(x)                           \
-       SEC("classifier/" #x)                   \
-       int bpf_func_##x(struct __sk_buff *skb) \
+       SEC("tc")                               \
+       int classifier_##x(struct __sk_buff *skb)       \
        {                                       \
                return x;                       \
        }
@@ -22,7 +22,7 @@ TAIL_FUNC(0)
 TAIL_FUNC(1)
 TAIL_FUNC(2)
 
-SEC("classifier")
+SEC("tc")
 int entry(struct __sk_buff *skb)
 {
        int idx = 0;
@@ -37,4 +37,3 @@ int entry(struct __sk_buff *skb)
 }
 
 char __license[] SEC("license") = "GPL";
-int _version SEC("version") = 1;
index 0f4a811..d77b8ab 100644 (file)
@@ -12,8 +12,8 @@ struct {
 
 int count, which;
 
-SEC("classifier/0")
-int bpf_func_0(struct __sk_buff *skb)
+SEC("tc")
+int classifier_0(struct __sk_buff *skb)
 {
        count++;
        if (__builtin_constant_p(which))
@@ -22,7 +22,7 @@ int bpf_func_0(struct __sk_buff *skb)
        return 1;
 }
 
-SEC("classifier")
+SEC("tc")
 int entry(struct __sk_buff *skb)
 {
        if (__builtin_constant_p(which))
index 0103f3d..8c91428 100644 (file)
@@ -10,8 +10,8 @@ struct {
 } jmp_table SEC(".maps");
 
 #define TAIL_FUNC(x)                           \
-       SEC("classifier/" #x)                   \
-       int bpf_func_##x(struct __sk_buff *skb) \
+       SEC("tc")                               \
+       int classifier_##x(struct __sk_buff *skb)       \
        {                                       \
                return x;                       \
        }
@@ -26,7 +26,7 @@ int subprog_tail(struct __sk_buff *skb)
        return skb->len * 2;
 }
 
-SEC("classifier")
+SEC("tc")
 int entry(struct __sk_buff *skb)
 {
        bpf_tail_call_static(skb, &jmp_table, 1);
@@ -35,4 +35,3 @@ int entry(struct __sk_buff *skb)
 }
 
 char __license[] SEC("license") = "GPL";
-int _version SEC("version") = 1;
index 3cc4c12..ce97d14 100644 (file)
@@ -22,14 +22,14 @@ int subprog_tail(struct __sk_buff *skb)
 
 int count = 0;
 
-SEC("classifier/0")
-int bpf_func_0(struct __sk_buff *skb)
+SEC("tc")
+int classifier_0(struct __sk_buff *skb)
 {
        count++;
        return subprog_tail(skb);
 }
 
-SEC("classifier")
+SEC("tc")
 int entry(struct __sk_buff *skb)
 {
        bpf_tail_call_static(skb, &jmp_table, 0);
@@ -38,4 +38,3 @@ int entry(struct __sk_buff *skb)
 }
 
 char __license[] SEC("license") = "GPL";
-int _version SEC("version") = 1;
index 0d5482b..7fab39a 100644 (file)
@@ -33,23 +33,23 @@ int subprog_tail(struct __sk_buff *skb)
        return skb->len * 2;
 }
 
-SEC("classifier/0")
-int bpf_func_0(struct __sk_buff *skb)
+SEC("tc")
+int classifier_0(struct __sk_buff *skb)
 {
        volatile char arr[128] = {};
 
        return subprog_tail2(skb);
 }
 
-SEC("classifier/1")
-int bpf_func_1(struct __sk_buff *skb)
+SEC("tc")
+int classifier_1(struct __sk_buff *skb)
 {
        volatile char arr[128] = {};
 
        return skb->len * 3;
 }
 
-SEC("classifier")
+SEC("tc")
 int entry(struct __sk_buff *skb)
 {
        volatile char arr[128] = {};
@@ -58,4 +58,3 @@ int entry(struct __sk_buff *skb)
 }
 
 char __license[] SEC("license") = "GPL";
-int _version SEC("version") = 1;
index e89368a..b67e802 100644 (file)
@@ -50,30 +50,29 @@ int subprog_tail(struct __sk_buff *skb)
        return skb->len;
 }
 
-SEC("classifier/1")
-int bpf_func_1(struct __sk_buff *skb)
+SEC("tc")
+int classifier_1(struct __sk_buff *skb)
 {
        return subprog_tail_2(skb);
 }
 
-SEC("classifier/2")
-int bpf_func_2(struct __sk_buff *skb)
+SEC("tc")
+int classifier_2(struct __sk_buff *skb)
 {
        count++;
        return subprog_tail_2(skb);
 }
 
-SEC("classifier/0")
-int bpf_func_0(struct __sk_buff *skb)
+SEC("tc")
+int classifier_0(struct __sk_buff *skb)
 {
        return subprog_tail_1(skb);
 }
 
-SEC("classifier")
+SEC("tc")
 int entry(struct __sk_buff *skb)
 {
        return subprog_tail(skb);
 }
 
 char __license[] SEC("license") = "GPL";
-int _version SEC("version") = 1;
index 9a6b85d..e2bea4d 100644 (file)
@@ -145,7 +145,7 @@ release:
        return TC_ACT_OK;
 }
 
-SEC("classifier/ingress")
+SEC("tc")
 int cls_ingress(struct __sk_buff *skb)
 {
        struct ipv6hdr *ip6h;
index 71184af..2ec1de1 100644 (file)
@@ -153,7 +153,7 @@ int xdp_input_len_exceed(struct xdp_md *ctx)
        return retval;
 }
 
-SEC("classifier")
+SEC("tc")
 int tc_use_helper(struct __sk_buff *ctx)
 {
        int retval = BPF_OK; /* Expected retval on successful test */
@@ -172,7 +172,7 @@ out:
        return retval;
 }
 
-SEC("classifier")
+SEC("tc")
 int tc_exceed_mtu(struct __sk_buff *ctx)
 {
        __u32 ifindex = GLOBAL_USER_IFINDEX;
@@ -196,7 +196,7 @@ int tc_exceed_mtu(struct __sk_buff *ctx)
        return retval;
 }
 
-SEC("classifier")
+SEC("tc")
 int tc_exceed_mtu_da(struct __sk_buff *ctx)
 {
        /* SKB Direct-Access variant */
@@ -223,7 +223,7 @@ int tc_exceed_mtu_da(struct __sk_buff *ctx)
        return retval;
 }
 
-SEC("classifier")
+SEC("tc")
 int tc_minus_delta(struct __sk_buff *ctx)
 {
        int retval = BPF_OK; /* Expected retval on successful test */
@@ -245,7 +245,7 @@ int tc_minus_delta(struct __sk_buff *ctx)
        return retval;
 }
 
-SEC("classifier")
+SEC("tc")
 int tc_input_len(struct __sk_buff *ctx)
 {
        int retval = BPF_OK; /* Expected retval on successful test */
@@ -265,7 +265,7 @@ int tc_input_len(struct __sk_buff *ctx)
        return retval;
 }
 
-SEC("classifier")
+SEC("tc")
 int tc_input_len_exceed(struct __sk_buff *ctx)
 {
        int retval = BPF_DROP; /* Fail */
index e2a5acc..2833ad7 100644 (file)
@@ -928,7 +928,7 @@ static INLINING verdict_t process_ipv6(buf_t *pkt, metrics_t *metrics)
        }
 }
 
-SEC("classifier/cls_redirect")
+SEC("tc")
 int cls_redirect(struct __sk_buff *skb)
 {
        metrics_t *metrics = get_global_metrics();
index 1319be1..719e314 100644 (file)
@@ -68,7 +68,7 @@ static struct foo struct3 = {
                bpf_map_update_elem(&result_##map, &key, var, 0);       \
        } while (0)
 
-SEC("classifier/static_data_load")
+SEC("tc")
 int load_static_data(struct __sk_buff *skb)
 {
        static const __u64 bar = ~0;
index 880260f..7b42dad 100644 (file)
@@ -38,7 +38,7 @@ int f3(int val, struct __sk_buff *skb, int var)
        return skb->ifindex * val * var;
 }
 
-SEC("classifier/test")
+SEC("tc")
 int test_cls(struct __sk_buff *skb)
 {
        return f0(1, skb) + f1(skb) + f2(2, skb) + f3(3, skb, 4);
index 86f0ecb..01bf827 100644 (file)
@@ -54,7 +54,7 @@ int f8(struct __sk_buff *skb)
 }
 #endif
 
-SEC("classifier/test")
+SEC("tc")
 int test_cls(struct __sk_buff *skb)
 {
 #ifndef NO_FN8
index 260c25b..9248d03 100644 (file)
@@ -24,7 +24,7 @@ int f3(int val, struct __sk_buff *skb)
        return skb->ifindex * val;
 }
 
-SEC("classifier/test")
+SEC("tc")
 int test_cls(struct __sk_buff *skb)
 {
        return f1(skb) + f2(2, skb) + f3(3, skb);
index 69e19c6..af8c78b 100644 (file)
@@ -24,7 +24,7 @@ int f3(int val, struct __sk_buff *skb)
        return skb->ifindex * val;
 }
 
-SEC("classifier/test")
+SEC("tc")
 int test_cls(struct __sk_buff *skb)
 {
        return f1(skb) + f2(2, skb) + f3(3, skb);
index 309b3f6..6cb8e2f 100644 (file)
@@ -10,7 +10,7 @@ void foo(struct __sk_buff *skb)
        skb->tc_index = 0;
 }
 
-SEC("classifier/test")
+SEC("tc")
 int test_cls(struct __sk_buff *skb)
 {
        foo(skb);
index 8520510..3cfd881 100644 (file)
@@ -97,7 +97,7 @@ int test_pkt_write_access_subprog(struct __sk_buff *skb, __u32 off)
        return 0;
 }
 
-SEC("classifier/test_pkt_access")
+SEC("tc")
 int test_pkt_access(struct __sk_buff *skb)
 {
        void *data_end = (void *)(long)skb->data_end;
index 610c74e..d183936 100644 (file)
@@ -7,8 +7,6 @@
 #include <linux/pkt_cls.h>
 #include <bpf/bpf_helpers.h>
 
-int _version SEC("version") = 1;
-
 #if  __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
 #define TEST_FIELD(TYPE, FIELD, MASK)                                  \
        {                                                               \
@@ -27,7 +25,7 @@ int _version SEC("version") = 1;
        }
 #endif
 
-SEC("classifier/test_pkt_md_access")
+SEC("tc")
 int test_pkt_md_access(struct __sk_buff *skb)
 {
        TEST_FIELD(__u8,  len, 0xFF);
index 1ecd987..02f7935 100644 (file)
@@ -36,7 +36,6 @@ struct {
        .pinning = PIN_GLOBAL_NS,
 };
 
-int _version SEC("version") = 1;
 char _license[] SEC("license") = "GPL";
 
 /* Fill 'tuple' with L3 info, and attempt to find L4. On fail, return NULL. */
@@ -159,7 +158,7 @@ assign:
        return ret;
 }
 
-SEC("classifier/sk_assign_test")
+SEC("tc")
 int bpf_sk_assign_test(struct __sk_buff *skb)
 {
        struct bpf_sock_tuple *tuple, ln = {0};
index 8249075..40f1614 100644 (file)
@@ -15,7 +15,6 @@
 #include <bpf/bpf_helpers.h>
 #include <bpf/bpf_endian.h>
 
-int _version SEC("version") = 1;
 char _license[] SEC("license") = "GPL";
 
 /* Fill 'tuple' with L3 info, and attempt to find L4. On fail, return NULL. */
@@ -53,8 +52,8 @@ static struct bpf_sock_tuple *get_tuple(void *data, __u64 nh_off,
        return result;
 }
 
-SEC("classifier/sk_lookup_success")
-int bpf_sk_lookup_test0(struct __sk_buff *skb)
+SEC("tc")
+int sk_lookup_success(struct __sk_buff *skb)
 {
        void *data_end = (void *)(long)skb->data_end;
        void *data = (void *)(long)skb->data;
@@ -79,8 +78,8 @@ int bpf_sk_lookup_test0(struct __sk_buff *skb)
        return sk ? TC_ACT_OK : TC_ACT_UNSPEC;
 }
 
-SEC("classifier/sk_lookup_success_simple")
-int bpf_sk_lookup_test1(struct __sk_buff *skb)
+SEC("tc")
+int sk_lookup_success_simple(struct __sk_buff *skb)
 {
        struct bpf_sock_tuple tuple = {};
        struct bpf_sock *sk;
@@ -91,8 +90,8 @@ int bpf_sk_lookup_test1(struct __sk_buff *skb)
        return 0;
 }
 
-SEC("classifier/err_use_after_free")
-int bpf_sk_lookup_uaf(struct __sk_buff *skb)
+SEC("tc")
+int err_use_after_free(struct __sk_buff *skb)
 {
        struct bpf_sock_tuple tuple = {};
        struct bpf_sock *sk;
@@ -106,8 +105,8 @@ int bpf_sk_lookup_uaf(struct __sk_buff *skb)
        return family;
 }
 
-SEC("classifier/err_modify_sk_pointer")
-int bpf_sk_lookup_modptr(struct __sk_buff *skb)
+SEC("tc")
+int err_modify_sk_pointer(struct __sk_buff *skb)
 {
        struct bpf_sock_tuple tuple = {};
        struct bpf_sock *sk;
@@ -121,8 +120,8 @@ int bpf_sk_lookup_modptr(struct __sk_buff *skb)
        return 0;
 }
 
-SEC("classifier/err_modify_sk_or_null_pointer")
-int bpf_sk_lookup_modptr_or_null(struct __sk_buff *skb)
+SEC("tc")
+int err_modify_sk_or_null_pointer(struct __sk_buff *skb)
 {
        struct bpf_sock_tuple tuple = {};
        struct bpf_sock *sk;
@@ -135,8 +134,8 @@ int bpf_sk_lookup_modptr_or_null(struct __sk_buff *skb)
        return 0;
 }
 
-SEC("classifier/err_no_release")
-int bpf_sk_lookup_test2(struct __sk_buff *skb)
+SEC("tc")
+int err_no_release(struct __sk_buff *skb)
 {
        struct bpf_sock_tuple tuple = {};
 
@@ -144,8 +143,8 @@ int bpf_sk_lookup_test2(struct __sk_buff *skb)
        return 0;
 }
 
-SEC("classifier/err_release_twice")
-int bpf_sk_lookup_test3(struct __sk_buff *skb)
+SEC("tc")
+int err_release_twice(struct __sk_buff *skb)
 {
        struct bpf_sock_tuple tuple = {};
        struct bpf_sock *sk;
@@ -156,8 +155,8 @@ int bpf_sk_lookup_test3(struct __sk_buff *skb)
        return 0;
 }
 
-SEC("classifier/err_release_unchecked")
-int bpf_sk_lookup_test4(struct __sk_buff *skb)
+SEC("tc")
+int err_release_unchecked(struct __sk_buff *skb)
 {
        struct bpf_sock_tuple tuple = {};
        struct bpf_sock *sk;
@@ -173,8 +172,8 @@ void lookup_no_release(struct __sk_buff *skb)
        bpf_sk_lookup_tcp(skb, &tuple, sizeof(tuple), BPF_F_CURRENT_NETNS, 0);
 }
 
-SEC("classifier/err_no_release_subcall")
-int bpf_sk_lookup_test5(struct __sk_buff *skb)
+SEC("tc")
+int err_no_release_subcall(struct __sk_buff *skb)
 {
        lookup_no_release(skb);
        return 0;
index bb3fbf1..5072157 100644 (file)
@@ -14,7 +14,7 @@ struct {
 
 char _license[] SEC("license") = "GPL";
 
-SEC("classifier/test_skb_helpers")
+SEC("tc")
 int test_skb_helpers(struct __sk_buff *skb)
 {
        struct task_struct *task;
index 9d0c9f2..6d64ea5 100644 (file)
@@ -24,7 +24,7 @@ struct {
        __type(value, __u64);
 } dst_sock_hash SEC(".maps");
 
-SEC("classifier/copy_sock_map")
+SEC("tc")
 int copy_sock_map(void *ctx)
 {
        struct bpf_sock *sk;
index 18a3a7e..d28ca8d 100644 (file)
@@ -5,7 +5,7 @@
 
 /* Dummy prog to test TC-BPF API */
 
-SEC("classifier")
+SEC("tc")
 int cls(struct __sk_buff *skb)
 {
        return 0;
index 0c93d32..3e32ea3 100644 (file)
@@ -70,7 +70,7 @@ static __always_inline bool is_remote_ep_v6(struct __sk_buff *skb,
        return v6_equal(ip6h->daddr, addr);
 }
 
-SEC("classifier/chk_egress")
+SEC("tc")
 int tc_chk(struct __sk_buff *skb)
 {
        void *data_end = ctx_ptr(skb->data_end);
@@ -83,7 +83,7 @@ int tc_chk(struct __sk_buff *skb)
        return !raw[0] && !raw[1] && !raw[2] ? TC_ACT_SHOT : TC_ACT_OK;
 }
 
-SEC("classifier/dst_ingress")
+SEC("tc")
 int tc_dst(struct __sk_buff *skb)
 {
        __u8 zero[ETH_ALEN * 2];
@@ -108,7 +108,7 @@ int tc_dst(struct __sk_buff *skb)
        return bpf_redirect_neigh(IFINDEX_SRC, NULL, 0, 0);
 }
 
-SEC("classifier/src_ingress")
+SEC("tc")
 int tc_src(struct __sk_buff *skb)
 {
        __u8 zero[ETH_ALEN * 2];
index f7ab69c..ec4cce1 100644 (file)
@@ -75,7 +75,7 @@ static __always_inline int fill_fib_params_v6(struct __sk_buff *skb,
        return 0;
 }
 
-SEC("classifier/chk_egress")
+SEC("tc")
 int tc_chk(struct __sk_buff *skb)
 {
        void *data_end = ctx_ptr(skb->data_end);
@@ -143,13 +143,13 @@ static __always_inline int tc_redir(struct __sk_buff *skb)
 /* these are identical, but keep them separate for compatibility with the
  * section names expected by test_tc_redirect.sh
  */
-SEC("classifier/dst_ingress")
+SEC("tc")
 int tc_dst(struct __sk_buff *skb)
 {
        return tc_redir(skb);
 }
 
-SEC("classifier/src_ingress")
+SEC("tc")
 int tc_src(struct __sk_buff *skb)
 {
        return tc_redir(skb);
index fe818cd..365eacb 100644 (file)
@@ -16,31 +16,31 @@ volatile const __u32 IFINDEX_DST;
 static const __u8 src_mac[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55};
 static const __u8 dst_mac[] = {0x00, 0x22, 0x33, 0x44, 0x55, 0x66};
 
-SEC("classifier/chk_egress")
+SEC("tc")
 int tc_chk(struct __sk_buff *skb)
 {
        return TC_ACT_SHOT;
 }
 
-SEC("classifier/dst_ingress")
+SEC("tc")
 int tc_dst(struct __sk_buff *skb)
 {
        return bpf_redirect_peer(IFINDEX_SRC, 0);
 }
 
-SEC("classifier/src_ingress")
+SEC("tc")
 int tc_src(struct __sk_buff *skb)
 {
        return bpf_redirect_peer(IFINDEX_DST, 0);
 }
 
-SEC("classifier/dst_ingress_l3")
+SEC("tc")
 int tc_dst_l3(struct __sk_buff *skb)
 {
        return bpf_redirect(IFINDEX_SRC, 0);
 }
 
-SEC("classifier/src_ingress_l3")
+SEC("tc")
 int tc_src_l3(struct __sk_buff *skb)
 {
        __u16 proto = skb->protocol;
index fac7ef9..cd747cd 100644 (file)
@@ -148,7 +148,7 @@ release:
        bpf_sk_release(sk);
 }
 
-SEC("clsact/check_syncookie")
+SEC("tc")
 int check_syncookie_clsact(struct __sk_buff *skb)
 {
        check_syncookie(skb, (void *)(long)skb->data,
index fed7651..6413c14 100755 (executable)
@@ -76,7 +76,7 @@ DIR=$(dirname $0)
 TEST_IF=lo
 MAX_PING_TRIES=5
 BPF_PROG_OBJ="${DIR}/test_tcp_check_syncookie_kern.o"
-CLSACT_SECTION="clsact/check_syncookie"
+CLSACT_SECTION="tc"
 XDP_SECTION="xdp"
 BPF_PROG_ID=0
 PROG="${DIR}/test_tcp_check_syncookie_user"