Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 5 Sep 2003 09:11:17 -0700 (PDT)
From:      Sam Leffler <sam@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 37575 for review
Message-ID:  <200309051611.h85GBHDd040193@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=37575

Change 37575 by sam@sam_ebb on 2003/09/05 09:10:33

	Locking fixups based on testing by Pavlin Radoslavov <pavlin@icir.org>.
	
	Move up VIF_LOCK in add_mfc to insure lock order for ip_mdq.
	ip_mdq handling of bw_meter_receive_packet does not require
	an explicit MFC lock; use an existing lock.

Affected files ...

.. //depot/projects/netperf/sys/netinet/ip_mroute.c#9 edit

Differences ...

==== //depot/projects/netperf/sys/netinet/ip_mroute.c#9 (text+ko) ====

@@ -1116,6 +1116,7 @@
     u_short nstl;
     int s;
 
+    VIF_LOCK();
     MFC_LOCK();
 
     rt = mfc_find(mfccp->mfcc_origin.s_addr, mfccp->mfcc_mcastgrp.s_addr);
@@ -1130,6 +1131,7 @@
 
 	update_mfc_params(rt, mfccp);
 	MFC_UNLOCK();
+	VIF_UNLOCK();
 	return 0;
     }
 
@@ -1212,6 +1214,7 @@
 	}
     }
     MFC_UNLOCK();
+    VIF_UNLOCK();
     return 0;
 }
 
@@ -1331,6 +1334,7 @@
     }
 
     VIF_LOCK();
+    MFC_LOCK();
     if (imo && ((vifi = imo->imo_multicast_vif) < numvifs)) {
 	if (ip->ip_ttl < 255)
 	    ip->ip_ttl++;	/* compensate for -1 in *_send routines */
@@ -1344,6 +1348,7 @@
 		vifp->v_ifp->if_name, vifp->v_ifp->if_unit);
 	}
 	error = ip_mdq(m, ifp, NULL, vifi);
+	MFC_UNLOCK();
 	VIF_UNLOCK();
 	return error;
     }
@@ -1359,6 +1364,7 @@
      * or a packet destined to a local-only group.
      */
     if (ip->ip_ttl <= 1 || ntohl(ip->ip_dst.s_addr) <= INADDR_MAX_LOCAL_GROUP) {
+	MFC_UNLOCK();
 	VIF_UNLOCK();
 	return 0;
     }
@@ -1366,14 +1372,13 @@
     /*
      * Determine forwarding vifs from the forwarding cache table
      */
-    MFC_LOCK();
     ++mrtstat.mrts_mfc_lookups;
     rt = mfc_find(ip->ip_src.s_addr, ip->ip_dst.s_addr);
 
     /* Entry exists, so forward if necessary */
     if (rt != NULL) {
+	error = ip_mdq(m, ifp, rt, -1);
 	MFC_UNLOCK();
-	error = ip_mdq(m, ifp, rt, -1);
 	VIF_UNLOCK();
 	return error;
     } else {
@@ -1744,10 +1749,9 @@
 	struct timeval now;
 
 	GET_TIME(now);
-	MFC_LOCK();
+	MFC_LOCK_ASSERT();
 	for (x = rt->mfc_bw_meter; x != NULL; x = x->bm_mfc_next)
 	    bw_meter_receive_packet(x, plen, &now);
-	MFC_UNLOCK();
     }
 
     return 0;



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