in(6)_mcast: Expand out vnet set / restore macro so that they work in a conditional block

Reported by:	zec at fer.hr
This commit is contained in:
Matt Macy 2018-05-21 08:34:10 +00:00
parent 06b15160e1
commit ed6bb714b2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=333968
2 changed files with 24 additions and 12 deletions

View File

@ -653,6 +653,7 @@ inm_release(struct in_multi *inm)
{
struct ifmultiaddr *ifma;
struct ifnet *ifp;
struct vnet *saved_vnet;
CTR2(KTR_IGMPV3, "%s: refcount is %d", __func__, inm->inm_refcount);
MPASS(inm->inm_refcount == 0);
@ -663,14 +664,16 @@ inm_release(struct in_multi *inm)
/* XXX this access is not covered by IF_ADDR_LOCK */
CTR2(KTR_IGMPV3, "%s: purging ifma %p", __func__, ifma);
if (ifp)
CURVNET_SET(ifp->if_vnet);
if (ifp) {
saved_vnet = curvnet;
curvnet = ifp->if_vnet;
}
inm_purge(inm);
free(inm, M_IPMADDR);
if_delmulti_ifma_flags(ifma, 1);
if (ifp) {
CURVNET_RESTORE();
curvnet = saved_vnet;
if_rele(ifp);
}
}
@ -1666,6 +1669,7 @@ inp_gcmoptions(epoch_context_t ctx)
struct in_mfilter *imf;
struct in_multi *inm;
struct ifnet *ifp;
struct vnet *saved_vnet;
size_t idx, nmships;
imo = __containerof(ctx, struct ip_moptions, imo_epoch_ctx);
@ -1677,11 +1681,13 @@ inp_gcmoptions(epoch_context_t ctx)
imf_leave(imf);
inm = imo->imo_membership[idx];
ifp = inm->inm_ifp;
if (ifp)
CURVNET_SET(ifp->if_vnet);
if (ifp) {
saved_vnet = curvnet;
curvnet = ifp->if_vnet;
}
(void)in_leavegroup(inm, imf);
if (ifp)
CURVNET_RESTORE();
curvnet = saved_vnet;
if (imf)
imf_purge(imf);
}

View File

@ -524,6 +524,7 @@ in6m_release(struct in6_multi *inm)
{
struct ifmultiaddr *ifma;
struct ifnet *ifp;
struct vnet *saved_vnet;
CTR2(KTR_MLD, "%s: refcount is %d", __func__, inm->in6m_refcount);
@ -539,14 +540,16 @@ in6m_release(struct in6_multi *inm)
KASSERT(ifma->ifma_protospec == NULL,
("%s: ifma_protospec != NULL", __func__));
if (ifp)
CURVNET_SET(ifp->if_vnet);
if (ifp) {
saved_vnet = curvnet;
curvnet = ifp->if_vnet;
}
in6m_purge(inm);
free(inm, M_IP6MADDR);
if_delmulti_ifma_flags(ifma, 1);
if (ifp) {
CURVNET_RESTORE();
curvnet = saved_vnet;
if_rele(ifp);
}
}
@ -1628,6 +1631,7 @@ inp_gcmoptions(epoch_context_t ctx)
struct in6_mfilter *imf;
struct in6_multi *inm;
struct ifnet *ifp;
struct vnet *saved_vnet;
size_t idx, nmships;
imo = __containerof(ctx, struct ip6_moptions, imo6_epoch_ctx);
@ -1639,11 +1643,13 @@ inp_gcmoptions(epoch_context_t ctx)
im6f_leave(imf);
inm = imo->im6o_membership[idx];
ifp = inm->in6m_ifp;
if (ifp)
CURVNET_SET(ifp->if_vnet);
if (ifp) {
saved_vnet = curvnet;
curvnet = ifp->if_vnet;
}
(void)in6_leavegroup(inm, imf);
if (ifp)
CURVNET_RESTORE();
curvnet = saved_vnet;
if (imf)
im6f_purge(imf);
}