Re: [PATCH] ipv6: mcast: use rcu-safe version of ipv6_get_lladdr()

From: David Ahern
Date: Sat Feb 12 2022 - 14:46:35 EST


On 2/11/22 9:30 AM, Ignat Korchagin wrote:
> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
> index f927c199a93c..3f23da8c0b10 100644
> --- a/net/ipv6/addrconf.c
> +++ b/net/ipv6/addrconf.c
> @@ -1839,8 +1839,8 @@ int ipv6_dev_get_saddr(struct net *net, const struct net_device *dst_dev,
> }
> EXPORT_SYMBOL(ipv6_dev_get_saddr);
>
> -int __ipv6_get_lladdr(struct inet6_dev *idev, struct in6_addr *addr,
> - u32 banned_flags)
> +static int __ipv6_get_lladdr(struct inet6_dev *idev, struct in6_addr *addr,
> + u32 banned_flags)
> {
> struct inet6_ifaddr *ifp;
> int err = -EADDRNOTAVAIL;
> diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
> index bed8155508c8..a8861db52c18 100644
> --- a/net/ipv6/mcast.c
> +++ b/net/ipv6/mcast.c
> @@ -1759,7 +1759,7 @@ static struct sk_buff *mld_newpack(struct inet6_dev *idev, unsigned int mtu)
> skb_reserve(skb, hlen);
> skb_tailroom_reserve(skb, mtu, tlen);
>
> - if (__ipv6_get_lladdr(idev, &addr_buf, IFA_F_TENTATIVE)) {
> + if (ipv6_get_lladdr(dev, &addr_buf, IFA_F_TENTATIVE)) {
> /* <draft-ietf-magma-mld-source-05.txt>:
> * use unspecified address as the source address
> * when a valid link-local address is not available.

Why not add read_lock_bh(&idev->lock); ... read_unlock_bh(&idev->lock);
around the call to __ipv6_get_lladdr? you already have the idev.