--- zzzz-none-000/linux-5.4.213/net/ipv6/addrconf.c 2022-09-15 10:04:56.000000000 +0000 +++ miami-7690-761/linux-5.4.213/net/ipv6/addrconf.c 2024-05-29 11:20:02.000000000 +0000 @@ -2023,6 +2023,35 @@ return result; } +/* ipv6_dev_find() + * Find (and hold) net device that has the given address. + * Or NULL on failure. + */ +struct net_device *ipv6_dev_find(struct net *net, struct in6_addr *addr, + int strict) +{ + struct inet6_ifaddr *ifp; + struct net_device *dev; + + ifp = ipv6_get_ifaddr(net, addr, NULL, strict); + if (!ifp) + return NULL; + + if (!ifp->idev) { + in6_ifa_put(ifp); + return NULL; + } + + dev = ifp->idev->dev; + if (dev) + dev_hold(dev); + + in6_ifa_put(ifp); + + return dev; +} +EXPORT_SYMBOL(ipv6_dev_find); + /* Gets referenced address, destroys ifaddr */ static void addrconf_dad_stop(struct inet6_ifaddr *ifp, int dad_failed)