Re: [PATCH net-next] net: lan966x: Fix when CONFIG_IPV6 is not set

From: Jakub Kicinski
Date: Wed Feb 09 2022 - 21:08:55 EST


On Wed, 9 Feb 2022 14:54:23 +0100 Andrew Lunn wrote:
> On Wed, Feb 09, 2022 at 11:18:23AM +0100, Horatiu Vultur wrote:
> > When CONFIG_IPV6 is not set, then the compilation of the lan966x driver

compilation or linking?

> > fails with the following error:
> >
> > drivers/net/ethernet/microchip/lan966x/lan966x_main.c:444: undefined
> > reference to `ipv6_mc_check_mld'
> >
> > The fix consists in adding #ifdef around this code.
>
> It might be better to add a stub function for when IPv6 is
> disabled. We try to avoid #if in C code.

If it's linking we can do:

if (IS_ENABLED(CONFIG_IPV6) &&
skb->protocol == htons(ETH_P_IPV6) &&
ipv6_addr_is_multicast(&ipv6_hdr(skb)->daddr) &&
!ipv6_mc_check_mld(skb))
return false;

But beware that IPV6 can be a module, you may need a Kconfig dependency.