All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yonghong Song <yonghong.song@linux.dev>
To: "Jose E. Marchesi" <jose.marchesi@oracle.com>, bpf@vger.kernel.org
Cc: Yonghong Song <yhs@meta.com>,
	Eduard Zingerman <eddyz87@gmail.com>,
	david.faust@oracle.com, cupertino.miranda@oracle.com
Subject: Re: [PATCH] bpf: avoid VLAs in progs/test_xdp_dynptr.c
Date: Tue, 23 Jan 2024 13:06:04 -0800	[thread overview]
Message-ID: <e966e13e-282b-4f18-878f-c68de7939daf@linux.dev> (raw)
In-Reply-To: <20240123201729.16173-1-jose.marchesi@oracle.com>


On 1/23/24 12:17 PM, Jose E. Marchesi wrote:
> 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>


  reply	other threads:[~2024-01-23 21:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-23 20:17 [PATCH] bpf: avoid VLAs in progs/test_xdp_dynptr.c Jose E. Marchesi
2024-01-23 21:06 ` Yonghong Song [this message]
2024-01-24  0:00 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e966e13e-282b-4f18-878f-c68de7939daf@linux.dev \
    --to=yonghong.song@linux.dev \
    --cc=bpf@vger.kernel.org \
    --cc=cupertino.miranda@oracle.com \
    --cc=david.faust@oracle.com \
    --cc=eddyz87@gmail.com \
    --cc=jose.marchesi@oracle.com \
    --cc=yhs@meta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.