Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/bpf: Switch SEC("classifier*") usage to a strict SEC("tc")

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

authored by

Andrii Nakryiko and committed by
Alexei Starovoitov
c22bdd28 8fffa0e3

+141 -157
+10 -13
tools/testing/selftests/bpf/prog_tests/reference_tracking.c
··· 2 2 #include <test_progs.h> 3 3 4 4 static void toggle_object_autoload_progs(const struct bpf_object *obj, 5 - const char *title_load) 5 + const char *name_load) 6 6 { 7 7 struct bpf_program *prog; 8 8 9 9 bpf_object__for_each_program(prog, obj) { 10 - const char *title = bpf_program__section_name(prog); 10 + const char *name = bpf_program__name(prog); 11 11 12 - if (!strcmp(title_load, title)) 12 + if (!strcmp(name_load, name)) 13 13 bpf_program__set_autoload(prog, true); 14 14 else 15 15 bpf_program__set_autoload(prog, false); ··· 39 39 goto cleanup; 40 40 41 41 bpf_object__for_each_program(prog, obj_iter) { 42 - const char *title; 42 + const char *name; 43 43 44 - /* Ignore .text sections */ 45 - title = bpf_program__section_name(prog); 46 - if (strstr(title, ".text") != NULL) 47 - continue; 48 - 49 - if (!test__start_subtest(title)) 44 + name = bpf_program__name(prog); 45 + if (!test__start_subtest(name)) 50 46 continue; 51 47 52 48 obj = bpf_object__open_file(file, &open_opts); 53 49 if (!ASSERT_OK_PTR(obj, "obj_open_file")) 54 50 goto cleanup; 55 51 56 - toggle_object_autoload_progs(obj, title); 52 + toggle_object_autoload_progs(obj, name); 57 53 /* Expect verifier failure if test name has 'err' */ 58 - if (strstr(title, "err_") != NULL) { 54 + if (strncmp(name, "err_", sizeof("err_") - 1) == 0) { 59 55 libbpf_print_fn_t old_print_fn; 60 56 61 57 old_print_fn = libbpf_set_print(NULL); ··· 60 64 } else { 61 65 err = bpf_object__load(obj); 62 66 } 63 - CHECK(err, title, "\n"); 67 + ASSERT_OK(err, name); 68 + 64 69 bpf_object__close(obj); 65 70 obj = NULL; 66 71 }
+1 -1
tools/testing/selftests/bpf/prog_tests/sk_assign.c
··· 48 48 return false; 49 49 sprintf(tc_cmd, "%s %s %s %s", "tc filter add dev lo ingress bpf", 50 50 "direct-action object-file ./test_sk_assign.o", 51 - "section classifier/sk_assign_test", 51 + "section tc", 52 52 (env.verbosity < VERBOSE_VERY) ? " 2>/dev/null" : "verbose"); 53 53 if (CHECK(system(tc_cmd), "BPF load failed;", 54 54 "run with -vv for more info\n"))
+29 -29
tools/testing/selftests/bpf/prog_tests/tailcalls.c
··· 21 21 if (CHECK_FAIL(err)) 22 22 return; 23 23 24 - prog = bpf_object__find_program_by_title(obj, "classifier"); 24 + prog = bpf_object__find_program_by_name(obj, "entry"); 25 25 if (CHECK_FAIL(!prog)) 26 26 goto out; 27 27 ··· 38 38 goto out; 39 39 40 40 for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) { 41 - snprintf(prog_name, sizeof(prog_name), "classifier/%i", i); 41 + snprintf(prog_name, sizeof(prog_name), "classifier_%d", i); 42 42 43 - prog = bpf_object__find_program_by_title(obj, prog_name); 43 + prog = bpf_object__find_program_by_name(obj, prog_name); 44 44 if (CHECK_FAIL(!prog)) 45 45 goto out; 46 46 ··· 70 70 err, errno, retval); 71 71 72 72 for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) { 73 - snprintf(prog_name, sizeof(prog_name), "classifier/%i", i); 73 + snprintf(prog_name, sizeof(prog_name), "classifier_%d", i); 74 74 75 - prog = bpf_object__find_program_by_title(obj, prog_name); 75 + prog = bpf_object__find_program_by_name(obj, prog_name); 76 76 if (CHECK_FAIL(!prog)) 77 77 goto out; 78 78 ··· 92 92 93 93 for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) { 94 94 j = bpf_map__def(prog_array)->max_entries - 1 - i; 95 - snprintf(prog_name, sizeof(prog_name), "classifier/%i", j); 95 + snprintf(prog_name, sizeof(prog_name), "classifier_%d", j); 96 96 97 - prog = bpf_object__find_program_by_title(obj, prog_name); 97 + prog = bpf_object__find_program_by_name(obj, prog_name); 98 98 if (CHECK_FAIL(!prog)) 99 99 goto out; 100 100 ··· 159 159 if (CHECK_FAIL(err)) 160 160 return; 161 161 162 - prog = bpf_object__find_program_by_title(obj, "classifier"); 162 + prog = bpf_object__find_program_by_name(obj, "entry"); 163 163 if (CHECK_FAIL(!prog)) 164 164 goto out; 165 165 ··· 176 176 goto out; 177 177 178 178 for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) { 179 - snprintf(prog_name, sizeof(prog_name), "classifier/%i", i); 179 + snprintf(prog_name, sizeof(prog_name), "classifier_%d", i); 180 180 181 - prog = bpf_object__find_program_by_title(obj, prog_name); 181 + prog = bpf_object__find_program_by_name(obj, prog_name); 182 182 if (CHECK_FAIL(!prog)) 183 183 goto out; 184 184 ··· 233 233 if (CHECK_FAIL(err)) 234 234 return; 235 235 236 - prog = bpf_object__find_program_by_title(obj, "classifier"); 236 + prog = bpf_object__find_program_by_name(obj, "entry"); 237 237 if (CHECK_FAIL(!prog)) 238 238 goto out; 239 239 ··· 249 249 if (CHECK_FAIL(map_fd < 0)) 250 250 goto out; 251 251 252 - prog = bpf_object__find_program_by_title(obj, "classifier/0"); 252 + prog = bpf_object__find_program_by_name(obj, "classifier_0"); 253 253 if (CHECK_FAIL(!prog)) 254 254 goto out; 255 255 ··· 329 329 if (CHECK_FAIL(err)) 330 330 return; 331 331 332 - prog = bpf_object__find_program_by_title(obj, "classifier"); 332 + prog = bpf_object__find_program_by_name(obj, "entry"); 333 333 if (CHECK_FAIL(!prog)) 334 334 goto out; 335 335 ··· 354 354 return; 355 355 356 356 for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) { 357 - snprintf(prog_name, sizeof(prog_name), "classifier/%i", i); 357 + snprintf(prog_name, sizeof(prog_name), "classifier_%d", i); 358 358 359 - prog = bpf_object__find_program_by_title(obj, prog_name); 359 + prog = bpf_object__find_program_by_name(obj, prog_name); 360 360 if (CHECK_FAIL(!prog)) 361 361 goto out; 362 362 ··· 417 417 if (CHECK_FAIL(err)) 418 418 return; 419 419 420 - prog = bpf_object__find_program_by_title(obj, "classifier"); 420 + prog = bpf_object__find_program_by_name(obj, "entry"); 421 421 if (CHECK_FAIL(!prog)) 422 422 goto out; 423 423 ··· 442 442 return; 443 443 444 444 for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) { 445 - snprintf(prog_name, sizeof(prog_name), "classifier/%i", i); 445 + snprintf(prog_name, sizeof(prog_name), "classifier_%d", i); 446 446 447 - prog = bpf_object__find_program_by_title(obj, prog_name); 447 + prog = bpf_object__find_program_by_name(obj, prog_name); 448 448 if (CHECK_FAIL(!prog)) 449 449 goto out; 450 450 ··· 503 503 if (CHECK_FAIL(err)) 504 504 return; 505 505 506 - prog = bpf_object__find_program_by_title(obj, "classifier"); 506 + prog = bpf_object__find_program_by_name(obj, "entry"); 507 507 if (CHECK_FAIL(!prog)) 508 508 goto out; 509 509 ··· 521 521 522 522 /* nop -> jmp */ 523 523 for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) { 524 - snprintf(prog_name, sizeof(prog_name), "classifier/%i", i); 524 + snprintf(prog_name, sizeof(prog_name), "classifier_%d", i); 525 525 526 - prog = bpf_object__find_program_by_title(obj, prog_name); 526 + prog = bpf_object__find_program_by_name(obj, prog_name); 527 527 if (CHECK_FAIL(!prog)) 528 528 goto out; 529 529 ··· 587 587 if (CHECK_FAIL(err)) 588 588 return; 589 589 590 - prog = bpf_object__find_program_by_title(obj, "classifier"); 590 + prog = bpf_object__find_program_by_name(obj, "entry"); 591 591 if (CHECK_FAIL(!prog)) 592 592 goto out; 593 593 ··· 603 603 if (CHECK_FAIL(map_fd < 0)) 604 604 goto out; 605 605 606 - prog = bpf_object__find_program_by_title(obj, "classifier/0"); 606 + prog = bpf_object__find_program_by_name(obj, "classifier_0"); 607 607 if (CHECK_FAIL(!prog)) 608 608 goto out; 609 609 ··· 665 665 if (CHECK_FAIL(err)) 666 666 return; 667 667 668 - prog = bpf_object__find_program_by_title(obj, "classifier"); 668 + prog = bpf_object__find_program_by_name(obj, "entry"); 669 669 if (CHECK_FAIL(!prog)) 670 670 goto out; 671 671 ··· 682 682 goto out; 683 683 684 684 for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) { 685 - snprintf(prog_name, sizeof(prog_name), "classifier/%i", i); 685 + snprintf(prog_name, sizeof(prog_name), "classifier_%d", i); 686 686 687 - prog = bpf_object__find_program_by_title(obj, prog_name); 687 + prog = bpf_object__find_program_by_name(obj, prog_name); 688 688 if (CHECK_FAIL(!prog)) 689 689 goto out; 690 690 ··· 762 762 if (CHECK_FAIL(err)) 763 763 return; 764 764 765 - prog = bpf_object__find_program_by_title(obj, "classifier"); 765 + prog = bpf_object__find_program_by_name(obj, "entry"); 766 766 if (CHECK_FAIL(!prog)) 767 767 goto out; 768 768 ··· 779 779 goto out; 780 780 781 781 for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) { 782 - snprintf(prog_name, sizeof(prog_name), "classifier/%i", i); 782 + snprintf(prog_name, sizeof(prog_name), "classifier_%d", i); 783 783 784 - prog = bpf_object__find_program_by_title(obj, prog_name); 784 + prog = bpf_object__find_program_by_name(obj, prog_name); 785 785 if (CHECK_FAIL(!prog)) 786 786 goto out; 787 787
+1 -1
tools/testing/selftests/bpf/progs/for_each_array_map_elem.c
··· 47 47 48 48 u32 arraymap_output = 0; 49 49 50 - SEC("classifier") 50 + SEC("tc") 51 51 int test_pkt_access(struct __sk_buff *skb) 52 52 { 53 53 struct callback_ctx data;
+1 -1
tools/testing/selftests/bpf/progs/for_each_hash_map_elem.c
··· 78 78 int hashmap_elems = 0; 79 79 int percpu_map_elems = 0; 80 80 81 - SEC("classifier") 81 + SEC("tc") 82 82 int test_pkt_access(struct __sk_buff *skb) 83 83 { 84 84 struct callback_ctx data;
+2 -2
tools/testing/selftests/bpf/progs/kfunc_call_test.c
··· 8 8 extern __u64 bpf_kfunc_call_test1(struct sock *sk, __u32 a, __u64 b, 9 9 __u32 c, __u64 d) __ksym; 10 10 11 - SEC("classifier") 11 + SEC("tc") 12 12 int kfunc_call_test2(struct __sk_buff *skb) 13 13 { 14 14 struct bpf_sock *sk = skb->sk; ··· 23 23 return bpf_kfunc_call_test2((struct sock *)sk, 1, 2); 24 24 } 25 25 26 - SEC("classifier") 26 + SEC("tc") 27 27 int kfunc_call_test1(struct __sk_buff *skb) 28 28 { 29 29 struct bpf_sock *sk = skb->sk;
+1 -1
tools/testing/selftests/bpf/progs/kfunc_call_test_subprog.c
··· 33 33 return (__u32)bpf_kfunc_call_test1((struct sock *)sk, 1, 2, 3, 4); 34 34 } 35 35 36 - SEC("classifier") 36 + SEC("tc") 37 37 int kfunc_call_test1(struct __sk_buff *skb) 38 38 { 39 39 return f1(skb);
+1 -1
tools/testing/selftests/bpf/progs/skb_pkt_end.c
··· 25 25 return ip; 26 26 } 27 27 28 - SEC("classifier/cls") 28 + SEC("tc") 29 29 int main_prog(struct __sk_buff *skb) 30 30 { 31 31 struct iphdr *ip = NULL;
+3 -4
tools/testing/selftests/bpf/progs/tailcall1.c
··· 11 11 } jmp_table SEC(".maps"); 12 12 13 13 #define TAIL_FUNC(x) \ 14 - SEC("classifier/" #x) \ 15 - int bpf_func_##x(struct __sk_buff *skb) \ 14 + SEC("tc") \ 15 + int classifier_##x(struct __sk_buff *skb) \ 16 16 { \ 17 17 return x; \ 18 18 } ··· 20 20 TAIL_FUNC(1) 21 21 TAIL_FUNC(2) 22 22 23 - SEC("classifier") 23 + SEC("tc") 24 24 int entry(struct __sk_buff *skb) 25 25 { 26 26 /* Multiple locations to make sure we patch ··· 45 45 } 46 46 47 47 char __license[] SEC("license") = "GPL"; 48 - int _version SEC("version") = 1;
+11 -12
tools/testing/selftests/bpf/progs/tailcall2.c
··· 10 10 __uint(value_size, sizeof(__u32)); 11 11 } jmp_table SEC(".maps"); 12 12 13 - SEC("classifier/0") 14 - int bpf_func_0(struct __sk_buff *skb) 13 + SEC("tc") 14 + int classifier_0(struct __sk_buff *skb) 15 15 { 16 16 bpf_tail_call_static(skb, &jmp_table, 1); 17 17 return 0; 18 18 } 19 19 20 - SEC("classifier/1") 21 - int bpf_func_1(struct __sk_buff *skb) 20 + SEC("tc") 21 + int classifier_1(struct __sk_buff *skb) 22 22 { 23 23 bpf_tail_call_static(skb, &jmp_table, 2); 24 24 return 1; 25 25 } 26 26 27 - SEC("classifier/2") 28 - int bpf_func_2(struct __sk_buff *skb) 27 + SEC("tc") 28 + int classifier_2(struct __sk_buff *skb) 29 29 { 30 30 return 2; 31 31 } 32 32 33 - SEC("classifier/3") 34 - int bpf_func_3(struct __sk_buff *skb) 33 + SEC("tc") 34 + int classifier_3(struct __sk_buff *skb) 35 35 { 36 36 bpf_tail_call_static(skb, &jmp_table, 4); 37 37 return 3; 38 38 } 39 39 40 - SEC("classifier/4") 41 - int bpf_func_4(struct __sk_buff *skb) 40 + SEC("tc") 41 + int classifier_4(struct __sk_buff *skb) 42 42 { 43 43 bpf_tail_call_static(skb, &jmp_table, 3); 44 44 return 4; 45 45 } 46 46 47 - SEC("classifier") 47 + SEC("tc") 48 48 int entry(struct __sk_buff *skb) 49 49 { 50 50 bpf_tail_call_static(skb, &jmp_table, 0); ··· 56 56 } 57 57 58 58 char __license[] SEC("license") = "GPL"; 59 - int _version SEC("version") = 1;
+3 -4
tools/testing/selftests/bpf/progs/tailcall3.c
··· 12 12 13 13 int count = 0; 14 14 15 - SEC("classifier/0") 16 - int bpf_func_0(struct __sk_buff *skb) 15 + SEC("tc") 16 + int classifier_0(struct __sk_buff *skb) 17 17 { 18 18 count++; 19 19 bpf_tail_call_static(skb, &jmp_table, 0); 20 20 return 1; 21 21 } 22 22 23 - SEC("classifier") 23 + SEC("tc") 24 24 int entry(struct __sk_buff *skb) 25 25 { 26 26 bpf_tail_call_static(skb, &jmp_table, 0); ··· 28 28 } 29 29 30 30 char __license[] SEC("license") = "GPL"; 31 - int _version SEC("version") = 1;
+3 -4
tools/testing/selftests/bpf/progs/tailcall4.c
··· 13 13 int selector = 0; 14 14 15 15 #define TAIL_FUNC(x) \ 16 - SEC("classifier/" #x) \ 17 - int bpf_func_##x(struct __sk_buff *skb) \ 16 + SEC("tc") \ 17 + int classifier_##x(struct __sk_buff *skb) \ 18 18 { \ 19 19 return x; \ 20 20 } ··· 22 22 TAIL_FUNC(1) 23 23 TAIL_FUNC(2) 24 24 25 - SEC("classifier") 25 + SEC("tc") 26 26 int entry(struct __sk_buff *skb) 27 27 { 28 28 bpf_tail_call(skb, &jmp_table, selector); ··· 30 30 } 31 31 32 32 char __license[] SEC("license") = "GPL"; 33 - int _version SEC("version") = 1;
+3 -4
tools/testing/selftests/bpf/progs/tailcall5.c
··· 13 13 int selector = 0; 14 14 15 15 #define TAIL_FUNC(x) \ 16 - SEC("classifier/" #x) \ 17 - int bpf_func_##x(struct __sk_buff *skb) \ 16 + SEC("tc") \ 17 + int classifier_##x(struct __sk_buff *skb) \ 18 18 { \ 19 19 return x; \ 20 20 } ··· 22 22 TAIL_FUNC(1) 23 23 TAIL_FUNC(2) 24 24 25 - SEC("classifier") 25 + SEC("tc") 26 26 int entry(struct __sk_buff *skb) 27 27 { 28 28 int idx = 0; ··· 37 37 } 38 38 39 39 char __license[] SEC("license") = "GPL"; 40 - int _version SEC("version") = 1;
+3 -3
tools/testing/selftests/bpf/progs/tailcall6.c
··· 12 12 13 13 int count, which; 14 14 15 - SEC("classifier/0") 16 - int bpf_func_0(struct __sk_buff *skb) 15 + SEC("tc") 16 + int classifier_0(struct __sk_buff *skb) 17 17 { 18 18 count++; 19 19 if (__builtin_constant_p(which)) ··· 22 22 return 1; 23 23 } 24 24 25 - SEC("classifier") 25 + SEC("tc") 26 26 int entry(struct __sk_buff *skb) 27 27 { 28 28 if (__builtin_constant_p(which))
+3 -4
tools/testing/selftests/bpf/progs/tailcall_bpf2bpf1.c
··· 10 10 } jmp_table SEC(".maps"); 11 11 12 12 #define TAIL_FUNC(x) \ 13 - SEC("classifier/" #x) \ 14 - int bpf_func_##x(struct __sk_buff *skb) \ 13 + SEC("tc") \ 14 + int classifier_##x(struct __sk_buff *skb) \ 15 15 { \ 16 16 return x; \ 17 17 } ··· 26 26 return skb->len * 2; 27 27 } 28 28 29 - SEC("classifier") 29 + SEC("tc") 30 30 int entry(struct __sk_buff *skb) 31 31 { 32 32 bpf_tail_call_static(skb, &jmp_table, 1); ··· 35 35 } 36 36 37 37 char __license[] SEC("license") = "GPL"; 38 - int _version SEC("version") = 1;
+3 -4
tools/testing/selftests/bpf/progs/tailcall_bpf2bpf2.c
··· 22 22 23 23 int count = 0; 24 24 25 - SEC("classifier/0") 26 - int bpf_func_0(struct __sk_buff *skb) 25 + SEC("tc") 26 + int classifier_0(struct __sk_buff *skb) 27 27 { 28 28 count++; 29 29 return subprog_tail(skb); 30 30 } 31 31 32 - SEC("classifier") 32 + SEC("tc") 33 33 int entry(struct __sk_buff *skb) 34 34 { 35 35 bpf_tail_call_static(skb, &jmp_table, 0); ··· 38 38 } 39 39 40 40 char __license[] SEC("license") = "GPL"; 41 - int _version SEC("version") = 1;
+5 -6
tools/testing/selftests/bpf/progs/tailcall_bpf2bpf3.c
··· 33 33 return skb->len * 2; 34 34 } 35 35 36 - SEC("classifier/0") 37 - int bpf_func_0(struct __sk_buff *skb) 36 + SEC("tc") 37 + int classifier_0(struct __sk_buff *skb) 38 38 { 39 39 volatile char arr[128] = {}; 40 40 41 41 return subprog_tail2(skb); 42 42 } 43 43 44 - SEC("classifier/1") 45 - int bpf_func_1(struct __sk_buff *skb) 44 + SEC("tc") 45 + int classifier_1(struct __sk_buff *skb) 46 46 { 47 47 volatile char arr[128] = {}; 48 48 49 49 return skb->len * 3; 50 50 } 51 51 52 - SEC("classifier") 52 + SEC("tc") 53 53 int entry(struct __sk_buff *skb) 54 54 { 55 55 volatile char arr[128] = {}; ··· 58 58 } 59 59 60 60 char __license[] SEC("license") = "GPL"; 61 - int _version SEC("version") = 1;
+7 -8
tools/testing/selftests/bpf/progs/tailcall_bpf2bpf4.c
··· 50 50 return skb->len; 51 51 } 52 52 53 - SEC("classifier/1") 54 - int bpf_func_1(struct __sk_buff *skb) 53 + SEC("tc") 54 + int classifier_1(struct __sk_buff *skb) 55 55 { 56 56 return subprog_tail_2(skb); 57 57 } 58 58 59 - SEC("classifier/2") 60 - int bpf_func_2(struct __sk_buff *skb) 59 + SEC("tc") 60 + int classifier_2(struct __sk_buff *skb) 61 61 { 62 62 count++; 63 63 return subprog_tail_2(skb); 64 64 } 65 65 66 - SEC("classifier/0") 67 - int bpf_func_0(struct __sk_buff *skb) 66 + SEC("tc") 67 + int classifier_0(struct __sk_buff *skb) 68 68 { 69 69 return subprog_tail_1(skb); 70 70 } 71 71 72 - SEC("classifier") 72 + SEC("tc") 73 73 int entry(struct __sk_buff *skb) 74 74 { 75 75 return subprog_tail(skb); 76 76 } 77 77 78 78 char __license[] SEC("license") = "GPL"; 79 - int _version SEC("version") = 1;
+1 -1
tools/testing/selftests/bpf/progs/test_btf_skc_cls_ingress.c
··· 145 145 return TC_ACT_OK; 146 146 } 147 147 148 - SEC("classifier/ingress") 148 + SEC("tc") 149 149 int cls_ingress(struct __sk_buff *skb) 150 150 { 151 151 struct ipv6hdr *ip6h;
+6 -6
tools/testing/selftests/bpf/progs/test_check_mtu.c
··· 153 153 return retval; 154 154 } 155 155 156 - SEC("classifier") 156 + SEC("tc") 157 157 int tc_use_helper(struct __sk_buff *ctx) 158 158 { 159 159 int retval = BPF_OK; /* Expected retval on successful test */ ··· 172 172 return retval; 173 173 } 174 174 175 - SEC("classifier") 175 + SEC("tc") 176 176 int tc_exceed_mtu(struct __sk_buff *ctx) 177 177 { 178 178 __u32 ifindex = GLOBAL_USER_IFINDEX; ··· 196 196 return retval; 197 197 } 198 198 199 - SEC("classifier") 199 + SEC("tc") 200 200 int tc_exceed_mtu_da(struct __sk_buff *ctx) 201 201 { 202 202 /* SKB Direct-Access variant */ ··· 223 223 return retval; 224 224 } 225 225 226 - SEC("classifier") 226 + SEC("tc") 227 227 int tc_minus_delta(struct __sk_buff *ctx) 228 228 { 229 229 int retval = BPF_OK; /* Expected retval on successful test */ ··· 245 245 return retval; 246 246 } 247 247 248 - SEC("classifier") 248 + SEC("tc") 249 249 int tc_input_len(struct __sk_buff *ctx) 250 250 { 251 251 int retval = BPF_OK; /* Expected retval on successful test */ ··· 265 265 return retval; 266 266 } 267 267 268 - SEC("classifier") 268 + SEC("tc") 269 269 int tc_input_len_exceed(struct __sk_buff *ctx) 270 270 { 271 271 int retval = BPF_DROP; /* Fail */
+1 -1
tools/testing/selftests/bpf/progs/test_cls_redirect.c
··· 928 928 } 929 929 } 930 930 931 - SEC("classifier/cls_redirect") 931 + SEC("tc") 932 932 int cls_redirect(struct __sk_buff *skb) 933 933 { 934 934 metrics_t *metrics = get_global_metrics();
+1 -1
tools/testing/selftests/bpf/progs/test_global_data.c
··· 68 68 bpf_map_update_elem(&result_##map, &key, var, 0); \ 69 69 } while (0) 70 70 71 - SEC("classifier/static_data_load") 71 + SEC("tc") 72 72 int load_static_data(struct __sk_buff *skb) 73 73 { 74 74 static const __u64 bar = ~0;
+1 -1
tools/testing/selftests/bpf/progs/test_global_func1.c
··· 38 38 return skb->ifindex * val * var; 39 39 } 40 40 41 - SEC("classifier/test") 41 + SEC("tc") 42 42 int test_cls(struct __sk_buff *skb) 43 43 { 44 44 return f0(1, skb) + f1(skb) + f2(2, skb) + f3(3, skb, 4);
+1 -1
tools/testing/selftests/bpf/progs/test_global_func3.c
··· 54 54 } 55 55 #endif 56 56 57 - SEC("classifier/test") 57 + SEC("tc") 58 58 int test_cls(struct __sk_buff *skb) 59 59 { 60 60 #ifndef NO_FN8
+1 -1
tools/testing/selftests/bpf/progs/test_global_func5.c
··· 24 24 return skb->ifindex * val; 25 25 } 26 26 27 - SEC("classifier/test") 27 + SEC("tc") 28 28 int test_cls(struct __sk_buff *skb) 29 29 { 30 30 return f1(skb) + f2(2, skb) + f3(3, skb);
+1 -1
tools/testing/selftests/bpf/progs/test_global_func6.c
··· 24 24 return skb->ifindex * val; 25 25 } 26 26 27 - SEC("classifier/test") 27 + SEC("tc") 28 28 int test_cls(struct __sk_buff *skb) 29 29 { 30 30 return f1(skb) + f2(2, skb) + f3(3, skb);
+1 -1
tools/testing/selftests/bpf/progs/test_global_func7.c
··· 10 10 skb->tc_index = 0; 11 11 } 12 12 13 - SEC("classifier/test") 13 + SEC("tc") 14 14 int test_cls(struct __sk_buff *skb) 15 15 { 16 16 foo(skb);
+1 -1
tools/testing/selftests/bpf/progs/test_pkt_access.c
··· 97 97 return 0; 98 98 } 99 99 100 - SEC("classifier/test_pkt_access") 100 + SEC("tc") 101 101 int test_pkt_access(struct __sk_buff *skb) 102 102 { 103 103 void *data_end = (void *)(long)skb->data_end;
+1 -3
tools/testing/selftests/bpf/progs/test_pkt_md_access.c
··· 7 7 #include <linux/pkt_cls.h> 8 8 #include <bpf/bpf_helpers.h> 9 9 10 - int _version SEC("version") = 1; 11 - 12 10 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ 13 11 #define TEST_FIELD(TYPE, FIELD, MASK) \ 14 12 { \ ··· 25 27 } 26 28 #endif 27 29 28 - SEC("classifier/test_pkt_md_access") 30 + SEC("tc") 29 31 int test_pkt_md_access(struct __sk_buff *skb) 30 32 { 31 33 TEST_FIELD(__u8, len, 0xFF);
+1 -2
tools/testing/selftests/bpf/progs/test_sk_assign.c
··· 36 36 .pinning = PIN_GLOBAL_NS, 37 37 }; 38 38 39 - int _version SEC("version") = 1; 40 39 char _license[] SEC("license") = "GPL"; 41 40 42 41 /* Fill 'tuple' with L3 info, and attempt to find L4. On fail, return NULL. */ ··· 158 159 return ret; 159 160 } 160 161 161 - SEC("classifier/sk_assign_test") 162 + SEC("tc") 162 163 int bpf_sk_assign_test(struct __sk_buff *skb) 163 164 { 164 165 struct bpf_sock_tuple *tuple, ln = {0};
+18 -19
tools/testing/selftests/bpf/progs/test_sk_lookup_kern.c
··· 15 15 #include <bpf/bpf_helpers.h> 16 16 #include <bpf/bpf_endian.h> 17 17 18 - int _version SEC("version") = 1; 19 18 char _license[] SEC("license") = "GPL"; 20 19 21 20 /* Fill 'tuple' with L3 info, and attempt to find L4. On fail, return NULL. */ ··· 52 53 return result; 53 54 } 54 55 55 - SEC("classifier/sk_lookup_success") 56 - int bpf_sk_lookup_test0(struct __sk_buff *skb) 56 + SEC("tc") 57 + int sk_lookup_success(struct __sk_buff *skb) 57 58 { 58 59 void *data_end = (void *)(long)skb->data_end; 59 60 void *data = (void *)(long)skb->data; ··· 78 79 return sk ? TC_ACT_OK : TC_ACT_UNSPEC; 79 80 } 80 81 81 - SEC("classifier/sk_lookup_success_simple") 82 - int bpf_sk_lookup_test1(struct __sk_buff *skb) 82 + SEC("tc") 83 + int sk_lookup_success_simple(struct __sk_buff *skb) 83 84 { 84 85 struct bpf_sock_tuple tuple = {}; 85 86 struct bpf_sock *sk; ··· 90 91 return 0; 91 92 } 92 93 93 - SEC("classifier/err_use_after_free") 94 - int bpf_sk_lookup_uaf(struct __sk_buff *skb) 94 + SEC("tc") 95 + int err_use_after_free(struct __sk_buff *skb) 95 96 { 96 97 struct bpf_sock_tuple tuple = {}; 97 98 struct bpf_sock *sk; ··· 105 106 return family; 106 107 } 107 108 108 - SEC("classifier/err_modify_sk_pointer") 109 - int bpf_sk_lookup_modptr(struct __sk_buff *skb) 109 + SEC("tc") 110 + int err_modify_sk_pointer(struct __sk_buff *skb) 110 111 { 111 112 struct bpf_sock_tuple tuple = {}; 112 113 struct bpf_sock *sk; ··· 120 121 return 0; 121 122 } 122 123 123 - SEC("classifier/err_modify_sk_or_null_pointer") 124 - int bpf_sk_lookup_modptr_or_null(struct __sk_buff *skb) 124 + SEC("tc") 125 + int err_modify_sk_or_null_pointer(struct __sk_buff *skb) 125 126 { 126 127 struct bpf_sock_tuple tuple = {}; 127 128 struct bpf_sock *sk; ··· 134 135 return 0; 135 136 } 136 137 137 - SEC("classifier/err_no_release") 138 - int bpf_sk_lookup_test2(struct __sk_buff *skb) 138 + SEC("tc") 139 + int err_no_release(struct __sk_buff *skb) 139 140 { 140 141 struct bpf_sock_tuple tuple = {}; 141 142 ··· 143 144 return 0; 144 145 } 145 146 146 - SEC("classifier/err_release_twice") 147 - int bpf_sk_lookup_test3(struct __sk_buff *skb) 147 + SEC("tc") 148 + int err_release_twice(struct __sk_buff *skb) 148 149 { 149 150 struct bpf_sock_tuple tuple = {}; 150 151 struct bpf_sock *sk; ··· 155 156 return 0; 156 157 } 157 158 158 - SEC("classifier/err_release_unchecked") 159 - int bpf_sk_lookup_test4(struct __sk_buff *skb) 159 + SEC("tc") 160 + int err_release_unchecked(struct __sk_buff *skb) 160 161 { 161 162 struct bpf_sock_tuple tuple = {}; 162 163 struct bpf_sock *sk; ··· 172 173 bpf_sk_lookup_tcp(skb, &tuple, sizeof(tuple), BPF_F_CURRENT_NETNS, 0); 173 174 } 174 175 175 - SEC("classifier/err_no_release_subcall") 176 - int bpf_sk_lookup_test5(struct __sk_buff *skb) 176 + SEC("tc") 177 + int err_no_release_subcall(struct __sk_buff *skb) 177 178 { 178 179 lookup_no_release(skb); 179 180 return 0;
+1 -1
tools/testing/selftests/bpf/progs/test_skb_helpers.c
··· 14 14 15 15 char _license[] SEC("license") = "GPL"; 16 16 17 - SEC("classifier/test_skb_helpers") 17 + SEC("tc") 18 18 int test_skb_helpers(struct __sk_buff *skb) 19 19 { 20 20 struct task_struct *task;
+1 -1
tools/testing/selftests/bpf/progs/test_sockmap_update.c
··· 24 24 __type(value, __u64); 25 25 } dst_sock_hash SEC(".maps"); 26 26 27 - SEC("classifier/copy_sock_map") 27 + SEC("tc") 28 28 int copy_sock_map(void *ctx) 29 29 { 30 30 struct bpf_sock *sk;
+1 -1
tools/testing/selftests/bpf/progs/test_tc_bpf.c
··· 5 5 6 6 /* Dummy prog to test TC-BPF API */ 7 7 8 - SEC("classifier") 8 + SEC("tc") 9 9 int cls(struct __sk_buff *skb) 10 10 { 11 11 return 0;
+3 -3
tools/testing/selftests/bpf/progs/test_tc_neigh.c
··· 70 70 return v6_equal(ip6h->daddr, addr); 71 71 } 72 72 73 - SEC("classifier/chk_egress") 73 + SEC("tc") 74 74 int tc_chk(struct __sk_buff *skb) 75 75 { 76 76 void *data_end = ctx_ptr(skb->data_end); ··· 83 83 return !raw[0] && !raw[1] && !raw[2] ? TC_ACT_SHOT : TC_ACT_OK; 84 84 } 85 85 86 - SEC("classifier/dst_ingress") 86 + SEC("tc") 87 87 int tc_dst(struct __sk_buff *skb) 88 88 { 89 89 __u8 zero[ETH_ALEN * 2]; ··· 108 108 return bpf_redirect_neigh(IFINDEX_SRC, NULL, 0, 0); 109 109 } 110 110 111 - SEC("classifier/src_ingress") 111 + SEC("tc") 112 112 int tc_src(struct __sk_buff *skb) 113 113 { 114 114 __u8 zero[ETH_ALEN * 2];
+3 -3
tools/testing/selftests/bpf/progs/test_tc_neigh_fib.c
··· 75 75 return 0; 76 76 } 77 77 78 - SEC("classifier/chk_egress") 78 + SEC("tc") 79 79 int tc_chk(struct __sk_buff *skb) 80 80 { 81 81 void *data_end = ctx_ptr(skb->data_end); ··· 143 143 /* these are identical, but keep them separate for compatibility with the 144 144 * section names expected by test_tc_redirect.sh 145 145 */ 146 - SEC("classifier/dst_ingress") 146 + SEC("tc") 147 147 int tc_dst(struct __sk_buff *skb) 148 148 { 149 149 return tc_redir(skb); 150 150 } 151 151 152 - SEC("classifier/src_ingress") 152 + SEC("tc") 153 153 int tc_src(struct __sk_buff *skb) 154 154 { 155 155 return tc_redir(skb);
+5 -5
tools/testing/selftests/bpf/progs/test_tc_peer.c
··· 16 16 static const __u8 src_mac[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55}; 17 17 static const __u8 dst_mac[] = {0x00, 0x22, 0x33, 0x44, 0x55, 0x66}; 18 18 19 - SEC("classifier/chk_egress") 19 + SEC("tc") 20 20 int tc_chk(struct __sk_buff *skb) 21 21 { 22 22 return TC_ACT_SHOT; 23 23 } 24 24 25 - SEC("classifier/dst_ingress") 25 + SEC("tc") 26 26 int tc_dst(struct __sk_buff *skb) 27 27 { 28 28 return bpf_redirect_peer(IFINDEX_SRC, 0); 29 29 } 30 30 31 - SEC("classifier/src_ingress") 31 + SEC("tc") 32 32 int tc_src(struct __sk_buff *skb) 33 33 { 34 34 return bpf_redirect_peer(IFINDEX_DST, 0); 35 35 } 36 36 37 - SEC("classifier/dst_ingress_l3") 37 + SEC("tc") 38 38 int tc_dst_l3(struct __sk_buff *skb) 39 39 { 40 40 return bpf_redirect(IFINDEX_SRC, 0); 41 41 } 42 42 43 - SEC("classifier/src_ingress_l3") 43 + SEC("tc") 44 44 int tc_src_l3(struct __sk_buff *skb) 45 45 { 46 46 __u16 proto = skb->protocol;
+1 -1
tools/testing/selftests/bpf/progs/test_tcp_check_syncookie_kern.c
··· 148 148 bpf_sk_release(sk); 149 149 } 150 150 151 - SEC("clsact/check_syncookie") 151 + SEC("tc") 152 152 int check_syncookie_clsact(struct __sk_buff *skb) 153 153 { 154 154 check_syncookie(skb, (void *)(long)skb->data,
+1 -1
tools/testing/selftests/bpf/test_tcp_check_syncookie.sh
··· 76 76 TEST_IF=lo 77 77 MAX_PING_TRIES=5 78 78 BPF_PROG_OBJ="${DIR}/test_tcp_check_syncookie_kern.o" 79 - CLSACT_SECTION="clsact/check_syncookie" 79 + CLSACT_SECTION="tc" 80 80 XDP_SECTION="xdp" 81 81 BPF_PROG_ID=0 82 82 PROG="${DIR}/test_tcp_check_syncookie_user"