[PATCH] net: lwip: ensure alignment of packet buffers

Jerome Forissier jerome.forissier at linaro.org
Tue Sep 30 11:57:42 CEST 2025


Hi Tim,

On 9/29/25 21:21, Tim Harvey wrote:
> Network packet buffers should be aligned to PKTALIGN. Add a compiler
> attribute to ensure this.
> 
> Signed-off-by: Tim Harvey <tharvey at gateworks.com>
> ---
>  net/lwip/net-lwip.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/lwip/net-lwip.c b/net/lwip/net-lwip.c
> index 660ceb10cbe..aec05d55de6 100644
> --- a/net/lwip/net-lwip.c
> +++ b/net/lwip/net-lwip.c
> @@ -30,7 +30,7 @@ void (*push_packet)(void *, int len) = 0;
>  static int net_try_count;
>  static int net_restarted;
>  int net_restart_wrap;
> -static uchar net_pkt_buf[(PKTBUFSRX) * PKTSIZE_ALIGN + PKTALIGN];
> +static uchar net_pkt_buf[(PKTBUFSRX) * PKTSIZE_ALIGN + PKTALIGN] __attribute__((aligned(PKTALIGN)));
>  uchar *net_rx_packets[PKTBUFSRX];
>  uchar *net_rx_packet;
>  const u8 net_bcast_ethaddr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };

I'd rather use the __aligned(x) macro from <linux/compiler_attributes.h>.
No need to resend, I will update the patch locally before sending my next
pull request for the net subsystem.

Thanks,
-- 
Jerome


More information about the U-Boot mailing list