summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf/progs/test_tcpbpf_kern.c
diff options
context:
space:
mode:
authorJose E. Marchesi <jose.marchesi@oracle.com>2024-01-23 23:17:29 +0300
committerAlexei Starovoitov <ast@kernel.org>2024-01-24 02:50:47 +0300
commitedb799035dd7d41c3e81e1bef83e2a2120b08abb (patch)
tree2b59e35655f7dd697e9e22c894ee7dd0570b9606 /tools/testing/selftests/bpf/progs/test_tcpbpf_kern.c
parentbc308d011ab8cc61bf1be15a2920bcd7d7b9b9d3 (diff)
downloadlinux-edb799035dd7d41c3e81e1bef83e2a2120b08abb.tar.xz
bpf: avoid VLAs in progs/test_xdp_dynptr.c
VLAs are not supported by either the BPF port of clang nor GCC. The selftest test_xdp_dynptr.c contains the following code: const size_t tcphdr_sz = sizeof(struct tcphdr); const size_t udphdr_sz = sizeof(struct udphdr); const size_t ethhdr_sz = sizeof(struct ethhdr); const size_t iphdr_sz = sizeof(struct iphdr); const size_t ipv6hdr_sz = sizeof(struct ipv6hdr); [...] static __always_inline int handle_ipv4(struct xdp_md *xdp, struct bpf_dynptr *xdp_ptr) { __u8 eth_buffer[ethhdr_sz + iphdr_sz + ethhdr_sz]; __u8 iph_buffer_tcp[iphdr_sz + tcphdr_sz]; __u8 iph_buffer_udp[iphdr_sz + udphdr_sz]; [...] } The eth_buffer, iph_buffer_tcp and other automatics are fixed size only if the compiler optimizes away the constant global variables. clang does this, but GCC does not, turning these automatics into variable length arrays. This patch removes the global variables and turns these values into preprocessor constants. This makes the selftest to build properly with GCC. Tested in bpf-next master. No regressions. Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com> Cc: Yonghong Song <yhs@meta.com> Cc: Eduard Zingerman <eddyz87@gmail.com> Cc: david.faust@oracle.com Cc: cupertino.miranda@oracle.com Acked-by: Yonghong Song <yonghong.song@linux.dev> Link: https://lore.kernel.org/r/20240123201729.16173-1-jose.marchesi@oracle.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/testing/selftests/bpf/progs/test_tcpbpf_kern.c')
0 files changed, 0 insertions, 0 deletions