diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2019-11-08 07:16:30 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2019-11-08 07:16:30 +0000 |
commit | cc9483a80803855ffa3376b13ebbd8b6e388cee1 (patch) | |
tree | 837221515cc522324b695dbd52708970926136b6 /sys/net/pf_if.c | |
parent | 49a5ca10756fe16735beacb0938189fe6b04b0e6 (diff) |
convert interface address change hooks to tasks and a task_list.
this follows what's been done for detach and link state hooks, and
makes handling of hooks generally more robust.
address hooks are a bit different to detach/link state hooks in
that there's only a few things that register hooks (carp, pf, vxlan),
but a lot of places to run the hooks (lots of ipv4 and ipv6 address
configuration).
an address hook cookie was in struct pfi_kif, which is part of the
pf abi. rather than break pfctl -sI, this maintains the void * used
for the cookie and uses it to store a task, which is then used as
intended with the new api.
Diffstat (limited to 'sys/net/pf_if.c')
-rw-r--r-- | sys/net/pf_if.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/sys/net/pf_if.c b/sys/net/pf_if.c index 00684f80093..ba7cff1932a 100644 --- a/sys/net/pf_if.c +++ b/sys/net/pf_if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pf_if.c,v 1.97 2019/07/09 11:30:19 yasuoka Exp $ */ +/* $OpenBSD: pf_if.c,v 1.98 2019/11/08 07:16:29 dlg Exp $ */ /* * Copyright 2005 Henning Brauer <henning@openbsd.org> @@ -235,6 +235,7 @@ void pfi_attach_ifnet(struct ifnet *ifp) { struct pfi_kif *kif; + struct task *t; pfi_initialize(); pfi_update++; @@ -244,10 +245,10 @@ pfi_attach_ifnet(struct ifnet *ifp) kif->pfik_ifp = ifp; ifp->if_pf_kif = (caddr_t)kif; - if ((kif->pfik_ah_cookie = hook_establish(ifp->if_addrhooks, 1, - pfi_kifaddr_update, kif)) == NULL) - panic("pfi_attach_ifnet: cannot allocate '%s' address hook", - ifp->if_xname); + t = malloc(sizeof(*t), PFI_MTYPE, M_WAITOK); + task_set(t, pfi_kifaddr_update, kif); + if_addrhook_add(ifp, t); + kif->pfik_ah_cookie = t; pfi_kif_update(kif); } @@ -256,12 +257,14 @@ void pfi_detach_ifnet(struct ifnet *ifp) { struct pfi_kif *kif; + struct task *t; if ((kif = (struct pfi_kif *)ifp->if_pf_kif) == NULL) return; pfi_update++; - hook_disestablish(ifp->if_addrhooks, kif->pfik_ah_cookie); + t = kif->pfik_ah_cookie; + if_addrhook_del(ifp, t); pfi_kif_update(kif); kif->pfik_ifp = NULL; |