PERFORCE change 112878 for review

Marko Zec zec at FreeBSD.org
Sat Jan 13 21:03:11 UTC 2007


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

Change 112878 by zec at zec_tpx32 on 2007/01/13 21:03:01

	Provide an instance-detach method for ipfw.  This allows ipfw
	to be correctly kldunloaded regardless of the number of active
	vnets, and should be called on vnet destroy events in the future.

Affected files ...

.. //depot/projects/vimage/src/sys/netinet/ip_fw2.c#6 edit

Differences ...

==== //depot/projects/vimage/src/sys/netinet/ip_fw2.c#6 (text+ko) ====

@@ -115,6 +115,7 @@
 #include <security/mac/mac_framework.h>
 
 static int	vnet_ipfw_iattach(void);
+static int	vnet_ipfw_idetach(void);
 
 #ifdef VIMAGE
 static struct vnet_modinfo vnet_ipfw_modinfo = {
@@ -123,7 +124,7 @@
 	.name		= "ipfw",
 	.symmap		= NULL,
 	.i_attach	= vnet_ipfw_iattach,
-	.i_detach	= NULL,
+	.i_detach	= vnet_ipfw_idetach,
 };
 #endif
 
@@ -5064,17 +5065,14 @@
 	return (0);
 }
 
-void
-ipfw_destroy(void)
+static int vnet_ipfw_idetach(void)
 {
-	INIT_VNET_IPFW(curvnetb); /* XXX */
+	INIT_VNET_IPFW(curvnetb);
 	struct ip_fw *reap;
 #ifdef IPFIREWALL_NAT
 	struct cfg_nat *ptr, *ptr_temp;
 #endif
 
-	ip_fw_chk_ptr = NULL;
-	ip_fw_ctl_ptr = NULL;
 	callout_drain(&V_ipfw_timeout);
 	IPFW_WLOCK(&V_layer3_chain);
 	flush_tables(&V_layer3_chain);
@@ -5085,7 +5083,6 @@
 		LibAliasUninit(ptr->lib);
 		free(ptr, M_IPFW);
 	}
-	EVENTHANDLER_DEREGISTER(ifaddr_event, ifaddr_event_tag);
 #endif
 	V_layer3_chain.reap = NULL;
 	free_chain(&V_layer3_chain, 1 /* kill default rule */);
@@ -5093,9 +5090,33 @@
 	IPFW_WUNLOCK(&V_layer3_chain);
 	if (reap != NULL)
 		reap_rules(reap);
+	IPFW_LOCK_DESTROY(&V_layer3_chain);
+
+#ifdef VIMAGE
+	curvnetb->mod_data[vnet_ipfw_modinfo.id] = NULL;
+	free(vnet_ipfw, M_IPFW);
+#endif
+
+	return 0;
+}
+
+void
+ipfw_destroy(void)
+{
+	ip_fw_chk_ptr = NULL;
+	ip_fw_ctl_ptr = NULL;
+
+#ifdef VIMAGE
+	vnet_mod_deregister(&vnet_ipfw_modinfo);
+#else
+	vnet_ipfw_idetach();
+#endif
+
+#ifdef IPFIREWALL_NAT
+	EVENTHANDLER_DEREGISTER(ifaddr_event, ifaddr_event_tag);
+#endif
 	IPFW_DYN_LOCK_DESTROY();
 	uma_zdestroy(ipfw_dyn_rule_zone);
-	IPFW_LOCK_DESTROY(&V_layer3_chain);
 
 #ifdef INET6
 	/* Free IPv6 fw sysctl tree. */


More information about the p4-projects mailing list