Index: sys/netinet/in_mcast.c
===================================================================
--- sys/netinet/in_mcast.c	(revision 233734)
+++ sys/netinet/in_mcast.c	(working copy)
@@ -1543,6 +1543,7 @@ inp_freemoptions(struct ip_moptions *imo)
 static void
 inp_freemoptions_internal(struct ip_moptions *imo)
 {
+	struct in_multi		*inm;
 	struct in_mfilter	*imf;
 	size_t			 idx, nmships;
 
@@ -1551,7 +1552,11 @@ inp_freemoptions_internal(struct ip_moptions *imo)
 		imf = imo->imo_mfilters ? &imo->imo_mfilters[idx] : NULL;
 		if (imf)
 			imf_leave(imf);
-		(void)in_leavegroup(imo->imo_membership[idx], imf);
+		inm = imo->imo_membership[idx];
+		KASSERT(inm->inm_ifp != NULL, ("%s: no ifp", __func__));
+		CURVNET_SET(inm->inm_ifp->if_vnet);
+		(void)in_leavegroup(inm, imf);
+		CURVNET_RESTORE();
 		if (imf)
 			imf_purge(imf);
 	}
