diff --git a/sys/netinet/in_mcast.c b/sys/netinet/in_mcast.c index 391f4907da4c..a37f64f1a89d 100644 --- a/sys/netinet/in_mcast.c +++ b/sys/netinet/in_mcast.c @@ -653,7 +653,6 @@ 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); @@ -664,16 +663,14 @@ 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) { - saved_vnet = curvnet; - curvnet = ifp->if_vnet; - } + if (ifp) + CURVNET_SET(ifp->if_vnet); inm_purge(inm); free(inm, M_IPMADDR); if_delmulti_ifma_flags(ifma, 1); if (ifp) { - curvnet = saved_vnet; + CURVNET_RESTORE(); if_rele(ifp); } } @@ -1669,7 +1666,6 @@ 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); @@ -1681,13 +1677,11 @@ inp_gcmoptions(epoch_context_t ctx) imf_leave(imf); inm = imo->imo_membership[idx]; ifp = inm->inm_ifp; - if (ifp) { - saved_vnet = curvnet; - curvnet = ifp->if_vnet; - } + if (ifp) + CURVNET_SET(ifp->if_vnet); (void)in_leavegroup(inm, imf); if (ifp) - curvnet = saved_vnet; + CURVNET_RESTORE(); if (imf) imf_purge(imf); } diff --git a/sys/netinet6/in6_mcast.c b/sys/netinet6/in6_mcast.c index c580ba8ae7e3..ba23b1d85de4 100644 --- a/sys/netinet6/in6_mcast.c +++ b/sys/netinet6/in6_mcast.c @@ -524,7 +524,6 @@ 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); @@ -540,16 +539,14 @@ in6m_release(struct in6_multi *inm) KASSERT(ifma->ifma_protospec == NULL, ("%s: ifma_protospec != NULL", __func__)); - if (ifp) { - saved_vnet = curvnet; - curvnet = ifp->if_vnet; - } + if (ifp) + CURVNET_SET(ifp->if_vnet); in6m_purge(inm); free(inm, M_IP6MADDR); if_delmulti_ifma_flags(ifma, 1); if (ifp) { - curvnet = saved_vnet; + CURVNET_RESTORE(); if_rele(ifp); } } @@ -1631,7 +1628,6 @@ 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); @@ -1643,13 +1639,11 @@ inp_gcmoptions(epoch_context_t ctx) im6f_leave(imf); inm = imo->im6o_membership[idx]; ifp = inm->in6m_ifp; - if (ifp) { - saved_vnet = curvnet; - curvnet = ifp->if_vnet; - } + if (ifp) + CURVNET_SET(ifp->if_vnet); (void)in6_leavegroup(inm, imf); if (ifp) - curvnet = saved_vnet; + CURVNET_RESTORE(); if (imf) im6f_purge(imf); }