]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
selftests/bpf: Normalize XDP section names in selftests
authorAndrii Nakryiko <andrii@kernel.org>
Tue, 28 Sep 2021 16:19:38 +0000 (09:19 -0700)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 20 May 2022 12:38:43 +0000 (14:38 +0200)
BugLink: https://bugs.launchpad.net/bugs/1969110
[ Upstream commit 8fffa0e3451abdd84e4b4e427f7e66040eb24f43 ]

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
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit a5c1c0920cf6b3d70343806b97381992c789314a)
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
19 files changed:
tools/testing/selftests/bpf/progs/test_map_in_map.c
tools/testing/selftests/bpf/progs/test_tcp_check_syncookie_kern.c
tools/testing/selftests/bpf/progs/test_xdp.c
tools/testing/selftests/bpf/progs/test_xdp_adjust_tail_grow.c
tools/testing/selftests/bpf/progs/test_xdp_adjust_tail_shrink.c
tools/testing/selftests/bpf/progs/test_xdp_devmap_helpers.c
tools/testing/selftests/bpf/progs/test_xdp_link.c
tools/testing/selftests/bpf/progs/test_xdp_loop.c
tools/testing/selftests/bpf/progs/test_xdp_noinline.c
tools/testing/selftests/bpf/progs/test_xdp_with_cpumap_helpers.c
tools/testing/selftests/bpf/progs/test_xdp_with_devmap_helpers.c
tools/testing/selftests/bpf/progs/xdp_dummy.c
tools/testing/selftests/bpf/progs/xdp_redirect_multi_kern.c
tools/testing/selftests/bpf/progs/xdping_kern.c
tools/testing/selftests/bpf/test_tcp_check_syncookie.sh
tools/testing/selftests/bpf/test_xdp_redirect.sh
tools/testing/selftests/bpf/test_xdp_redirect_multi.sh
tools/testing/selftests/bpf/test_xdp_veth.sh
tools/testing/selftests/bpf/xdping.c

index 1cfeb940cf9fb259da3eb9fa864465b21e72794d..5f0e0bfc151e52841f2a3126885292817c2d7559 100644 (file)
@@ -23,7 +23,7 @@ struct {
        __uint(value_size, sizeof(__u32));
 } mim_hash SEC(".maps");
 
-SEC("xdp_mimtest")
+SEC("xdp")
 int xdp_mimtest0(struct xdp_md *ctx)
 {
        int value = 123;
index 47cbe2eeae431b85d407dd2e11e21e0e8316b58a..fac7ef99f9a67365ce6ac236d43ba20dd5074b55 100644 (file)
@@ -156,7 +156,7 @@ int check_syncookie_clsact(struct __sk_buff *skb)
        return TC_ACT_OK;
 }
 
-SEC("xdp/check_syncookie")
+SEC("xdp")
 int check_syncookie_xdp(struct xdp_md *ctx)
 {
        check_syncookie(ctx, (void *)(long)ctx->data,
index 31f9bce37491a6ca842f0ac3eca3c8ad49759e6b..e6aa2fc6ce6bd4594d95540dca96672e53368753 100644 (file)
@@ -210,7 +210,7 @@ static __always_inline int handle_ipv6(struct xdp_md *xdp)
        return XDP_TX;
 }
 
-SEC("xdp_tx_iptunnel")
+SEC("xdp")
 int _xdp_tx_iptunnel(struct xdp_md *xdp)
 {
        void *data_end = (void *)(long)xdp->data_end;
index 3d66599eee2ec9e0332e3270722f4581d2c80963..199c61b7d062863389c2b4371f7c8e6171c3d323 100644 (file)
@@ -2,7 +2,7 @@
 #include <linux/bpf.h>
 #include <bpf/bpf_helpers.h>
 
-SEC("xdp_adjust_tail_grow")
+SEC("xdp")
 int _xdp_adjust_tail_grow(struct xdp_md *xdp)
 {
        void *data_end = (void *)(long)xdp->data_end;
index 22065a9cfb254ed659890ead1578fc577d412895..b7448253d1359b7939370bba04525b20ffc2c367 100644 (file)
@@ -9,9 +9,7 @@
 #include <linux/if_ether.h>
 #include <bpf/bpf_helpers.h>
 
-int _version SEC("version") = 1;
-
-SEC("xdp_adjust_tail_shrink")
+SEC("xdp")
 int _xdp_adjust_tail_shrink(struct xdp_md *xdp)
 {
        void *data_end = (void *)(long)xdp->data_end;
index b360ba2bd441148e10da51c5b96b8696b6f91442..807bf895f42ca84ffc77838464a2ff144f8876d7 100644 (file)
@@ -5,7 +5,7 @@
 #include <linux/bpf.h>
 #include <bpf/bpf_helpers.h>
 
-SEC("xdp_dm_log")
+SEC("xdp")
 int xdpdm_devlog(struct xdp_md *ctx)
 {
        char fmt[] = "devmap redirect: dev %u -> dev %u len %u\n";
index eb93ea95d1d8f14ffd52e3934fc7b753d69e07fe..ee7d6ac0f61513120edfefefdcf42b554a131dcc 100644 (file)
@@ -5,7 +5,7 @@
 
 char LICENSE[] SEC("license") = "GPL";
 
-SEC("xdp/handler")
+SEC("xdp")
 int xdp_handler(struct xdp_md *xdp)
 {
        return 0;
index fcabcda30ba32086a1594ed21f5fbb77443ae475..27eb52dda92c21f23605c0f23a54f6b3f38f99c9 100644 (file)
@@ -206,7 +206,7 @@ static __always_inline int handle_ipv6(struct xdp_md *xdp)
        return XDP_TX;
 }
 
-SEC("xdp_tx_iptunnel")
+SEC("xdp")
 int _xdp_tx_iptunnel(struct xdp_md *xdp)
 {
        void *data_end = (void *)(long)xdp->data_end;
index 3a67921f62b52c3d9143ddc6bf78e43b62abb663..596c4e71bf3ac21b056ef7002934db0cbe499c13 100644 (file)
@@ -797,7 +797,7 @@ out:
        return XDP_DROP;
 }
 
-SEC("xdp-test-v4")
+SEC("xdp")
 int balancer_ingress_v4(struct xdp_md *ctx)
 {
        void *data = (void *)(long)ctx->data;
@@ -816,7 +816,7 @@ int balancer_ingress_v4(struct xdp_md *ctx)
                return XDP_DROP;
 }
 
-SEC("xdp-test-v6")
+SEC("xdp")
 int balancer_ingress_v6(struct xdp_md *ctx)
 {
        void *data = (void *)(long)ctx->data;
index 59ee4f182ff800d7517fe4daeb681fbd59660c1e..532025057711e27aa3cb3cdc80332725f9b40147 100644 (file)
@@ -12,13 +12,13 @@ struct {
        __uint(max_entries, 4);
 } cpu_map SEC(".maps");
 
-SEC("xdp_redir")
+SEC("xdp")
 int xdp_redir_prog(struct xdp_md *ctx)
 {
        return bpf_redirect_map(&cpu_map, 1, 0);
 }
 
-SEC("xdp_dummy")
+SEC("xdp")
 int xdp_dummy_prog(struct xdp_md *ctx)
 {
        return XDP_PASS;
index 0ac08649772228ebd7846e6a543ce78bbc25168f..1e6b9c38ea6d9231ec8c7a860fa9e176472f5b01 100644 (file)
@@ -9,7 +9,7 @@ struct {
        __uint(max_entries, 4);
 } dm_ports SEC(".maps");
 
-SEC("xdp_redir")
+SEC("xdp")
 int xdp_redir_prog(struct xdp_md *ctx)
 {
        return bpf_redirect_map(&dm_ports, 1, 0);
@@ -18,7 +18,7 @@ int xdp_redir_prog(struct xdp_md *ctx)
 /* invalid program on DEVMAP entry;
  * SEC name means expected attach type not set
  */
-SEC("xdp_dummy")
+SEC("xdp")
 int xdp_dummy_prog(struct xdp_md *ctx)
 {
        return XDP_PASS;
index ea25e88819928dda30a8a81b21adaba1d07b3919..d988b2e0cee840c578373ca34ec0df99483b0f85 100644 (file)
@@ -4,7 +4,7 @@
 #include <linux/bpf.h>
 #include <bpf/bpf_helpers.h>
 
-SEC("xdp_dummy")
+SEC("xdp")
 int xdp_dummy_prog(struct xdp_md *ctx)
 {
        return XDP_PASS;
index 880debcbcd65deb32107e1646af170ccb389bc76..8395782b6e0a3c2d82f52298b80cf3d3b941969f 100644 (file)
@@ -34,7 +34,7 @@ struct {
        __uint(max_entries, 128);
 } mac_map SEC(".maps");
 
-SEC("xdp_redirect_map_multi")
+SEC("xdp")
 int xdp_redirect_map_multi_prog(struct xdp_md *ctx)
 {
        void *data_end = (void *)(long)ctx->data_end;
@@ -63,7 +63,7 @@ int xdp_redirect_map_multi_prog(struct xdp_md *ctx)
 }
 
 /* The following 2 progs are for 2nd devmap prog testing */
-SEC("xdp_redirect_map_ingress")
+SEC("xdp")
 int xdp_redirect_map_all_prog(struct xdp_md *ctx)
 {
        return bpf_redirect_map(&map_egress, 0,
index 6b9ca40bd1f4f8a80c9c8b93f6f59dfc8f76d5a8..4ad73847b8a5de6227d48d5a5cb091ca2d5b88e7 100644 (file)
@@ -86,7 +86,7 @@ static __always_inline int icmp_check(struct xdp_md *ctx, int type)
        return XDP_TX;
 }
 
-SEC("xdpclient")
+SEC("xdp")
 int xdping_client(struct xdp_md *ctx)
 {
        void *data_end = (void *)(long)ctx->data_end;
@@ -150,7 +150,7 @@ int xdping_client(struct xdp_md *ctx)
        return XDP_TX;
 }
 
-SEC("xdpserver")
+SEC("xdp")
 int xdping_server(struct xdp_md *ctx)
 {
        void *data_end = (void *)(long)ctx->data_end;
index 9b3617d770a525875bf6a0d6d6d2f27553267029..fed765157c53c192ba7663f1142a2c2312240b20 100755 (executable)
@@ -77,7 +77,7 @@ TEST_IF=lo
 MAX_PING_TRIES=5
 BPF_PROG_OBJ="${DIR}/test_tcp_check_syncookie_kern.o"
 CLSACT_SECTION="clsact/check_syncookie"
-XDP_SECTION="xdp/check_syncookie"
+XDP_SECTION="xdp"
 BPF_PROG_ID=0
 PROG="${DIR}/test_tcp_check_syncookie_user"
 
index c033850886f441b014dbbac921a50814e68a1f54..57c8db9972a65fa3abc3bba6c9e21333f1ca2dcf 100755 (executable)
@@ -52,8 +52,8 @@ test_xdp_redirect()
                return 0
        fi
 
-       ip -n ns1 link set veth11 $xdpmode obj xdp_dummy.o sec xdp_dummy &> /dev/null
-       ip -n ns2 link set veth22 $xdpmode obj xdp_dummy.o sec xdp_dummy &> /dev/null
+       ip -n ns1 link set veth11 $xdpmode obj xdp_dummy.o sec xdp &> /dev/null
+       ip -n ns2 link set veth22 $xdpmode obj xdp_dummy.o sec xdp &> /dev/null
        ip link set dev veth1 $xdpmode obj test_xdp_redirect.o sec redirect_to_222 &> /dev/null
        ip link set dev veth2 $xdpmode obj test_xdp_redirect.o sec redirect_to_111 &> /dev/null
 
index bedff7aa7023f000f3e63cc8f517c87a1502e4c0..05f8727409997d50cc6a03c37c02c6238b2b06f0 100755 (executable)
@@ -92,7 +92,7 @@ setup_ns()
                # Add a neigh entry for IPv4 ping test
                ip -n ns$i neigh add 192.0.2.253 lladdr 00:00:00:00:00:01 dev veth0
                ip -n ns$i link set veth0 $mode obj \
-                       xdp_dummy.o sec xdp_dummy &> /dev/null || \
+                       xdp_dummy.o sec xdp &> /dev/null || \
                        { test_fail "Unable to load dummy xdp" && exit 1; }
                IFACES="$IFACES veth$i"
                veth_mac[$i]=$(ip -n ns0 link show veth$i | awk '/link\/ether/ {print $2}')
index 995278e684b6e43a99d815a6eac953c50bcf573d..a3a1eaee26ea60d563fff576de4cf00dc13d195b 100755 (executable)
@@ -107,9 +107,9 @@ ip link set dev veth1 xdp pinned $BPF_DIR/progs/redirect_map_0
 ip link set dev veth2 xdp pinned $BPF_DIR/progs/redirect_map_1
 ip link set dev veth3 xdp pinned $BPF_DIR/progs/redirect_map_2
 
-ip -n ns1 link set dev veth11 xdp obj xdp_dummy.o sec xdp_dummy
+ip -n ns1 link set dev veth11 xdp obj xdp_dummy.o sec xdp
 ip -n ns2 link set dev veth22 xdp obj xdp_tx.o sec xdp
-ip -n ns3 link set dev veth33 xdp obj xdp_dummy.o sec xdp_dummy
+ip -n ns3 link set dev veth33 xdp obj xdp_dummy.o sec xdp
 
 trap cleanup EXIT
 
index 842d9155d36c5b322ca71961df7fb6ef2df22f48..79a3453dab255e11915ec00c7d7e1bb5ca20e9f5 100644 (file)
@@ -178,9 +178,8 @@ int main(int argc, char **argv)
                return 1;
        }
 
-       main_prog = bpf_object__find_program_by_title(obj,
-                                                     server ? "xdpserver" :
-                                                              "xdpclient");
+       main_prog = bpf_object__find_program_by_name(obj,
+                                                    server ? "xdping_server" : "xdping_client");
        if (main_prog)
                prog_fd = bpf_program__fd(main_prog);
        if (!main_prog || prog_fd < 0) {