Pair CURVNET_SET and CURVNET_RESTORE in a block

Per vnet(9), CURVNET_SET and CURVNET_RESTORE cannot be used as a single
statement for a conditional and CURVNET_RESTORE must be in the same
block as CURVNET_SET (or a subblock).

Reviewed by:	andrew
Sponsored by:	The FreeBSD Foundation
This commit is contained in:
emaste 2018-05-21 13:08:44 +00:00
parent 745aef8c6a
commit 3de0b917bf
2 changed files with 26 additions and 18 deletions

View File

@ -663,15 +663,17 @@ inm_release(struct in_multi *inm)
/* XXX this access is not covered by IF_ADDR_LOCK */ /* XXX this access is not covered by IF_ADDR_LOCK */
CTR2(KTR_IGMPV3, "%s: purging ifma %p", __func__, ifma); CTR2(KTR_IGMPV3, "%s: purging ifma %p", __func__, ifma);
if (ifp) if (ifp != NULL) {
CURVNET_SET(ifp->if_vnet); CURVNET_SET(ifp->if_vnet);
inm_purge(inm); inm_purge(inm);
free(inm, M_IPMADDR); free(inm, M_IPMADDR);
if_delmulti_ifma_flags(ifma, 1);
if_delmulti_ifma_flags(ifma, 1);
if (ifp) {
CURVNET_RESTORE(); CURVNET_RESTORE();
if_rele(ifp); if_rele(ifp);
} else {
inm_purge(inm);
free(inm, M_IPMADDR);
if_delmulti_ifma_flags(ifma, 1);
} }
} }
@ -1677,11 +1679,13 @@ inp_gcmoptions(epoch_context_t ctx)
imf_leave(imf); imf_leave(imf);
inm = imo->imo_membership[idx]; inm = imo->imo_membership[idx];
ifp = inm->inm_ifp; ifp = inm->inm_ifp;
if (ifp) if (ifp != NULL) {
CURVNET_SET(ifp->if_vnet); CURVNET_SET(ifp->if_vnet);
(void)in_leavegroup(inm, imf); (void)in_leavegroup(inm, imf);
if (ifp)
CURVNET_RESTORE(); CURVNET_RESTORE();
} else {
(void)in_leavegroup(inm, imf);
}
if (imf) if (imf)
imf_purge(imf); imf_purge(imf);
} }

View File

@ -539,15 +539,17 @@ in6m_release(struct in6_multi *inm)
KASSERT(ifma->ifma_protospec == NULL, KASSERT(ifma->ifma_protospec == NULL,
("%s: ifma_protospec != NULL", __func__)); ("%s: ifma_protospec != NULL", __func__));
if (ifp) if (ifp != NULL) {
CURVNET_SET(ifp->if_vnet); CURVNET_SET(ifp->if_vnet);
in6m_purge(inm); in6m_purge(inm);
free(inm, M_IP6MADDR); free(inm, M_IP6MADDR);
if_delmulti_ifma_flags(ifma, 1);
if_delmulti_ifma_flags(ifma, 1);
if (ifp) {
CURVNET_RESTORE(); CURVNET_RESTORE();
if_rele(ifp); if_rele(ifp);
} else {
in6m_purge(inm);
free(inm, M_IP6MADDR);
if_delmulti_ifma_flags(ifma, 1);
} }
} }
@ -1639,11 +1641,13 @@ inp_gcmoptions(epoch_context_t ctx)
im6f_leave(imf); im6f_leave(imf);
inm = imo->im6o_membership[idx]; inm = imo->im6o_membership[idx];
ifp = inm->in6m_ifp; ifp = inm->in6m_ifp;
if (ifp) if (ifp != NULL) {
CURVNET_SET(ifp->if_vnet); CURVNET_SET(ifp->if_vnet);
(void)in6_leavegroup(inm, imf); (void)in6_leavegroup(inm, imf);
if (ifp)
CURVNET_RESTORE(); CURVNET_RESTORE();
} else {
(void)in6_leavegroup(inm, imf);
}
if (imf) if (imf)
im6f_purge(imf); im6f_purge(imf);
} }