PERFORCE change 118550 for review
Marko Zec
zec at FreeBSD.org
Sat Apr 21 23:30:48 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=118550
Change 118550 by zec at zec_tca51 on 2007/04/21 23:30:22
Make sure that uma_zcreate() and uma_zdestroy() for
various global pools used by pf are called only once
in pf_load() / pf_unload() call graph, and not once for
each stack instance in iattach() / idetach() routines.
This seems to have fixed kldloading / kldunloading of
pf when multiple stack instances are active.
Affected files ...
.. //depot/projects/vimage/src/sys/contrib/pf/net/pf_ioctl.c#6 edit
Differences ...
==== //depot/projects/vimage/src/sys/contrib/pf/net/pf_ioctl.c#6 (text+ko) ====
@@ -256,7 +256,6 @@
};
#endif
-static volatile int pf_pfil_hooked = 0;
struct mtx pf_task_mtx;
pflog_packet_t *pflog_packet_ptr = NULL;
@@ -341,8 +340,10 @@
if ( (error = pf_osfp_initialize()) ) {
#ifdef VIMAGE
if (curvnet == &vnet_0)
+ cleanup_pf_zone();
+#else
+ cleanup_pf_zone();
#endif
- cleanup_pf_zone();
pf_osfp_cleanup();
return (error);
}
@@ -405,7 +406,6 @@
if (curvnet == &vnet_0) {
#endif
pf_normalize_init();
- pf_pfil_hooked = 0;
#ifdef VIMAGE
}
#endif
@@ -1469,16 +1469,6 @@
if (V_pf_status.running)
error = EEXIST;
else {
-#ifdef __FreeBSD__
- PF_UNLOCK();
- error = hook_pf();
- PF_LOCK();
- if (error) {
- DPFPRINTF(PF_DEBUG_MISC,
- ("pf: pfil registeration fail\n"));
- break;
- }
-#endif
V_pf_status.running = 1;
V_pf_status.since = time_second;
if (V_pf_status.stateid == 0) {
@@ -1494,16 +1484,6 @@
error = ENOENT;
else {
V_pf_status.running = 0;
-#ifdef __FreeBSD__
- PF_UNLOCK();
- error = dehook_pf();
- PF_LOCK();
- if (error) {
- V_pf_status.running = 1;
- DPFPRINTF(PF_DEBUG_MISC,
- ("pf: pfil unregisteration failed\n"));
- }
-#endif
V_pf_status.since = time_second;
DPFPRINTF(PF_DEBUG_MISC, ("pf: stopped\n"));
}
@@ -3546,9 +3526,6 @@
PF_ASSERT(MA_NOTOWNED);
- if (pf_pfil_hooked)
- return (0);
-
pfh_inet = pfil_head_get(PFIL_TYPE_AF, AF_INET);
if (pfh_inet == NULL)
return (ESRCH); /* XXX */
@@ -3567,7 +3544,6 @@
pfil_add_hook(pf_check6_out, NULL, PFIL_OUT | PFIL_WAITOK, pfh_inet6);
#endif
- pf_pfil_hooked = 1;
return (0);
}
@@ -3581,9 +3557,6 @@
PF_ASSERT(MA_NOTOWNED);
- if (pf_pfil_hooked == 0)
- return (0);
-
pfh_inet = pfil_head_get(PFIL_TYPE_AF, AF_INET);
if (pfh_inet == NULL)
return (ESRCH); /* XXX */
@@ -3601,7 +3574,6 @@
pfh_inet6);
#endif
- pf_pfil_hooked = 0;
return (0);
}
@@ -3624,18 +3596,29 @@
static int
pf_load(void)
{
+ int error = 0;
+
init_zone_var();
init_pf_mutex();
pf_dev = make_dev(&pf_cdevsw, 0, 0, 0, 0600, PF_NAME);
+ error = hook_pf();
+ if (error) {
+ printf("%s : pfil registeration failed\n", __FUNCTION__);
+ destroy_dev(pf_dev);
+ destroy_pf_mutex();
+ return error;
+ }
#ifdef VIMAGE
vnet_mod_register(&vnet_pf_modinfo);
#else
- if (vnet_pf_iattach()) {
+ error = vnet_pf_iattach();
+ if (error) {
+ dehook_pf();
destroy_dev(pf_dev);
destroy_pf_mutex();
}
#endif
- return (0);
+ return (error);
}
static int vnet_pf_idetach(void)
@@ -3647,8 +3630,6 @@
shutdown_pf();
pfi_cleanup();
pf_osfp_flush();
- pf_osfp_cleanup();
- cleanup_pf_zone();
PF_UNLOCK();
#ifdef VIMAGE
@@ -3668,6 +3649,8 @@
#else
vnet_pf_idetach();
#endif
+ pf_osfp_cleanup();
+ cleanup_pf_zone();
error = dehook_pf();
if (error) {
/*
More information about the p4-projects
mailing list