Subject: Re: [PATCH RESEND net-next] netlink: add IPv6 anycast join/leave notifications

From: David Ahern <[email-masked]>
Date: Mon, 6 Jan 2025 10:53:15 -0700

On 1/4/25 7:00 PM, Yuyang Huang wrote:
> diff --git a/net/ipv6/anycast.c b/net/ipv6/anycast.c
> index 562cace50ca9..6793ff436986 100644
> --- a/net/ipv6/anycast.c
> +++ b/net/ipv6/anycast.c
> @@ -278,6 +278,40 @@ static struct ifacaddr6 *aca_alloc(struct fib6_info *f6i,
>  	return aca;
>  }
>  
> +static void inet6_ifacaddr_notify(struct net_device *dev,
> +				  const struct ifacaddr6 *ifaca, int event)
> +{
> +	struct inet6_fill_args fillargs = {
> +		.portid = 0,
> +		.seq = 0,
> +		.event = event,
> +		.flags = 0,

0 initializations are not needed.

> +		.netnsid = -1,
> +	};
> +	struct net *net = dev_net(dev);
> +	struct sk_buff *skb;
> +	int err = -ENOMEM;
> +
> +	skb = nlmsg_new(NLMSG_ALIGN(sizeof(struct ifaddrmsg)) +
> +			nla_total_size(sizeof(struct in6_addr)) +
> +			nla_total_size(sizeof(struct ifa_cacheinfo)),
> +			GFP_KERNEL);
> +	if (!skb)
> +		goto error;
> +
> +	err = inet6_fill_ifacaddr(skb, ifaca, &fillargs);
> +	if (err < 0) {
> +		WARN_ON_ONCE(err == -EMSGSIZE);

simple error message should suffice; stack trace does not provide
additional value.

> +		nlmsg_free(skb);
> +		goto error;
> +	}
> +
> +	rtnl_notify(skb, net, 0, RTNLGRP_IPV6_ACADDR, NULL, GFP_KERNEL);
> +	return;
> +error:
> +	rtnl_set_sk_err(net, RTNLGRP_IPV6_ACADDR, err);
> +}
> +
>  /*
>   *	device anycast group inc (add if not found)
>   */