diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index a9a77b6e3e6..04988e792c0 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -7191,8 +7191,6 @@ pf_unload(void *dummy __unused) } sx_xunlock(&pf_end_lock); - pf_nl_unregister(); - if (pf_dev != NULL) destroy_dev(pf_dev); @@ -7220,6 +7218,26 @@ SYSUNINIT(pf_unload, SI_SUB_PROTO_FIREWALL, SI_ORDER_SECOND, pf_unload, NULL); VNET_SYSUNINIT(vnet_pf_uninit, SI_SUB_PROTO_FIREWALL, SI_ORDER_THIRD, vnet_pf_uninit, NULL); +/* + * The netlink handlers use the per-vnet state: register them after + * vnet_pf_init() and unregister them before vnet_pf_uninit(). + */ +static void +pf_nl_init(void *unused __unused) +{ + + pf_nl_register(); +} +SYSINIT(pf_nl, SI_SUB_PROTO_FIREWALL, SI_ORDER_FOURTH, pf_nl_init, NULL); + +static void +pf_nl_uninit(void *unused __unused) +{ + + pf_nl_unregister(); +} +SYSUNINIT(pf_nl, SI_SUB_PROTO_FIREWALL, SI_ORDER_FOURTH, pf_nl_uninit, NULL); + static int pf_modevent(module_t mod, int type, void *data) { @@ -7228,7 +7246,6 @@ pf_modevent(module_t mod, int type, void *data) switch(type) { case MOD_LOAD: error = pf_load(); - pf_nl_register(); break; case MOD_UNLOAD: /* Handled in SYSUNINIT(pf_unload) to ensure it's done after