/* * npf_pfil_unregister: unregister pfil(9) hooks. */ void npf_pfil_unregister(void) { mutex_enter(softnet_lock); KERNEL_LOCK(1, NULL); if (npf_ph_if) { (void)pfil_remove_hook(npf_ifhook, NULL, PFIL_IFADDR | PFIL_IFNET, npf_ph_if); } if (npf_ph_inet) { (void)pfil_remove_hook(npf_packet_handler, NULL, PFIL_ALL, npf_ph_inet); } if (npf_ph_inet6) { (void)pfil_remove_hook(npf_packet_handler, NULL, PFIL_ALL, npf_ph_inet6); } npf_ph_if = NULL; KERNEL_UNLOCK_ONE(NULL); mutex_exit(softnet_lock); }
/* * npf_pfil_unregister: unregister pfil(9) hooks. */ void npf_pfil_unregister(bool fini) { npf_t *npf = npf_getkernctx(); mutex_enter(softnet_lock); KERNEL_LOCK(1, NULL); if (fini && npf_ph_if) { (void)pfil_remove_hook(npf_ifhook, NULL, PFIL_IFADDR | PFIL_IFNET, npf_ph_if); } if (npf_ph_inet) { (void)pfil_remove_hook(npf_packet_handler, npf, PFIL_ALL, npf_ph_inet); } if (npf_ph_inet6) { (void)pfil_remove_hook(npf_packet_handler, npf, PFIL_ALL, npf_ph_inet6); } pfil_registered = false; KERNEL_UNLOCK_ONE(NULL); mutex_exit(softnet_lock); }
void pfi_destroy(void) { struct pfi_kif *p; ifnet_t *ifp; int s; int bound; pfil_remove_hook(pfil_ifaddr_wrapper, NULL, PFIL_IFADDR, if_pfil); pfil_remove_hook(pfil_ifnet_wrapper, NULL, PFIL_IFNET, if_pfil); bound = curlwp_bind(); s = pserialize_read_enter(); IFNET_READER_FOREACH(ifp) { struct psref psref; psref_acquire(&psref, &ifp->if_psref, ifnet_psref_class); pserialize_read_exit(s); pfi_detach_ifnet(ifp); pfi_destroy_groups(ifp); s = pserialize_read_enter(); psref_release(&psref, &ifp->if_psref, ifnet_psref_class); } pserialize_read_exit(s); curlwp_bindx(bound); while ((p = RB_MIN(pfi_ifhead, &pfi_ifs))) { RB_REMOVE(pfi_ifhead, &pfi_ifs, p); free(p, PFI_MTYPE); } pool_destroy(&pfi_addr_pl); free(pfi_buffer, PFI_MTYPE); }