PERFORCE change 39752 for review

Sam Leffler sam at FreeBSD.org
Wed Oct 15 10:25:09 PDT 2003


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

Change 39752 by sam at sam_ebb on 2003/10/15 10:24:51

	o restructure initialization code so data structures are setup
	  when loaded as a module
	o remove extraneous unlocks immediately prior to destroying them
	
	NB: module unload will fail if mcast routing is active; I've asked
	    Luigi why this is necessary

Affected files ...

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

Differences ...

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

@@ -584,6 +584,27 @@
     return 0;
 }
 
+static void
+ip_mrouter_reset(void)
+{
+    bzero((caddr_t)mfctable, sizeof(mfctable));
+    MFC_LOCK_INIT();
+    VIF_LOCK_INIT();
+    bzero((caddr_t)nexpire, sizeof(nexpire));
+
+    pim_assert = 0;
+    mrt_api_config = 0;
+
+    callout_init(&expire_upcalls_ch, CALLOUT_MPSAFE);
+
+    bw_upcalls_n = 0;
+    bzero((caddr_t)bw_meter_timers, sizeof(bw_meter_timers));
+    callout_init(&bw_upcalls_ch, CALLOUT_MPSAFE);
+    callout_init(&bw_meter_ch, CALLOUT_MPSAFE);
+
+    callout_init(&tbf_reprocess_ch, CALLOUT_MPSAFE);
+}
+
 /*
  * Enable multicast routing
  */
@@ -603,30 +624,16 @@
     if (ip_mrouter != NULL)
 	return EADDRINUSE;
 
-    ip_mrouter = so;
+    ip_mrouter_reset();
 
-    bzero((caddr_t)mfctable, sizeof(mfctable));
-    MFC_LOCK_INIT();
-    VIF_LOCK_INIT();
-    bzero((caddr_t)nexpire, sizeof(nexpire));
-
-    pim_assert = 0;
-
-    callout_init(&expire_upcalls_ch, CALLOUT_MPSAFE);
     callout_reset(&expire_upcalls_ch, EXPIRE_TIMEOUT, expire_upcalls, NULL);
 
-    bw_upcalls_n = 0;
-    bzero((caddr_t)bw_meter_timers, sizeof(bw_meter_timers));
-    callout_init(&bw_upcalls_ch, CALLOUT_MPSAFE);
     callout_reset(&bw_upcalls_ch, BW_UPCALLS_PERIOD,
 	expire_bw_upcalls_send, NULL);
-    callout_init(&bw_meter_ch, CALLOUT_MPSAFE);
     callout_reset(&bw_meter_ch, BW_METER_PERIOD, expire_bw_meter_process, NULL);
 
-    callout_init(&tbf_reprocess_ch, CALLOUT_MPSAFE);
+    ip_mrouter = so;
 
-    mrt_api_config = 0;
-
     if (mrtdebug)
 	log(LOG_DEBUG, "ip_mrouter_init\n");
 
@@ -679,7 +686,6 @@
     bzero((caddr_t)viftable, sizeof(viftable));
     numvifs = 0;
     pim_assert = 0;
-    VIF_UNLOCK();
     VIF_LOCK_DESTROY();
 
     /*
@@ -709,7 +715,6 @@
     bzero((caddr_t)mfctable, sizeof(mfctable));
     bw_upcalls_n = 0;
     bzero(bw_meter_timers, sizeof(bw_meter_timers));
-    MFC_UNLOCK();
     MFC_LOCK_DESTROY();
 
     /*
@@ -3353,7 +3358,8 @@
     switch (type) {
     case MOD_LOAD:
 	s = splnet();
-	/* XXX Protect against multiple loading */
+	ip_mrouter_reset();
+	/* XXX synchronize setup */
 	ip_mcast_src = X_ip_mcast_src;
 	ip_mforward = X_ip_mforward;
 	ip_mrouter_done = X_ip_mrouter_done;
@@ -3368,6 +3374,7 @@
 	break;
 
     case MOD_UNLOAD:
+	/* XXX shutdown on module unload? */
 	if (ip_mrouter)
 	    return EINVAL;
 


More information about the p4-projects mailing list