Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 May 2018 13:08:45 +0000 (UTC)
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r333978 - in head/sys: netinet netinet6
Message-ID:  <201805211308.w4LD8jQT061276@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: emaste
Date: Mon May 21 13:08:44 2018
New Revision: 333978
URL: https://svnweb.freebsd.org/changeset/base/333978

Log:
  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

Modified:
  head/sys/netinet/in_mcast.c
  head/sys/netinet6/in6_mcast.c

Modified: head/sys/netinet/in_mcast.c
==============================================================================
--- head/sys/netinet/in_mcast.c	Mon May 21 13:08:18 2018	(r333977)
+++ head/sys/netinet/in_mcast.c	Mon May 21 13:08:44 2018	(r333978)
@@ -663,15 +663,17 @@ 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)
+	if (ifp != NULL) {
 		CURVNET_SET(ifp->if_vnet);
-	inm_purge(inm);
-	free(inm, M_IPMADDR);
-
-	if_delmulti_ifma_flags(ifma, 1);
-	if (ifp) {
+		inm_purge(inm);
+		free(inm, M_IPMADDR);
+		if_delmulti_ifma_flags(ifma, 1);
 		CURVNET_RESTORE();
 		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);
 		inm = imo->imo_membership[idx];
 		ifp = inm->inm_ifp;
-		if (ifp)
+		if (ifp != NULL) {
 			CURVNET_SET(ifp->if_vnet);
-		(void)in_leavegroup(inm, imf);
-		if (ifp)
+			(void)in_leavegroup(inm, imf);
 			CURVNET_RESTORE();
+		} else {
+			(void)in_leavegroup(inm, imf);
+		}
 		if (imf)
 			imf_purge(imf);
 	}

Modified: head/sys/netinet6/in6_mcast.c
==============================================================================
--- head/sys/netinet6/in6_mcast.c	Mon May 21 13:08:18 2018	(r333977)
+++ head/sys/netinet6/in6_mcast.c	Mon May 21 13:08:44 2018	(r333978)
@@ -539,15 +539,17 @@ in6m_release(struct in6_multi *inm)
 	KASSERT(ifma->ifma_protospec == NULL,
 	    ("%s: ifma_protospec != NULL", __func__));
 
-	if (ifp)
+	if (ifp != NULL) {
 		CURVNET_SET(ifp->if_vnet);
-	in6m_purge(inm);
-	free(inm, M_IP6MADDR);
-
-	if_delmulti_ifma_flags(ifma, 1);
-	if (ifp) {
+		in6m_purge(inm);
+		free(inm, M_IP6MADDR);
+		if_delmulti_ifma_flags(ifma, 1);
 		CURVNET_RESTORE();
 		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);
 		inm = imo->im6o_membership[idx];
 		ifp = inm->in6m_ifp;
-		if (ifp)
+		if (ifp != NULL) {
 			CURVNET_SET(ifp->if_vnet);
-		(void)in6_leavegroup(inm, imf);
-		if (ifp)
+			(void)in6_leavegroup(inm, imf);
 			CURVNET_RESTORE();
+		} else {
+			(void)in6_leavegroup(inm, imf);
+		}
 		if (imf)
 			im6f_purge(imf);
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201805211308.w4LD8jQT061276>