Uninline inm_lookup_locked(). Now in_var.h doesn't dereference
fields of struct ifnet. Sponsored by: Netflix Sponsored by: Nginx, Inc.
This commit is contained in:
parent
66e01d73cd
commit
8d7cf9b5d4
@ -223,6 +223,49 @@ imf_init(struct in_mfilter *imf, const int st0, const int st1)
|
||||
imf->imf_st[1] = st1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function for looking up an in_multi record for an IPv4 multicast address
|
||||
* on a given interface. ifp must be valid. If no record found, return NULL.
|
||||
* The IN_MULTI_LOCK and IF_ADDR_LOCK on ifp must be held.
|
||||
*/
|
||||
struct in_multi *
|
||||
inm_lookup_locked(struct ifnet *ifp, const struct in_addr ina)
|
||||
{
|
||||
struct ifmultiaddr *ifma;
|
||||
struct in_multi *inm;
|
||||
|
||||
IN_MULTI_LOCK_ASSERT();
|
||||
IF_ADDR_LOCK_ASSERT(ifp);
|
||||
|
||||
inm = NULL;
|
||||
TAILQ_FOREACH(ifma, &((ifp)->if_multiaddrs), ifma_link) {
|
||||
if (ifma->ifma_addr->sa_family == AF_INET) {
|
||||
inm = (struct in_multi *)ifma->ifma_protospec;
|
||||
if (inm->inm_addr.s_addr == ina.s_addr)
|
||||
break;
|
||||
inm = NULL;
|
||||
}
|
||||
}
|
||||
return (inm);
|
||||
}
|
||||
|
||||
/*
|
||||
* Wrapper for inm_lookup_locked().
|
||||
* The IF_ADDR_LOCK will be taken on ifp and released on return.
|
||||
*/
|
||||
struct in_multi *
|
||||
inm_lookup(struct ifnet *ifp, const struct in_addr ina)
|
||||
{
|
||||
struct in_multi *inm;
|
||||
|
||||
IN_MULTI_LOCK_ASSERT();
|
||||
IF_ADDR_RLOCK(ifp);
|
||||
inm = inm_lookup_locked(ifp, ina);
|
||||
IF_ADDR_RUNLOCK(ifp);
|
||||
|
||||
return (inm);
|
||||
}
|
||||
|
||||
/*
|
||||
* Resize the ip_moptions vector to the next power-of-two minus 1.
|
||||
* May be called with locks held; do not sleep.
|
||||
|
@ -363,49 +363,6 @@ extern struct mtx in_multi_mtx;
|
||||
#define IN_MULTI_LOCK_ASSERT() mtx_assert(&in_multi_mtx, MA_OWNED)
|
||||
#define IN_MULTI_UNLOCK_ASSERT() mtx_assert(&in_multi_mtx, MA_NOTOWNED)
|
||||
|
||||
/*
|
||||
* Function for looking up an in_multi record for an IPv4 multicast address
|
||||
* on a given interface. ifp must be valid. If no record found, return NULL.
|
||||
* The IN_MULTI_LOCK and IF_ADDR_LOCK on ifp must be held.
|
||||
*/
|
||||
static __inline struct in_multi *
|
||||
inm_lookup_locked(struct ifnet *ifp, const struct in_addr ina)
|
||||
{
|
||||
struct ifmultiaddr *ifma;
|
||||
struct in_multi *inm;
|
||||
|
||||
IN_MULTI_LOCK_ASSERT();
|
||||
IF_ADDR_LOCK_ASSERT(ifp);
|
||||
|
||||
inm = NULL;
|
||||
TAILQ_FOREACH(ifma, &((ifp)->if_multiaddrs), ifma_link) {
|
||||
if (ifma->ifma_addr->sa_family == AF_INET) {
|
||||
inm = (struct in_multi *)ifma->ifma_protospec;
|
||||
if (inm->inm_addr.s_addr == ina.s_addr)
|
||||
break;
|
||||
inm = NULL;
|
||||
}
|
||||
}
|
||||
return (inm);
|
||||
}
|
||||
|
||||
/*
|
||||
* Wrapper for inm_lookup_locked().
|
||||
* The IF_ADDR_LOCK will be taken on ifp and released on return.
|
||||
*/
|
||||
static __inline struct in_multi *
|
||||
inm_lookup(struct ifnet *ifp, const struct in_addr ina)
|
||||
{
|
||||
struct in_multi *inm;
|
||||
|
||||
IN_MULTI_LOCK_ASSERT();
|
||||
IF_ADDR_RLOCK(ifp);
|
||||
inm = inm_lookup_locked(ifp, ina);
|
||||
IF_ADDR_RUNLOCK(ifp);
|
||||
|
||||
return (inm);
|
||||
}
|
||||
|
||||
/* Acquire an in_multi record. */
|
||||
static __inline void
|
||||
inm_acquire_locked(struct in_multi *inm)
|
||||
@ -428,6 +385,8 @@ struct route;
|
||||
struct ip_moptions;
|
||||
struct radix_node_head;
|
||||
|
||||
struct in_multi *inm_lookup_locked(struct ifnet *, const struct in_addr);
|
||||
struct in_multi *inm_lookup(struct ifnet *, const struct in_addr);
|
||||
int imo_multi_filter(const struct ip_moptions *, const struct ifnet *,
|
||||
const struct sockaddr *, const struct sockaddr *);
|
||||
void inm_commit(struct in_multi *);
|
||||
|
Loading…
Reference in New Issue
Block a user