PERFORCE change 149907 for review

Marko Zec zec at FreeBSD.org
Tue Sep 16 21:00:07 UTC 2008


http://perforce.freebsd.org/chv.cgi?CH=149907

Change 149907 by zec at zec_tpx32 on 2008/09/16 20:59:48

	Replace VNET_ITERLOOP_BEGIN / _END kludges with slightly
	more readable VNET iteration macros.
	Obtained from:	vimage

Affected files ...

.. //depot/projects/vimage-commit2/src/sys/contrib/pf/net/pf_subr.c#5 edit
.. //depot/projects/vimage-commit2/src/sys/contrib/rdma/rdma_cma.c#7 edit
.. //depot/projects/vimage-commit2/src/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb.c#3 edit
.. //depot/projects/vimage-commit2/src/sys/net/if.c#14 edit
.. //depot/projects/vimage-commit2/src/sys/net/if_ef.c#6 edit
.. //depot/projects/vimage-commit2/src/sys/net80211/ieee80211_ddb.c#4 edit
.. //depot/projects/vimage-commit2/src/sys/netgraph/atm/ng_atm.c#6 edit
.. //depot/projects/vimage-commit2/src/sys/netgraph/ng_gif.c#7 edit
.. //depot/projects/vimage-commit2/src/sys/netinet/igmp.c#8 edit
.. //depot/projects/vimage-commit2/src/sys/netinet/in_pcb.c#13 edit
.. //depot/projects/vimage-commit2/src/sys/netinet/in_rmx.c#9 edit
.. //depot/projects/vimage-commit2/src/sys/netinet/ip_input.c#11 edit
.. //depot/projects/vimage-commit2/src/sys/netinet/tcp_subr.c#11 edit
.. //depot/projects/vimage-commit2/src/sys/netinet/tcp_timer.c#8 edit
.. //depot/projects/vimage-commit2/src/sys/netinet6/frag6.c#9 edit
.. //depot/projects/vimage-commit2/src/sys/netipsec/key.c#11 edit
.. //depot/projects/vimage-commit2/src/sys/sys/vimage.h#16 edit

Differences ...

==== //depot/projects/vimage-commit2/src/sys/contrib/pf/net/pf_subr.c#5 (text+ko) ====

@@ -123,6 +123,7 @@
 u_int32_t
 pf_new_isn(struct pf_state *s)
 {
+	INIT_VNET_INET(curvnet);
 	u_int32_t md5_buffer[4];
 	u_int32_t new_isn;
 	struct pf_state_host *src, *dst;

==== //depot/projects/vimage-commit2/src/sys/contrib/rdma/rdma_cma.c#7 (text+ko) ====

@@ -48,8 +48,10 @@
 #include <sys/syslog.h>
 #include <sys/vimage.h>
 
+#include <net/if.h>
 #include <netinet/in.h>
 #include <netinet/in_pcb.h>
+#include <netinet/vinet.h>
 
 #include <contrib/rdma/rdma_cm.h>
 #include <contrib/rdma/ib_cache.h>
@@ -1947,6 +1949,7 @@
 
 static int cma_alloc_any_port(struct kvl *ps, struct rdma_id_private *id_priv)
 {
+	INIT_VNET_INET(curvnet);
 	struct rdma_bind_list *bind_list;
 	int port, ret;
 
@@ -1991,6 +1994,7 @@
 
 static int cma_use_port(struct kvl *ps, struct rdma_id_private *id_priv)
 {
+	INIT_VNET_INET(curvnet);
 	struct rdma_id_private *cur_id;
 	struct sockaddr_in *sin, *cur_sin;
 	struct rdma_bind_list *bind_list;
@@ -2910,6 +2914,7 @@
 
 static int cma_init(void)
 {
+	INIT_VNET_INET(curvnet);
 	int ret;
 
 	LIST_INIT(&listen_any_list);

==== //depot/projects/vimage-commit2/src/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb.c#3 (text+ko) ====

@@ -217,6 +217,7 @@
 static int
 iwch_init_module(void)
 {
+	VNET_ITERATOR_DECL(vnet_iter);
 	int err;
 	struct ifnet *ifp;
 
@@ -238,9 +239,15 @@
 
 	/* Register existing TOE interfaces by walking the ifnet chain */
 	IFNET_RLOCK();
-	TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
-		(void)ifaddr_event_handler(NULL, ifp);
+	VNET_LIST_REF();
+	VNET_FOREACH(vnet_iter) {
+		CURVNET_SET(vnet_iter); /* XXX CURVNET_SET_QUIET() ? */
+		INIT_VNET_NET(vnet_iter);
+		TAILQ_FOREACH(ifp, &V_ifnet, if_link)
+			(void)ifaddr_event_handler(NULL, ifp);
+		CURVNET_RESTORE();
 	}
+	VNET_LIST_UNREF();
 	IFNET_RUNLOCK();
 	return 0;
 }

==== //depot/projects/vimage-commit2/src/sys/net/if.c#14 (text+ko) ====

@@ -1528,19 +1528,24 @@
 static void
 if_slowtimo(void *arg)
 {
+	VNET_ITERATOR_DECL(vnet_iter);
 	struct ifnet *ifp;
 	int s = splimp();
 
 	IFNET_RLOCK();
-	VNET_ITERLOOP_BEGIN();
-	INIT_VNET_NET(curvnet);
-	TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
-		if (ifp->if_timer == 0 || --ifp->if_timer)
-			continue;
-		if (ifp->if_watchdog)
-			(*ifp->if_watchdog)(ifp);
+	VNET_LIST_REF();
+	VNET_FOREACH(vnet_iter) {
+		CURVNET_SET(vnet_iter);
+		INIT_VNET_NET(vnet_iter);
+		TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
+			if (ifp->if_timer == 0 || --ifp->if_timer)
+				continue;
+			if (ifp->if_watchdog)
+				(*ifp->if_watchdog)(ifp);
+		}
+		CURVNET_RESTORE();
 	}
-	VNET_ITERLOOP_END();
+	VNET_LIST_UNREF();
 	IFNET_RUNLOCK();
 	splx(s);
 	timeout(if_slowtimo, (void *)0, hz / IFNET_SLOWHZ);

==== //depot/projects/vimage-commit2/src/sys/net/if_ef.c#6 (text+ko) ====

@@ -484,43 +484,51 @@
 static int
 ef_load(void)
 {
+	VNET_ITERATOR_DECL(vnet_iter);
 	struct ifnet *ifp;
 	struct efnet *efp;
 	struct ef_link *efl = NULL, *efl_temp;
 	int error = 0, d;
 
-	IFNET_RLOCK();
-	TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
-		if (ifp->if_type != IFT_ETHER) continue;
-		EFDEBUG("Found interface %s\n", ifp->if_xname);
-		efl = (struct ef_link*)malloc(sizeof(struct ef_link), 
-		    M_IFADDR, M_WAITOK | M_ZERO);
-		if (efl == NULL) {
-			error = ENOMEM;
-			break;
-		}
+	VNET_LIST_REF();
+	VNET_FOREACH(vnet_iter) {
+		CURVNET_SET(vnet_iter);
+		INIT_VNET_NET(vnet_iter);
+		IFNET_RLOCK();
+		TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
+			if (ifp->if_type != IFT_ETHER) continue;
+			EFDEBUG("Found interface %s\n", ifp->if_xname);
+			efl = (struct ef_link*)malloc(sizeof(struct ef_link), 
+			    M_IFADDR, M_WAITOK | M_ZERO);
+			if (efl == NULL) {
+				error = ENOMEM;
+				break;
+			}
 
-		efl->el_ifp = ifp;
+			efl->el_ifp = ifp;
 #ifdef ETHER_II
-		error = ef_clone(efl, ETHER_FT_EII);
-		if (error) break;
+			error = ef_clone(efl, ETHER_FT_EII);
+			if (error) break;
 #endif
 #ifdef ETHER_8023
-		error = ef_clone(efl, ETHER_FT_8023);
-		if (error) break;
+			error = ef_clone(efl, ETHER_FT_8023);
+			if (error) break;
 #endif
 #ifdef ETHER_8022
-		error = ef_clone(efl, ETHER_FT_8022);
-		if (error) break;
+			error = ef_clone(efl, ETHER_FT_8022);
+			if (error) break;
 #endif
 #ifdef ETHER_SNAP
-		error = ef_clone(efl, ETHER_FT_SNAP);
-		if (error) break;
+			error = ef_clone(efl, ETHER_FT_SNAP);
+			if (error) break;
 #endif
-		efcount++;
-		SLIST_INSERT_HEAD(&efdev, efl, el_next);
+			efcount++;
+			SLIST_INSERT_HEAD(&efdev, efl, el_next);
+		}
+		IFNET_RUNLOCK();
+		CURVNET_RESTORE();
 	}
-	IFNET_RUNLOCK();
+	VNET_LIST_UNREF();
 	if (error) {
 		if (efl)
 			SLIST_INSERT_HEAD(&efdev, efl, el_next);

==== //depot/projects/vimage-commit2/src/sys/net80211/ieee80211_ddb.c#4 (text+ko) ====

@@ -183,6 +183,7 @@
 
 DB_SHOW_ALL_COMMAND(vaps, db_show_all_vaps)
 {
+	VNET_ITERATOR_DECL(vnet_iter);
 	const struct ifnet *ifp;
 	int i, showall = 0;
 
@@ -193,21 +194,26 @@
 			break;
 		}
 
-	TAILQ_FOREACH(ifp, &V_ifnet, if_list)
-		if (ifp->if_type == IFT_IEEE80211) {
-			const struct ieee80211com *ic = ifp->if_l2com;
+	/* XXX to lock or not to lock the vnet list - we are in DDB here? */
+	VNET_FOREACH(vnet_iter) {
+		INIT_VNET_NET(vnet_iter);
+		TAILQ_FOREACH(ifp, &V_ifnet, if_list)
+			if (ifp->if_type == IFT_IEEE80211) {
+				const struct ieee80211com *ic = ifp->if_l2com;
 
-			if (!showall) {
-				const struct ieee80211vap *vap;
-				db_printf("%s: com %p vaps:",
-				    ifp->if_xname, ic);
-				TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next)
-					db_printf(" %s(%p)",
-					    vap->iv_ifp->if_xname, vap);
-				db_printf("\n");
-			} else
-				_db_show_com(ic, 1, 1, 1);
-		}
+				if (!showall) {
+					const struct ieee80211vap *vap;
+					db_printf("%s: com %p vaps:",
+					    ifp->if_xname, ic);
+					TAILQ_FOREACH(vap, &ic->ic_vaps,
+					    iv_next)
+						db_printf(" %s(%p)",
+						    vap->iv_ifp->if_xname, vap);
+					db_printf("\n");
+				} else
+					_db_show_com(ic, 1, 1, 1);
+			}
+	}
 }
 
 static void

==== //depot/projects/vimage-commit2/src/sys/netgraph/atm/ng_atm.c#6 (text+ko) ====

@@ -1379,6 +1379,7 @@
 static int
 ng_atm_mod_event(module_t mod, int event, void *data)
 {
+	VNET_ITERATOR_DECL(vnet_iter);
 	struct ifnet *ifp;
 	int error = 0;
 
@@ -1402,10 +1403,17 @@
 		ng_atm_event_p = ng_atm_event;
 
 		/* Create nodes for existing ATM interfaces */
-		TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
-			if (ifp->if_type == IFT_ATM)
-				ng_atm_attach(ifp);
+		VNET_LIST_REF();
+		VNET_FOREACH(vnet_iter) {
+			CURVNET_SET_QUIET(vnet_iter);
+			INIT_VNET_NET(vnet_iter);
+			TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
+				if (ifp->if_type == IFT_ATM)
+					ng_atm_attach(ifp);
+			}
+			CURVNET_RESTORE();
 		}
+		VNET_LIST_UNREF();
 		IFNET_RUNLOCK();
 		break;
 
@@ -1419,10 +1427,17 @@
 		ng_atm_input_orphan_p = NULL;
 		ng_atm_event_p = NULL;
 
-		TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
-			if (ifp->if_type == IFT_ATM)
-				ng_atm_detach(ifp);
+		VNET_LIST_REF();
+		VNET_FOREACH(vnet_iter) {
+			CURVNET_SET_QUIET(vnet_iter);
+			INIT_VNET_NET(vnet_iter);
+			TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
+				if (ifp->if_type == IFT_ATM)
+					ng_atm_detach(ifp);
+			}
+			CURVNET_RESTORE();
 		}
+		VNET_LIST_UNREF();
 		IFNET_RUNLOCK();
 		break;
 

==== //depot/projects/vimage-commit2/src/sys/netgraph/ng_gif.c#7 (text+ko) ====

@@ -541,6 +541,7 @@
 static int
 ng_gif_mod_event(module_t mod, int event, void *data)
 {
+	VNET_ITERATOR_DECL(vnet_iter);
 	struct ifnet *ifp;
 	int error = 0;
 	int s;
@@ -561,10 +562,17 @@
 
 		/* Create nodes for any already-existing gif interfaces */
 		IFNET_RLOCK();
-		TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
-			if (ifp->if_type == IFT_GIF)
-				ng_gif_attach(ifp);
+		VNET_LIST_REF();
+		VNET_FOREACH(vnet_iter) {
+			CURVNET_SET_QUIET(vnet_iter); /* XXX revisit quiet */
+			INIT_VNET_NET(curvnet);
+			TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
+				if (ifp->if_type == IFT_GIF)
+					ng_gif_attach(ifp);
+			}
+			CURVNET_RESTORE();
 		}
+		VNET_LIST_UNREF();
 		IFNET_RUNLOCK();
 		break;
 

==== //depot/projects/vimage-commit2/src/sys/netinet/igmp.c#8 (text+ko) ====

@@ -412,6 +412,7 @@
 void
 igmp_fasttimo(void)
 {
+	VNET_ITERATOR_DECL(vnet_iter);
 	register struct in_multi *inm;
 	struct in_multistep step;
 
@@ -425,36 +426,50 @@
 
 	IN_MULTI_LOCK();
 	igmp_timers_are_running = 0;
-	IN_FIRST_MULTI(step, inm);
-	while (inm != NULL) {
-		if (inm->inm_timer == 0) {
-			/* do nothing */
-		} else if (--inm->inm_timer == 0) {
-			igmp_sendpkt(inm, inm->inm_rti->rti_type, 0);
-			inm->inm_state = IGMP_IREPORTEDLAST;
-		} else {
-			igmp_timers_are_running = 1;
+	VNET_LIST_REF();
+	VNET_FOREACH(vnet_iter) {
+		CURVNET_SET(vnet_iter);
+		INIT_VNET_INET(vnet_iter);
+		IN_FIRST_MULTI(step, inm);
+		while (inm != NULL) {
+			if (inm->inm_timer == 0) {
+				/* do nothing */
+			} else if (--inm->inm_timer == 0) {
+				igmp_sendpkt(inm, inm->inm_rti->rti_type, 0);
+				inm->inm_state = IGMP_IREPORTEDLAST;
+			} else {
+				igmp_timers_are_running = 1;
+			}
+			IN_NEXT_MULTI(step, inm);
 		}
-		IN_NEXT_MULTI(step, inm);
+		CURVNET_RESTORE();
 	}
+	VNET_LIST_UNREF();
 	IN_MULTI_UNLOCK();
 }
 
 void
 igmp_slowtimo(void)
 {
+	VNET_ITERATOR_DECL(vnet_iter);
 	struct router_info *rti;
 
 	IGMP_PRINTF("[igmp.c,_slowtimo] -- > entering \n");
 	mtx_lock(&igmp_mtx);
-	INIT_VNET_INET(vnet_iter);
-	SLIST_FOREACH(rti, &V_router_info_head, rti_list) {
-		if (rti->rti_type == IGMP_V1_ROUTER) {
-			rti->rti_time++;
-			if (rti->rti_time >= IGMP_AGE_THRESHOLD)
-				rti->rti_type = IGMP_V2_ROUTER;
+	VNET_LIST_REF();
+	VNET_FOREACH(vnet_iter) {
+		CURVNET_SET(vnet_iter);
+		INIT_VNET_INET(vnet_iter);
+		SLIST_FOREACH(rti, &V_router_info_head, rti_list) {
+			if (rti->rti_type == IGMP_V1_ROUTER) {
+				rti->rti_time++;
+				if (rti->rti_time >= IGMP_AGE_THRESHOLD)
+					rti->rti_type = IGMP_V2_ROUTER;
+			}
 		}
+		CURVNET_RESTORE();
 	}
+	VNET_LIST_UNREF();
 	mtx_unlock(&igmp_mtx);
 	IGMP_PRINTF("[igmp.c,_slowtimo] -- > exiting \n");
 }

==== //depot/projects/vimage-commit2/src/sys/netinet/in_pcb.c#13 (text+ko) ====

@@ -1213,16 +1213,22 @@
 void
 ipport_tick(void *xtp)
 {
+	VNET_ITERATOR_DECL(vnet_iter);
 
-	VNET_ITERLOOP_BEGIN();
-	INIT_VNET_INET(curvnet);
-	if (V_ipport_tcpallocs <= V_ipport_tcplastcount + V_ipport_randomcps) {
-		if (V_ipport_stoprandom > 0)
-			V_ipport_stoprandom--;
-	} else
-		V_ipport_stoprandom = V_ipport_randomtime;
-	V_ipport_tcplastcount = V_ipport_tcpallocs;
-	VNET_ITERLOOP_END();
+	VNET_LIST_REF();
+	VNET_FOREACH(vnet_iter) {
+		CURVNET_SET(vnet_iter);	/* XXX appease INVARIANTS here */
+		INIT_VNET_INET(vnet_iter);
+		if (V_ipport_tcpallocs <=
+		    V_ipport_tcplastcount + V_ipport_randomcps) {
+			if (V_ipport_stoprandom > 0)
+				V_ipport_stoprandom--;
+		} else
+			V_ipport_stoprandom = V_ipport_randomtime;
+		V_ipport_tcplastcount = V_ipport_tcpallocs;
+		CURVNET_RESTORE();
+	}
+	VNET_LIST_UNREF();
 	callout_reset(&ipport_tick_callout, hz, ipport_tick, NULL);
 }
 

==== //depot/projects/vimage-commit2/src/sys/netinet/in_rmx.c#9 (text+ko) ====

@@ -327,21 +327,29 @@
 void
 in_rtqdrain(void)
 {
+	VNET_ITERATOR_DECL(vnet_iter);
 	struct radix_node_head *rnh;
 	struct rtqk_arg arg;
 	int 	fibnum;
 
-	for ( fibnum = 0; fibnum < rt_numfibs; fibnum++) {
-		rnh = V_rt_tables[fibnum][AF_INET];
-		arg.found = arg.killed = 0;
-		arg.rnh = rnh;
-		arg.nextstop = 0;
-		arg.draining = 1;
-		arg.updating = 0;
-		RADIX_NODE_HEAD_LOCK(rnh);
-		rnh->rnh_walktree(rnh, in_rtqkill, &arg);
-		RADIX_NODE_HEAD_UNLOCK(rnh);
+	VNET_LIST_REF();
+	VNET_FOREACH(vnet_iter) {
+		CURVNET_SET(vnet_iter);
+		INIT_VNET_NET(vnet_iter);
+		for ( fibnum = 0; fibnum < rt_numfibs; fibnum++) {
+			rnh = V_rt_tables[fibnum][AF_INET];
+			arg.found = arg.killed = 0;
+			arg.rnh = rnh;
+			arg.nextstop = 0;
+			arg.draining = 1;
+			arg.updating = 0;
+			RADIX_NODE_HEAD_LOCK(rnh);
+			rnh->rnh_walktree(rnh, in_rtqkill, &arg);
+			RADIX_NODE_HEAD_UNLOCK(rnh);
+		}
+		CURVNET_RESTORE();
 	}
+	VNET_LIST_UNREF();
 }
 
 static int _in_rt_was_here;

==== //depot/projects/vimage-commit2/src/sys/netinet/ip_input.c#11 (text+ko) ====

@@ -1091,39 +1091,47 @@
 void
 ip_slowtimo(void)
 {
+	VNET_ITERATOR_DECL(vnet_iter);
 	struct ipq *fp;
 	int i;
 
 	IPQ_LOCK();
-	VNET_ITERLOOP_BEGIN();
-	INIT_VNET_INET(vnet_iter);
-	for (i = 0; i < IPREASS_NHASH; i++) {
-		for(fp = TAILQ_FIRST(&V_ipq[i]); fp;) {
-			struct ipq *fpp;
+	VNET_LIST_REF();
+	VNET_FOREACH(vnet_iter) {
+		CURVNET_SET(vnet_iter);
+		INIT_VNET_INET(vnet_iter);
+		for (i = 0; i < IPREASS_NHASH; i++) {
+			for(fp = TAILQ_FIRST(&V_ipq[i]); fp;) {
+				struct ipq *fpp;
 
-			fpp = fp;
-			fp = TAILQ_NEXT(fp, ipq_list);
-			if(--fpp->ipq_ttl == 0) {
-				V_ipstat.ips_fragtimeout += fpp->ipq_nfrags;
-				ip_freef(&V_ipq[i], fpp);
+				fpp = fp;
+				fp = TAILQ_NEXT(fp, ipq_list);
+				if(--fpp->ipq_ttl == 0) {
+					V_ipstat.ips_fragtimeout +=
+					    fpp->ipq_nfrags;
+					ip_freef(&V_ipq[i], fpp);
+				}
 			}
 		}
-	}
-	/*
-	 * If we are over the maximum number of fragments
-	 * (due to the limit being lowered), drain off
-	 * enough to get down to the new limit.
-	 */
-	if (V_maxnipq >= 0 && V_nipq > V_maxnipq) {
-		for (i = 0; i < IPREASS_NHASH; i++) {
-			while (V_nipq > V_maxnipq && !TAILQ_EMPTY(&V_ipq[i])) {
-				V_ipstat.ips_fragdropped +=
-				    TAILQ_FIRST(&V_ipq[i])->ipq_nfrags;
-				ip_freef(&V_ipq[i], TAILQ_FIRST(&V_ipq[i]));
+		/*
+		 * If we are over the maximum number of fragments
+		 * (due to the limit being lowered), drain off
+		 * enough to get down to the new limit.
+		 */
+		if (V_maxnipq >= 0 && V_nipq > V_maxnipq) {
+			for (i = 0; i < IPREASS_NHASH; i++) {
+				while (V_nipq > V_maxnipq &&
+				    !TAILQ_EMPTY(&V_ipq[i])) {
+					V_ipstat.ips_fragdropped +=
+					    TAILQ_FIRST(&V_ipq[i])->ipq_nfrags;
+					ip_freef(&V_ipq[i],
+					    TAILQ_FIRST(&V_ipq[i]));
+				}
 			}
 		}
+		CURVNET_RESTORE();
 	}
-	VNET_ITERLOOP_END();
+	VNET_LIST_UNREF();
 	IPQ_UNLOCK();
 }
 
@@ -1133,19 +1141,24 @@
 void
 ip_drain(void)
 {
+	VNET_ITERATOR_DECL(vnet_iter);
 	int     i;
 
 	IPQ_LOCK();
-	VNET_ITERLOOP_BEGIN();
-	INIT_VNET_INET(vnet_iter);
-	for (i = 0; i < IPREASS_NHASH; i++) {
-		while(!TAILQ_EMPTY(&V_ipq[i])) {
-			V_ipstat.ips_fragdropped +=
-			    TAILQ_FIRST(&V_ipq[i])->ipq_nfrags;
-			ip_freef(&V_ipq[i], TAILQ_FIRST(&V_ipq[i]));
+	VNET_LIST_REF();
+	VNET_FOREACH(vnet_iter) {
+		CURVNET_SET(vnet_iter);
+		INIT_VNET_INET(vnet_iter);
+		for (i = 0; i < IPREASS_NHASH; i++) {
+			while(!TAILQ_EMPTY(&V_ipq[i])) {
+				V_ipstat.ips_fragdropped +=
+				    TAILQ_FIRST(&V_ipq[i])->ipq_nfrags;
+				ip_freef(&V_ipq[i], TAILQ_FIRST(&V_ipq[i]));
+			}
 		}
+		CURVNET_RESTORE();
 	}
-	VNET_ITERLOOP_END();
+	VNET_LIST_UNREF();
 	IPQ_UNLOCK();
 	in_rtqdrain();
 }

==== //depot/projects/vimage-commit2/src/sys/netinet/tcp_subr.c#11 (text+ko) ====

@@ -846,9 +846,14 @@
 void
 tcp_drain(void)
 {
+	VNET_ITERATOR_DECL(vnet_iter);
+
+	if (!do_tcpdrain)
+		return;
 
-	if (do_tcpdrain) {
-		VNET_ITERLOOP_BEGIN();
+	VNET_LIST_REF();
+	VNET_FOREACH(vnet_iter) {
+		CURVNET_SET(vnet_iter);
 		INIT_VNET_INET(vnet_iter);
 		struct inpcb *inpb;
 		struct tcpcb *tcpb;
@@ -881,8 +886,9 @@
 			INP_WUNLOCK(inpb);
 		}
 		INP_INFO_RUNLOCK(&V_tcbinfo);
-		VNET_ITERLOOP_END();
+		CURVNET_RESTORE();
 	}
+	VNET_LIST_UNREF();
 }
 
 /*
@@ -1485,18 +1491,24 @@
 static void
 tcp_isn_tick(void *xtp)
 {
+	VNET_ITERATOR_DECL(vnet_iter);
 	u_int32_t projected_offset;
 
 	ISN_LOCK();
-	VNET_ITERLOOP_BEGIN();
-	INIT_VNET_INET(curvnet);
-	projected_offset = V_isn_offset_old + ISN_BYTES_PER_SECOND / 100;
+	VNET_LIST_REF();
+	VNET_FOREACH(vnet_iter) {
+		CURVNET_SET(vnet_iter); /* XXX appease INVARIANTS */
+		INIT_VNET_INET(curvnet);
+		projected_offset =
+		    V_isn_offset_old + ISN_BYTES_PER_SECOND / 100;
 
-	if (SEQ_GT(projected_offset, V_isn_offset))
-		V_isn_offset = projected_offset;
+		if (SEQ_GT(projected_offset, V_isn_offset))
+			V_isn_offset = projected_offset;
 
-	V_isn_offset_old = V_isn_offset;
-	VNET_ITERLOOP_END();
+		V_isn_offset_old = V_isn_offset;
+		CURVNET_RESTORE();
+	}
+	VNET_LIST_UNREF();
 	callout_reset(&isn_callout, hz/100, tcp_isn_tick, NULL);
 	ISN_UNLOCK();
 }

==== //depot/projects/vimage-commit2/src/sys/netinet/tcp_timer.c#8 (text+ko) ====

@@ -124,14 +124,19 @@
 void
 tcp_slowtimo(void)
 {
+	VNET_ITERATOR_DECL(vnet_iter);
 
-	VNET_ITERLOOP_BEGIN();
-	INIT_VNET_INET(vnet_iter);
-	tcp_maxidle = tcp_keepcnt * tcp_keepintvl;
-	INP_INFO_WLOCK(&V_tcbinfo);
-	(void) tcp_tw_2msl_scan(0);
-	INP_INFO_WUNLOCK(&V_tcbinfo);
-	VNET_ITERLOOP_END();
+	VNET_LIST_REF();
+	VNET_FOREACH(vnet_iter) {
+		CURVNET_SET(vnet_iter);
+		INIT_VNET_INET(vnet_iter);
+		tcp_maxidle = tcp_keepcnt * tcp_keepintvl;
+		INP_INFO_WLOCK(&V_tcbinfo);
+		(void) tcp_tw_2msl_scan(0);
+		INP_INFO_WUNLOCK(&V_tcbinfo);
+		CURVNET_RESTORE();
+	}
+	VNET_LIST_UNREF();
 }
 
 int	tcp_syn_backoff[TCP_MAXRXTSHIFT + 1] =

==== //depot/projects/vimage-commit2/src/sys/netinet6/frag6.c#9 (text+ko) ====

@@ -686,32 +686,39 @@
 void
 frag6_slowtimo(void)
 {
+	VNET_ITERATOR_DECL(vnet_iter);
 	struct ip6q *q6;
 
 	IP6Q_LOCK();
-	INIT_VNET_INET6(curvnet);
-	q6 = V_ip6q.ip6q_next;
-	if (q6)
-		while (q6 != &V_ip6q) {
-			--q6->ip6q_ttl;
-			q6 = q6->ip6q_next;
-			if (q6->ip6q_prev->ip6q_ttl == 0) {
-				V_ip6stat.ip6s_fragtimeout++;
-				/* XXX in6_ifstat_inc(ifp, ifs6_reass_fail) */
-				frag6_freef(q6->ip6q_prev);
+	VNET_LIST_REF();
+	VNET_FOREACH(vnet_iter) {
+		CURVNET_SET(vnet_iter);
+		INIT_VNET_INET6(vnet_iter);
+		q6 = V_ip6q.ip6q_next;
+		if (q6)
+			while (q6 != &V_ip6q) {
+				--q6->ip6q_ttl;
+				q6 = q6->ip6q_next;
+				if (q6->ip6q_prev->ip6q_ttl == 0) {
+					V_ip6stat.ip6s_fragtimeout++;
+					/* XXX in6_ifstat_inc(ifp, ifs6_reass_fail) */
+					frag6_freef(q6->ip6q_prev);
+				}
 			}
+		/*
+		 * If we are over the maximum number of fragments
+		 * (due to the limit being lowered), drain off
+		 * enough to get down to the new limit.
+		 */
+		while (V_frag6_nfragpackets > (u_int)V_ip6_maxfragpackets &&
+		    V_ip6q.ip6q_prev) {
+			V_ip6stat.ip6s_fragoverflow++;
+			/* XXX in6_ifstat_inc(ifp, ifs6_reass_fail) */
+			frag6_freef(V_ip6q.ip6q_prev);
 		}
-	/*
-	 * If we are over the maximum number of fragments
-	 * (due to the limit being lowered), drain off
-	 * enough to get down to the new limit.
-	 */
-	while (V_frag6_nfragpackets > (u_int)V_ip6_maxfragpackets &&
-	    V_ip6q.ip6q_prev) {
-		V_ip6stat.ip6s_fragoverflow++;
-		/* XXX in6_ifstat_inc(ifp, ifs6_reass_fail) */
-		frag6_freef(V_ip6q.ip6q_prev);
+		CURVNET_RESTORE();
 	}
+	VNET_LIST_UNREF();
 	IP6Q_UNLOCK();
 
 #if 0
@@ -737,14 +744,21 @@
 void
 frag6_drain(void)
 {
+	VNET_ITERATOR_DECL(vnet_iter);
 
 	if (IP6Q_TRYLOCK() == 0)
 		return;
-	INIT_VNET_INET6(curvnet);
-	while (V_ip6q.ip6q_next != &V_ip6q) {
-		V_ip6stat.ip6s_fragdropped++;
-		/* XXX in6_ifstat_inc(ifp, ifs6_reass_fail) */
-		frag6_freef(V_ip6q.ip6q_next);
+	VNET_LIST_REF();
+	VNET_FOREACH(vnet_iter) {
+		CURVNET_SET(vnet_iter);
+		INIT_VNET_INET6(vnet_iter);
+		while (V_ip6q.ip6q_next != &V_ip6q) {
+			V_ip6stat.ip6s_fragdropped++;
+			/* XXX in6_ifstat_inc(ifp, ifs6_reass_fail) */
+			frag6_freef(V_ip6q.ip6q_next);
+		}
+		CURVNET_RESTORE();
 	}
+	VNET_LIST_UNREF();
 	IP6Q_UNLOCK();
 }

==== //depot/projects/vimage-commit2/src/sys/netipsec/key.c#11 (text+ko) ====

@@ -4328,14 +4328,17 @@
 void
 key_timehandler(void)
 {
+	VNET_ITERATOR_DECL(vnet_iter);
 	time_t now = time_second;
 
-	VNET_ITERLOOP_BEGIN();
-	key_flush_spd(now);
-	key_flush_sad(now);
-	key_flush_acq(now);
-	key_flush_spacq(now);
-	VNET_ITERLOOP_END();
+	VNET_FOREACH(vnet_iter) {
+		CURVNET_SET(vnet_iter);
+		key_flush_spd(now);
+		key_flush_sad(now);
+		key_flush_acq(now);
+		key_flush_spacq(now);
+		CURVNET_RESTORE();
+	}
 
 #ifndef IPSEC_DEBUG2
 	/* do exchange to tick time !! */

==== //depot/projects/vimage-commit2/src/sys/sys/vimage.h#16 (text+ko) ====

@@ -220,23 +220,6 @@
 		      vnet, curvnet);					\
 	modtype *sym = (vnet)->mod_data[modindex];
 
-#define VNET_ITERLOOP_BEGIN()						\
-	struct vnet *vnet_iter;						\
-	VNET_LIST_REF();						\
-	LIST_FOREACH(vnet_iter, &vnet_head, vnet_le) {			\
-		CURVNET_SET(vnet_iter);
-
-#define VNET_ITERLOOP_BEGIN_QUIET()					\
-	struct vnet *vnet_iter;						\
-	VNET_LIST_REF();						\
-	LIST_FOREACH(vnet_iter, &vnet_head, vnet_le) {			\
-		CURVNET_SET_QUIET(vnet_iter);
-
-#define VNET_ITERLOOP_END()						\
-		CURVNET_RESTORE();					\
-	}								\
-	VNET_LIST_UNREF();
-
 #else /* !VNET_DEBUG */
 
 #define VNET_ASSERT(condition)
@@ -254,20 +237,10 @@
 #define INIT_FROM_VNET(vnet, modindex, modtype, sym)			\
 	modtype *sym = (vnet)->mod_data[modindex];
 
-#define VNET_ITERLOOP_BEGIN()						\
-	struct vnet *vnet_iter;						\
-	VNET_LIST_REF();						\
-	LIST_FOREACH(vnet_iter, &vnet_head, vnet_le) {			\
-		CURVNET_SET(vnet_iter);
+#endif /* !VNET_DEBUG */
 
-#define VNET_ITERLOOP_BEGIN_QUIET()	VNET_ITERLOOP_BEGIN()	
-
-#define VNET_ITERLOOP_END()						\
-		CURVNET_RESTORE();					\
-	}								\
-	VNET_LIST_UNREF();
-
-#endif /* !VNET_DEBUG */
+#define VNET_ITERATOR_DECL(arg)	struct vnet *arg;
+#define VNET_FOREACH(arg) LIST_FOREACH(arg, &vnet_head, vnet_le)
 
 #define INIT_VPROCG(arg)	struct vprocg *vprocg = (arg);
 
@@ -302,9 +275,10 @@
 #define VNET_ASSERT(condition)
 #define VSYM(base, sym) (sym)
 #define INIT_FROM_VNET(vnet, modindex, modtype, sym)
-#define VNET_ITERLOOP_BEGIN()
-#define VNET_ITERLOOP_BEGIN_QUIET()
-#define VNET_ITERLOOP_END()
+#define VNET_ITERATOR_DECL(arg)
+#define VNET_FOREACH(arg)
+#define VNET_LIST_REF()
+#define VNET_LIST_UNREF()
 #define INIT_VPROCG(arg)
 #define VPROCG_ITERLOOP_BEGIN()
 #define VPROCG_ITERLOOP_END()


More information about the p4-projects mailing list