Cleanup pf interface mangement - esp. remove EVENTHANDLER before unloading

the coresponding code.  This was lost during 4.1 import.

Reported by:	ru
MFC after:	3 days
This commit is contained in:
mlaier 2007-11-21 14:18:14 +00:00
parent 6c2f035ca3
commit e7409e54d4
2 changed files with 31 additions and 1 deletions

View File

@ -162,6 +162,36 @@ pfi_initialize(void)
#endif
}
#ifdef __FreeBSD__
void
pfi_cleanup(void)
{
struct pfi_kif *p;
PF_UNLOCK();
EVENTHANDLER_DEREGISTER(ifnet_arrival_event, pfi_attach_cookie);
EVENTHANDLER_DEREGISTER(ifnet_departure_event, pfi_detach_cookie);
EVENTHANDLER_DEREGISTER(group_attach_event, pfi_attach_group_cookie);
EVENTHANDLER_DEREGISTER(group_change_event, pfi_change_group_cookie);
EVENTHANDLER_DEREGISTER(group_detach_event, pfi_detach_group_cookie);
EVENTHANDLER_DEREGISTER(ifaddr_event, pfi_ifaddr_event_cookie);
PF_LOCK();
pfi_all = NULL;
while ((p = RB_MIN(pfi_ifhead, &pfi_ifs))) {
if (p->pfik_rules || p->pfik_states) {
printf("pfi_cleanup: dangling refs for %s\n",
p->pfik_name);
}
RB_REMOVE(pfi_ifhead, &pfi_ifs, p);
free(p, PFI_MTYPE);
}
free(pfi_buffer, PFI_MTYPE);
}
#endif
struct pfi_kif *
pfi_kif_get(const char *kif_name)
{

View File

@ -3739,7 +3739,7 @@ pf_unload(void)
wakeup_one(pf_purge_thread);
msleep(pf_purge_thread, &pf_task_mtx, 0, "pftmo", hz);
}
/* pfi_cleanup(); */
pfi_cleanup();
pf_osfp_flush();
pf_osfp_cleanup();
cleanup_pf_zone();