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

selftests/bpf: Normalize XDP section names in selftests

Convert almost all SEC("xdp_blah") uses to strict SEC("xdp") to comply
with strict libbpf 1.0 logic of exact section name match for XDP program
types. There is only one exception, which is only tested through
iproute2 and defines multiple XDP programs within the same BPF object.
Given iproute2 still works in non-strict libbpf mode and it doesn't have
means to specify XDP programs by its name (not section name/title),
leave that single file alone for now until iproute2 gains lookup by
function/program name.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Dave Marchevsky <davemarchevsky@fb.com>
Link: https://lore.kernel.org/bpf/20210928161946.2512801-3-andrii@kernel.org

authored by

Andrii Nakryiko and committed by
Alexei Starovoitov
8fffa0e3 9673268f

+27 -30
+1 -1
tools/testing/selftests/bpf/progs/test_map_in_map.c
··· 23 23 __uint(value_size, sizeof(__u32)); 24 24 } mim_hash SEC(".maps"); 25 25 26 - SEC("xdp_mimtest") 26 + SEC("xdp") 27 27 int xdp_mimtest0(struct xdp_md *ctx) 28 28 { 29 29 int value = 123;
+1 -1
tools/testing/selftests/bpf/progs/test_tcp_check_syncookie_kern.c
··· 156 156 return TC_ACT_OK; 157 157 } 158 158 159 - SEC("xdp/check_syncookie") 159 + SEC("xdp") 160 160 int check_syncookie_xdp(struct xdp_md *ctx) 161 161 { 162 162 check_syncookie(ctx, (void *)(long)ctx->data,
+1 -1
tools/testing/selftests/bpf/progs/test_xdp.c
··· 210 210 return XDP_TX; 211 211 } 212 212 213 - SEC("xdp_tx_iptunnel") 213 + SEC("xdp") 214 214 int _xdp_tx_iptunnel(struct xdp_md *xdp) 215 215 { 216 216 void *data_end = (void *)(long)xdp->data_end;
+1 -1
tools/testing/selftests/bpf/progs/test_xdp_adjust_tail_grow.c
··· 2 2 #include <linux/bpf.h> 3 3 #include <bpf/bpf_helpers.h> 4 4 5 - SEC("xdp_adjust_tail_grow") 5 + SEC("xdp") 6 6 int _xdp_adjust_tail_grow(struct xdp_md *xdp) 7 7 { 8 8 void *data_end = (void *)(long)xdp->data_end;
+1 -3
tools/testing/selftests/bpf/progs/test_xdp_adjust_tail_shrink.c
··· 9 9 #include <linux/if_ether.h> 10 10 #include <bpf/bpf_helpers.h> 11 11 12 - int _version SEC("version") = 1; 13 - 14 - SEC("xdp_adjust_tail_shrink") 12 + SEC("xdp") 15 13 int _xdp_adjust_tail_shrink(struct xdp_md *xdp) 16 14 { 17 15 void *data_end = (void *)(long)xdp->data_end;
+1 -1
tools/testing/selftests/bpf/progs/test_xdp_devmap_helpers.c
··· 5 5 #include <linux/bpf.h> 6 6 #include <bpf/bpf_helpers.h> 7 7 8 - SEC("xdp_dm_log") 8 + SEC("xdp") 9 9 int xdpdm_devlog(struct xdp_md *ctx) 10 10 { 11 11 char fmt[] = "devmap redirect: dev %u -> dev %u len %u\n";
+1 -1
tools/testing/selftests/bpf/progs/test_xdp_link.c
··· 5 5 6 6 char LICENSE[] SEC("license") = "GPL"; 7 7 8 - SEC("xdp/handler") 8 + SEC("xdp") 9 9 int xdp_handler(struct xdp_md *xdp) 10 10 { 11 11 return 0;
+1 -1
tools/testing/selftests/bpf/progs/test_xdp_loop.c
··· 206 206 return XDP_TX; 207 207 } 208 208 209 - SEC("xdp_tx_iptunnel") 209 + SEC("xdp") 210 210 int _xdp_tx_iptunnel(struct xdp_md *xdp) 211 211 { 212 212 void *data_end = (void *)(long)xdp->data_end;
+2 -2
tools/testing/selftests/bpf/progs/test_xdp_noinline.c
··· 797 797 return XDP_DROP; 798 798 } 799 799 800 - SEC("xdp-test-v4") 800 + SEC("xdp") 801 801 int balancer_ingress_v4(struct xdp_md *ctx) 802 802 { 803 803 void *data = (void *)(long)ctx->data; ··· 816 816 return XDP_DROP; 817 817 } 818 818 819 - SEC("xdp-test-v6") 819 + SEC("xdp") 820 820 int balancer_ingress_v6(struct xdp_md *ctx) 821 821 { 822 822 void *data = (void *)(long)ctx->data;
+2 -2
tools/testing/selftests/bpf/progs/test_xdp_with_cpumap_helpers.c
··· 12 12 __uint(max_entries, 4); 13 13 } cpu_map SEC(".maps"); 14 14 15 - SEC("xdp_redir") 15 + SEC("xdp") 16 16 int xdp_redir_prog(struct xdp_md *ctx) 17 17 { 18 18 return bpf_redirect_map(&cpu_map, 1, 0); 19 19 } 20 20 21 - SEC("xdp_dummy") 21 + SEC("xdp") 22 22 int xdp_dummy_prog(struct xdp_md *ctx) 23 23 { 24 24 return XDP_PASS;
+2 -2
tools/testing/selftests/bpf/progs/test_xdp_with_devmap_helpers.c
··· 9 9 __uint(max_entries, 4); 10 10 } dm_ports SEC(".maps"); 11 11 12 - SEC("xdp_redir") 12 + SEC("xdp") 13 13 int xdp_redir_prog(struct xdp_md *ctx) 14 14 { 15 15 return bpf_redirect_map(&dm_ports, 1, 0); ··· 18 18 /* invalid program on DEVMAP entry; 19 19 * SEC name means expected attach type not set 20 20 */ 21 - SEC("xdp_dummy") 21 + SEC("xdp") 22 22 int xdp_dummy_prog(struct xdp_md *ctx) 23 23 { 24 24 return XDP_PASS;
+1 -1
tools/testing/selftests/bpf/progs/xdp_dummy.c
··· 4 4 #include <linux/bpf.h> 5 5 #include <bpf/bpf_helpers.h> 6 6 7 - SEC("xdp_dummy") 7 + SEC("xdp") 8 8 int xdp_dummy_prog(struct xdp_md *ctx) 9 9 { 10 10 return XDP_PASS;
+2 -2
tools/testing/selftests/bpf/progs/xdp_redirect_multi_kern.c
··· 34 34 __uint(max_entries, 128); 35 35 } mac_map SEC(".maps"); 36 36 37 - SEC("xdp_redirect_map_multi") 37 + SEC("xdp") 38 38 int xdp_redirect_map_multi_prog(struct xdp_md *ctx) 39 39 { 40 40 void *data_end = (void *)(long)ctx->data_end; ··· 63 63 } 64 64 65 65 /* The following 2 progs are for 2nd devmap prog testing */ 66 - SEC("xdp_redirect_map_ingress") 66 + SEC("xdp") 67 67 int xdp_redirect_map_all_prog(struct xdp_md *ctx) 68 68 { 69 69 return bpf_redirect_map(&map_egress, 0,
+2 -2
tools/testing/selftests/bpf/progs/xdping_kern.c
··· 86 86 return XDP_TX; 87 87 } 88 88 89 - SEC("xdpclient") 89 + SEC("xdp") 90 90 int xdping_client(struct xdp_md *ctx) 91 91 { 92 92 void *data_end = (void *)(long)ctx->data_end; ··· 150 150 return XDP_TX; 151 151 } 152 152 153 - SEC("xdpserver") 153 + SEC("xdp") 154 154 int xdping_server(struct xdp_md *ctx) 155 155 { 156 156 void *data_end = (void *)(long)ctx->data_end;
+1 -1
tools/testing/selftests/bpf/test_tcp_check_syncookie.sh
··· 77 77 MAX_PING_TRIES=5 78 78 BPF_PROG_OBJ="${DIR}/test_tcp_check_syncookie_kern.o" 79 79 CLSACT_SECTION="clsact/check_syncookie" 80 - XDP_SECTION="xdp/check_syncookie" 80 + XDP_SECTION="xdp" 81 81 BPF_PROG_ID=0 82 82 PROG="${DIR}/test_tcp_check_syncookie_user" 83 83
+2 -2
tools/testing/selftests/bpf/test_xdp_redirect.sh
··· 52 52 return 0 53 53 fi 54 54 55 - ip -n ns1 link set veth11 $xdpmode obj xdp_dummy.o sec xdp_dummy &> /dev/null 56 - ip -n ns2 link set veth22 $xdpmode obj xdp_dummy.o sec xdp_dummy &> /dev/null 55 + ip -n ns1 link set veth11 $xdpmode obj xdp_dummy.o sec xdp &> /dev/null 56 + ip -n ns2 link set veth22 $xdpmode obj xdp_dummy.o sec xdp &> /dev/null 57 57 ip link set dev veth1 $xdpmode obj test_xdp_redirect.o sec redirect_to_222 &> /dev/null 58 58 ip link set dev veth2 $xdpmode obj test_xdp_redirect.o sec redirect_to_111 &> /dev/null 59 59
+1 -1
tools/testing/selftests/bpf/test_xdp_redirect_multi.sh
··· 88 88 # Add a neigh entry for IPv4 ping test 89 89 ip -n ns$i neigh add 192.0.2.253 lladdr 00:00:00:00:00:01 dev veth0 90 90 ip -n ns$i link set veth0 $mode obj \ 91 - xdp_dummy.o sec xdp_dummy &> /dev/null || \ 91 + xdp_dummy.o sec xdp &> /dev/null || \ 92 92 { test_fail "Unable to load dummy xdp" && exit 1; } 93 93 IFACES="$IFACES veth$i" 94 94 veth_mac[$i]=$(ip link show veth$i | awk '/link\/ether/ {print $2}')
+2 -2
tools/testing/selftests/bpf/test_xdp_veth.sh
··· 107 107 ip link set dev veth2 xdp pinned $BPF_DIR/progs/redirect_map_1 108 108 ip link set dev veth3 xdp pinned $BPF_DIR/progs/redirect_map_2 109 109 110 - ip -n ns1 link set dev veth11 xdp obj xdp_dummy.o sec xdp_dummy 110 + ip -n ns1 link set dev veth11 xdp obj xdp_dummy.o sec xdp 111 111 ip -n ns2 link set dev veth22 xdp obj xdp_tx.o sec xdp 112 - ip -n ns3 link set dev veth33 xdp obj xdp_dummy.o sec xdp_dummy 112 + ip -n ns3 link set dev veth33 xdp obj xdp_dummy.o sec xdp 113 113 114 114 trap cleanup EXIT 115 115
+2 -3
tools/testing/selftests/bpf/xdping.c
··· 178 178 return 1; 179 179 } 180 180 181 - main_prog = bpf_object__find_program_by_title(obj, 182 - server ? "xdpserver" : 183 - "xdpclient"); 181 + main_prog = bpf_object__find_program_by_name(obj, 182 + server ? "xdping_server" : "xdping_client"); 184 183 if (main_prog) 185 184 prog_fd = bpf_program__fd(main_prog); 186 185 if (!main_prog || prog_fd < 0) {