IfAPI: Hide the in6m_lookup_locked() implementation.

Summary:
in6m_lookup_locked() iterates over the ifnet's multiaddrs list.  Keep
this implementation detail private, by moving the implementation to the
netstack source from the header.

Sponsored by:	Juniper Networks, Inc.
Reviewed by:	glebius, melifaro
Differential Revision: https://reviews.freebsd.org/D38201
This commit is contained in:
Justin Hibbits 2023-01-25 14:09:09 -05:00
parent 537c166b76
commit 361ac40b0f
2 changed files with 27 additions and 24 deletions

View File

@ -345,6 +345,31 @@ im6o_mc_filter(const struct ip6_moptions *imo, const struct ifnet *ifp,
return (MCAST_PASS);
}
/*
* Look up an in6_multi record for an IPv6 multicast address
* on the interface ifp.
* If no record found, return NULL.
*
* SMPng: The IN6_MULTI_LOCK and must be held and must be in network epoch.
*/
struct in6_multi *
in6m_lookup_locked(struct ifnet *ifp, const struct in6_addr *mcaddr)
{
struct ifmultiaddr *ifma;
struct in6_multi *inm;
NET_EPOCH_ASSERT();
CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
inm = in6m_ifmultiaddr_get_inm(ifma);
if (inm == NULL)
continue;
if (IN6_ARE_ADDR_EQUAL(&inm->in6m_addr, mcaddr))
return (inm);
}
return (NULL);
}
/*
* Find and return a reference to an in6_multi record for (ifp, group),
* and bump its reference count.

View File

@ -776,35 +776,13 @@ static __inline struct in6_multi *
in6m_ifmultiaddr_get_inm(struct ifmultiaddr *ifma)
{
NET_EPOCH_ASSERT();
return ((ifma->ifma_addr->sa_family != AF_INET6 ||
(ifma->ifma_flags & IFMA_F_ENQUEUED) == 0) ? NULL :
ifma->ifma_protospec);
}
/*
* Look up an in6_multi record for an IPv6 multicast address
* on the interface ifp.
* If no record found, return NULL.
*
* SMPng: The IN6_MULTI_LOCK and must be held and must be in network epoch.
*/
static __inline struct in6_multi *
in6m_lookup_locked(struct ifnet *ifp, const struct in6_addr *mcaddr)
{
struct ifmultiaddr *ifma;
struct in6_multi *inm;
CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
inm = in6m_ifmultiaddr_get_inm(ifma);
if (inm == NULL)
continue;
if (IN6_ARE_ADDR_EQUAL(&inm->in6m_addr, mcaddr))
return (inm);
}
return (NULL);
}
struct in6_multi *
in6m_lookup_locked(struct ifnet *ifp, const struct in6_addr *mcaddr);
/*
* Wrapper for in6m_lookup_locked().