Re: [PATCH v4 net-next 2/2] udp_tunnel: use static call for GRO hooks when possible

Paolo Abeni
2025-03-21T09:11:15Z

On 3/21/25 5:16 AM, Nathan Chancellor wrote:
[...]
>> +#define UDP_MAX_TUNNEL_TYPES (IS_ENABLED(CONFIG_GENEVE) + \
>> + IS_ENABLED(CONFIG_VXLAN) * 2 + \
>> + IS_ENABLED(CONFIG_NET_FOU) * 2)
>
> I am seeing a warning in one particular configuration in my matrix when
> building with clang:
>
> $ make -skj"$(nproc)" ARCH=mips LLVM=1 mrproper malta_defconfig net/ipv4/udp_offload.o
> net/ipv4/udp_offload.c:130:8: warning: array index 0 is past the end of the array (that has type 'struct udp_tunnel_type_entry[0]') [-Warray-bounds]
> 130 | udp_tunnel_gro_types[0].gro_receive);

[...]

> GCC is more noisy but -Warray-bounds is not on by default yet.
>
> $ make -skj"$(nproc)" ARCH=mips CROSS_COMPILE=mips-linux- KCFLAGS=-Warray-bounds mrproper malta_defconfig net/ipv4/udp_offload.o
> In function 'udp_tunnel_update_gro_rcv',
> inlined from 'udp_tunnel_update_gro_rcv' at net/ipv4/udp_offload.c:78:6:
> net/ipv4/udp_offload.c:125:44: warning: array subscript <unknown> is outside array bounds of 'struct udp_tunnel_type_entry[0]' [-Warray-bounds=]
> 125 | *cur = udp_tunnel_gro_types[--udp_tunnel_gro_type_nr];
> | ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~

[...]

> Should UDP_MAX_TUNNEL_TYPES be at least 1?

Indeed! thank you for reporting.

I'll send a patch soon. I must admit I did not expect NET_UDP_TUNNEL
enabled without any of vxlan, geneve and xfrm, but such configuration is
indeed possible.

Thanks,

Paolo