Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 5 Sep 2003 21:22:58 -0700 (PDT)
From:      Sam Leffler <sam@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 37649 for review
Message-ID:  <200309060422.h864MwRl098374@repoman.freebsd.org>

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

Change 37649 by sam@sam_ebb on 2003/09/05 21:21:59

	more locking fixups from Pavlin Radoslavov <pavlin@icir.org>

Affected files ...

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

Differences ...

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

@@ -549,14 +549,15 @@
 
     MFC_LOCK();
     rt = mfc_find(req->src.s_addr, req->grp.s_addr);
-    MFC_UNLOCK();
     if (rt == NULL) {
+	MFC_UNLOCK();
 	req->pktcnt = req->bytecnt = req->wrong_if = 0xffffffff;
 	return EADDRNOTAVAIL;
     }
     req->pktcnt = rt->mfc_pkt_cnt;
     req->bytecnt = rt->mfc_byte_cnt;
     req->wrong_if = rt->mfc_wrong_if;
+    MFC_UNLOCK();
     return 0;
 }
 
@@ -568,13 +569,17 @@
 {
     vifi_t vifi = req->vifi;
 
-    if (vifi >= numvifs)
+    VIF_LOCK();
+    if (vifi >= numvifs) {
+	VIF_UNLOCK();
 	return EINVAL;
+    }
 
     req->icount = viftable[vifi].v_pkt_in;
     req->ocount = viftable[vifi].v_pkt_out;
     req->ibytes = viftable[vifi].v_bytes_in;
     req->obytes = viftable[vifi].v_bytes_out;
+    VIF_UNLOCK();
 
     return 0;
 }
@@ -894,8 +899,10 @@
     {
 	sin.sin_addr = vifcp->vifc_lcl_addr;
 	ifa = ifa_ifwithaddr((struct sockaddr *)&sin);
-	if (ifa == NULL)
+	if (ifa == NULL) {
+	    VIF_UNLOCK();
 	    return EADDRNOTAVAIL;
+	}
 	ifp = ifa->ifa_ifp;
     }
 
@@ -1114,7 +1121,6 @@
     u_long hash;
     struct rtdetq *rte;
     u_short nstl;
-    int s;
 
     VIF_LOCK();
     MFC_LOCK();
@@ -1199,7 +1205,8 @@
 	if (rt == NULL) {		/* no upcall, so make a new entry */
 	    rt = (struct mfc *)malloc(sizeof(*rt), M_MRTABLE, M_NOWAIT);
 	    if (rt == NULL) {
-		splx(s);
+		MFC_UNLOCK();
+		VIF_UNLOCK();
 		return ENOBUFS;
 	    }
 	    
@@ -1253,8 +1260,6 @@
 
     *nptr = rt->mfc_next;
 
-    MFC_UNLOCK();
-
     /*
      * free the bw_meter entries
      */
@@ -1265,6 +1270,8 @@
 
     free_bw_list(list);
 
+    MFC_UNLOCK();
+
     return 0;
 }
 
@@ -2439,8 +2446,8 @@
 	
 	list = mfc->mfc_bw_meter;
 	mfc->mfc_bw_meter = NULL;
+	free_bw_list(list);
 	MFC_UNLOCK();
-	free_bw_list(list);
 	return 0;
     } else {			/* Delete a single bw_meter entry */
 	struct bw_meter *prev;
@@ -2463,9 +2470,9 @@
 		prev->bm_mfc_next = x->bm_mfc_next;	/* remove from middle*/
 	    else
 		x->bm_mfc->mfc_bw_meter = x->bm_mfc_next;/* new head of list */
-	    MFC_UNLOCK();
 
 	    unschedule_bw_meter(x);
+	    MFC_UNLOCK();
 	    /* Free the bw_meter entry */
 	    free(x, M_BWMETER);
 	    return 0;



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