diff options
author | 2019-11-07 07:36:31 +0000 | |
---|---|---|
committer | 2019-11-07 07:36:31 +0000 | |
commit | 4f5e51a4e9a138283295ab8b7f236f90bf0f58ce (patch) | |
tree | e8f67f65e4d04bf88cb83ad12c28409ae28f84d8 /sys/net | |
parent | Add -F flag to send-keys to expand formats in search-backward and (diff) | |
download | wireguard-openbsd-4f5e51a4e9a138283295ab8b7f236f90bf0f58ce.tar.xz wireguard-openbsd-4f5e51a4e9a138283295ab8b7f236f90bf0f58ce.zip |
turn the linkstate hooks into a task list, like the detach hooks.
this is largely mechanical, except for carp. this moves the addition
of the carp link state hook after we're committed to using the new
interface as a carpdev. because the add can't fail, we avoid a
complicated unwind dance. also, this tweaks the carp linkstate hook
so it only updates the relevant carp interface, not all of the
carpdevs on the parent.
hrvoje popovski has tested an early version of this diff and it's
generally ok, but there's some splasserts that this diff fires that
i'll fix in an upcoming diff.
ok claudio@
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/bridgestp.c | 10 | ||||
-rw-r--r-- | sys/net/if.c | 31 | ||||
-rw-r--r-- | sys/net/if_aggr.c | 10 | ||||
-rw-r--r-- | sys/net/if_bpe.c | 10 | ||||
-rw-r--r-- | sys/net/if_bridge.h | 4 | ||||
-rw-r--r-- | sys/net/if_gre.c | 28 | ||||
-rw-r--r-- | sys/net/if_pfsync.c | 22 | ||||
-rw-r--r-- | sys/net/if_tpmr.c | 11 | ||||
-rw-r--r-- | sys/net/if_trunk.c | 8 | ||||
-rw-r--r-- | sys/net/if_trunk.h | 4 | ||||
-rw-r--r-- | sys/net/if_var.h | 6 | ||||
-rw-r--r-- | sys/net/if_vlan.c | 10 | ||||
-rw-r--r-- | sys/net/if_vxlan.c | 16 |
13 files changed, 79 insertions, 91 deletions
diff --git a/sys/net/bridgestp.c b/sys/net/bridgestp.c index 4147211d24d..be58ddd8e92 100644 --- a/sys/net/bridgestp.c +++ b/sys/net/bridgestp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bridgestp.c,v 1.72 2019/05/13 18:20:13 mpi Exp $ */ +/* $OpenBSD: bridgestp.c,v 1.73 2019/11/07 07:36:31 dlg Exp $ */ /* * Copyright (c) 2000 Jason L. Wright (jason@thought.net) @@ -1986,9 +1986,8 @@ bstp_add(struct bstp_state *bs, struct ifnet *ifp) bstp_update_roles(bs, bp); /* Register callback for physical link state changes */ - if (ifp->if_linkstatehooks != NULL) - bp->bp_lhcookie = hook_establish(ifp->if_linkstatehooks, 1, - bstp_ifstate, ifp); + task_set(&bp->bp_ltask, bstp_ifstate, ifp); + if_linkstatehook_add(ifp, &bp->bp_ltask); return (bp); } @@ -2002,8 +2001,7 @@ bstp_delete(struct bstp_port *bp) if (!bp->bp_active) panic("not a bstp member"); - if (ifp != NULL && ifp->if_linkstatehooks != NULL) - hook_disestablish(ifp->if_linkstatehooks, bp->bp_lhcookie); + if_linkstatehook_del(ifp, &bp->bp_ltask); LIST_REMOVE(bp, bp_next); free(bp, M_DEVBUF, sizeof *bp); diff --git a/sys/net/if.c b/sys/net/if.c index 0f3e07a53d8..0c96e305224 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.589 2019/11/06 03:51:26 dlg Exp $ */ +/* $OpenBSD: if.c,v 1.590 2019/11/07 07:36:31 dlg Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -629,9 +629,7 @@ if_attach_common(struct ifnet *ifp) ifp->if_addrhooks = malloc(sizeof(*ifp->if_addrhooks), M_TEMP, M_WAITOK); TAILQ_INIT(ifp->if_addrhooks); - ifp->if_linkstatehooks = malloc(sizeof(*ifp->if_linkstatehooks), - M_TEMP, M_WAITOK); - TAILQ_INIT(ifp->if_linkstatehooks); + TAILQ_INIT(&ifp->if_linkstatehooks); TAILQ_INIT(&ifp->if_detachhooks); if (ifp->if_rtrequest == NULL) @@ -1055,8 +1053,6 @@ if_deactivate(struct ifnet *ifp) NET_LOCK(); TAILQ_FOREACH_SAFE(t, &ifp->if_detachhooks, t_entry, nt) (*t->t_func)(t->t_arg); - - KASSERT(TAILQ_EMPTY(&ifp->if_detachhooks)); NET_UNLOCK(); } @@ -1148,7 +1144,8 @@ if_detach(struct ifnet *ifp) } free(ifp->if_addrhooks, M_TEMP, sizeof(*ifp->if_addrhooks)); - free(ifp->if_linkstatehooks, M_TEMP, sizeof(*ifp->if_linkstatehooks)); + KASSERT(TAILQ_EMPTY(&ifp->if_linkstatehooks)); + KASSERT(TAILQ_EMPTY(&ifp->if_detachhooks)); for (i = 0; (dp = domains[i]) != NULL; i++) { if (dp->dom_ifdetach && ifp->if_afdata[dp->dom_family]) @@ -1646,11 +1643,29 @@ if_linkstate_task(void *xifidx) void if_linkstate(struct ifnet *ifp) { + struct task *t, *nt; + NET_ASSERT_LOCKED(); rtm_ifchg(ifp); rt_if_track(ifp); - dohooks(ifp->if_linkstatehooks, 0); + + TAILQ_FOREACH_SAFE(t, &ifp->if_linkstatehooks, t_entry, nt) + (*t->t_func)(t->t_arg); +} + +void +if_linkstatehook_add(struct ifnet *ifp, struct task *t) +{ + NET_ASSERT_LOCKED(); + TAILQ_INSERT_TAIL(&ifp->if_linkstatehooks, t, t_entry); +} + +void +if_linkstatehook_del(struct ifnet *ifp, struct task *t) +{ + NET_ASSERT_LOCKED(); + TAILQ_REMOVE(&ifp->if_linkstatehooks, t, t_entry); } /* diff --git a/sys/net/if_aggr.c b/sys/net/if_aggr.c index b73ea41caac..3744abbe898 100644 --- a/sys/net/if_aggr.c +++ b/sys/net/if_aggr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_aggr.c,v 1.20 2019/11/06 03:51:26 dlg Exp $ */ +/* $OpenBSD: if_aggr.c,v 1.21 2019/11/07 07:36:31 dlg Exp $ */ /* * Copyright (c) 2019 The University of Queensland @@ -335,7 +335,7 @@ struct aggr_port { int (*p_output)(struct ifnet *, struct mbuf *, struct sockaddr *, struct rtentry *); - void *p_lcookie; + struct task p_lhook; struct task p_dhook; struct aggr_softc *p_aggr; @@ -1135,8 +1135,8 @@ aggr_add_port(struct aggr_softc *sc, const struct trunk_reqport *rp) } } - p->p_lcookie = hook_establish(ifp0->if_linkstatehooks, 1, - aggr_p_linkch, p); + task_set(&p->p_lhook, aggr_p_linkch, p); + if_linkstatehook_add(ifp0, &p->p_lhook); task_set(&p->p_dhook, aggr_p_detach, p); if_detachhook_add(ifp0, &p->p_dhook); @@ -1428,7 +1428,7 @@ aggr_p_dtor(struct aggr_softc *sc, struct aggr_port *p, const char *op) } if_detachhook_del(ifp0, &p->p_dhook); - hook_disestablish(ifp0->if_linkstatehooks, p->p_lcookie); + if_linkstatehook_del(ifp0, &p->p_lhook); if_put(ifp0); free(p, M_DEVBUF, sizeof(*p)); diff --git a/sys/net/if_bpe.c b/sys/net/if_bpe.c index 5ad9a41b684..b9a88be8efa 100644 --- a/sys/net/if_bpe.c +++ b/sys/net/if_bpe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bpe.c,v 1.9 2019/11/06 03:51:26 dlg Exp $ */ +/* $OpenBSD: if_bpe.c,v 1.10 2019/11/07 07:36:31 dlg Exp $ */ /* * Copyright (c) 2018 David Gwynne <dlg@openbsd.org> * @@ -102,7 +102,7 @@ struct bpe_softc { int sc_rxhprio; uint8_t sc_group[ETHER_ADDR_LEN]; - void * sc_lh_cookie; + struct task sc_ltask; struct task sc_dtask; struct bpe_map sc_bridge_map; @@ -174,6 +174,7 @@ bpe_clone_create(struct if_clone *ifc, int unit) sc->sc_txhprio = IF_HDRPRIO_PACKET; sc->sc_rxhprio = IF_HDRPRIO_OUTER; + task_set(&sc->sc_ltask, bpe_link_hook, sc); task_set(&sc->sc_dtask, bpe_detach_hook, sc); rw_init(&sc->sc_bridge_lock, "bpebr"); @@ -634,8 +635,7 @@ bpe_up(struct bpe_softc *sc) } /* Register callback for physical link state changes */ - sc->sc_lh_cookie = hook_establish(ifp0->if_linkstatehooks, 1, - bpe_link_hook, sc); + if_linkstatehook_add(ifp0, &sc->sc_ltask); /* Register callback if parent wants to unregister */ if_detachhook_add(ifp0, &sc->sc_dtask); @@ -676,7 +676,7 @@ bpe_down(struct bpe_softc *sc) ifp0 = if_get(sc->sc_key.k_if); if (ifp0 != NULL) { if_detachhook_del(ifp0, &sc->sc_dtask); - hook_disestablish(ifp0->if_linkstatehooks, sc->sc_lh_cookie); + if_linkstatehook_del(ifp0, &sc->sc_ltask); bpe_multi(sc, ifp0, SIOCDELMULTI); } if_put(ifp0); diff --git a/sys/net/if_bridge.h b/sys/net/if_bridge.h index 64393cf9ad2..3b0c5526647 100644 --- a/sys/net/if_bridge.h +++ b/sys/net/if_bridge.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bridge.h,v 1.66 2019/11/06 03:51:26 dlg Exp $ */ +/* $OpenBSD: if_bridge.h,v 1.67 2019/11/07 07:36:31 dlg Exp $ */ /* * Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net) @@ -331,7 +331,7 @@ struct bstp_port { LIST_ENTRY(bstp_port) bp_next; struct ifnet *bp_ifp; /* parent if */ struct bstp_state *bp_bs; - void *bp_lhcookie; /* if linkstate hook */ + struct task bp_ltask; /* if linkstate hook */ u_int8_t bp_active; u_int8_t bp_protover; u_int32_t bp_flags; diff --git a/sys/net/if_gre.c b/sys/net/if_gre.c index 3d95bae3ae3..3b436028742 100644 --- a/sys/net/if_gre.c +++ b/sys/net/if_gre.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_gre.c,v 1.153 2019/11/06 03:51:26 dlg Exp $ */ +/* $OpenBSD: if_gre.c,v 1.154 2019/11/07 07:36:31 dlg Exp $ */ /* $NetBSD: if_gre.c,v 1.9 1999/10/25 19:18:11 drochner Exp $ */ /* @@ -429,7 +429,7 @@ struct nvgre_softc { struct task sc_send_task; void *sc_inm; - void *sc_lhcookie; + struct task sc_ltask; struct task sc_dtask; struct rwlock sc_ether_lock; @@ -792,6 +792,7 @@ nvgre_clone_create(struct if_clone *ifc, int unit) mq_init(&sc->sc_send_list, IFQ_MAXLEN * 2, IPL_SOFTNET); task_set(&sc->sc_send_task, nvgre_send, sc); + task_set(&sc->sc_ltask, nvgre_link_change, sc); task_set(&sc->sc_dtask, nvgre_detach, sc); rw_init(&sc->sc_ether_lock, "nvgrelk"); @@ -3657,13 +3658,7 @@ nvgre_up(struct nvgre_softc *sc) unhandled_af(tunnel->t_af); } - sc->sc_lhcookie = hook_establish(ifp0->if_linkstatehooks, 0, - nvgre_link_change, sc); - if (sc->sc_lhcookie == NULL) { - error = ENOMEM; - goto delmulti; - } - + if_linkstatehook_add(ifp0, &sc->sc_ltask); if_detachhook_add(ifp0, &sc->sc_dtask); if_put(ifp0); @@ -3675,19 +3670,6 @@ nvgre_up(struct nvgre_softc *sc) return (0); -delmulti: - switch (tunnel->t_af) { - case AF_INET: - in_delmulti(inm); - break; -#ifdef INET6 - case AF_INET6: - in6_delmulti(inm); - break; -#endif - default: - unhandled_af(tunnel->t_af); - } remove_ucast: RBT_REMOVE(nvgre_ucast_tree, &nvgre_ucast_tree, sc); remove_mcast: @@ -3721,7 +3703,7 @@ nvgre_down(struct nvgre_softc *sc) ifp0 = if_get(sc->sc_ifp0); if (ifp0 != NULL) { if_detachhook_del(ifp0, &sc->sc_dtask); - hook_disestablish(ifp0->if_linkstatehooks, sc->sc_lhcookie); + if_linkstatehook_del(ifp0, &sc->sc_ltask); } if_put(ifp0); diff --git a/sys/net/if_pfsync.c b/sys/net/if_pfsync.c index 3bc01451c5e..8e7f12a05de 100644 --- a/sys/net/if_pfsync.c +++ b/sys/net/if_pfsync.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_pfsync.c,v 1.265 2019/11/06 03:51:26 dlg Exp $ */ +/* $OpenBSD: if_pfsync.c,v 1.266 2019/11/07 07:36:31 dlg Exp $ */ /* * Copyright (c) 2002 Michael Shalayeff @@ -235,7 +235,7 @@ struct pfsync_softc { TAILQ_HEAD(, tdb) sc_tdb_q; - void *sc_lhcookie; + struct task sc_ltask; struct task sc_dtask; struct timeout sc_tmo; @@ -321,6 +321,7 @@ pfsync_clone_create(struct if_clone *ifc, int unit) NULL); TAILQ_INIT(&sc->sc_upd_req_list); TAILQ_INIT(&sc->sc_deferrals); + task_set(&sc->sc_ltask, pfsync_syncdev_state, sc); task_set(&sc->sc_dtask, pfsync_ifdetach, sc); sc->sc_deferred = 0; @@ -379,9 +380,7 @@ pfsync_clone_destroy(struct ifnet *ifp) carp_group_demote_adj(&sc->sc_if, -1, "pfsync destroy"); #endif if (sc->sc_sync_if) { - hook_disestablish( - sc->sc_sync_if->if_linkstatehooks, - sc->sc_lhcookie); + if_linkstatehook_del(sc->sc_sync_if, &sc->sc_ltask); if_detachhook_del(sc->sc_sync_if, &sc->sc_dtask); } @@ -1347,9 +1346,8 @@ pfsyncioctl(struct ifnet *ifp, u_long cmd, caddr_t data) if (pfsyncr.pfsyncr_syncdev[0] == 0) { if (sc->sc_sync_if) { - hook_disestablish( - sc->sc_sync_if->if_linkstatehooks, - sc->sc_lhcookie); + if_linkstatehook_del(sc->sc_sync_if, + &sc->sc_ltask); if_detachhook_del(sc->sc_sync_if, &sc->sc_dtask); } @@ -1372,9 +1370,7 @@ pfsyncioctl(struct ifnet *ifp, u_long cmd, caddr_t data) pfsync_sendout(); if (sc->sc_sync_if) { - hook_disestablish( - sc->sc_sync_if->if_linkstatehooks, - sc->sc_lhcookie); + if_linkstatehook_del(sc->sc_sync_if, &sc->sc_ltask); if_detachhook_del(sc->sc_sync_if, &sc->sc_dtask); } sc->sc_sync_if = sifp; @@ -1418,9 +1414,7 @@ pfsyncioctl(struct ifnet *ifp, u_long cmd, caddr_t data) ip->ip_src.s_addr = INADDR_ANY; ip->ip_dst.s_addr = sc->sc_sync_peer.s_addr; - sc->sc_lhcookie = - hook_establish(sc->sc_sync_if->if_linkstatehooks, 1, - pfsync_syncdev_state, sc); + if_linkstatehook_add(sc->sc_sync_if, &sc->sc_ltask); if_detachhook_add(sc->sc_sync_if, &sc->sc_dtask); pfsync_request_full_update(sc); diff --git a/sys/net/if_tpmr.c b/sys/net/if_tpmr.c index 231e2e1968b..67c90aeb15b 100644 --- a/sys/net/if_tpmr.c +++ b/sys/net/if_tpmr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_tpmr.c,v 1.5 2019/11/06 03:51:26 dlg Exp $ */ +/* $OpenBSD: if_tpmr.c,v 1.6 2019/11/07 07:36:32 dlg Exp $ */ /* * Copyright (c) 2019 The University of Queensland @@ -86,7 +86,7 @@ struct tpmr_port { int (*p_output)(struct ifnet *, struct mbuf *, struct sockaddr *, struct rtentry *); - void *p_lcookie; + struct task p_ltask; struct task p_dtask; struct tpmr_softc *p_tpmr; @@ -563,8 +563,9 @@ tpmr_add_port(struct tpmr_softc *sc, const struct trunk_reqport *rp) if (error != 0) goto free; - p->p_lcookie = hook_establish(ifp0->if_linkstatehooks, 1, - tpmr_p_linkch, p); + task_set(&p->p_ltask, tpmr_p_linkch, p); + if_linkstatehook_add(ifp0, &p->p_ltask); + task_set(&p->p_dtask, tpmr_p_detach, p); if_detachhook_add(ifp0, &p->p_dtask); @@ -725,7 +726,7 @@ tpmr_p_dtor(struct tpmr_softc *sc, struct tpmr_port *p, const char *op) } if_detachhook_del(ifp0, &p->p_dtask); - hook_disestablish(ifp0->if_linkstatehooks, p->p_lcookie); + if_linkstatehook_del(ifp0, &p->p_ltask); smr_barrier(); diff --git a/sys/net/if_trunk.c b/sys/net/if_trunk.c index 546ba1a8385..1c0784f6a2c 100644 --- a/sys/net/if_trunk.c +++ b/sys/net/if_trunk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_trunk.c,v 1.142 2019/11/06 03:51:26 dlg Exp $ */ +/* $OpenBSD: if_trunk.c,v 1.143 2019/11/07 07:36:32 dlg Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Reyk Floeter <reyk@openbsd.org> @@ -372,8 +372,8 @@ trunk_port_create(struct trunk_softc *tr, struct ifnet *ifp) trunk_ether_cmdmulti(tp, SIOCADDMULTI); /* Register callback for physical link state changes */ - tp->lh_cookie = hook_establish(ifp->if_linkstatehooks, 1, - trunk_port_state, tp); + task_set(&tp->tp_ltask, trunk_port_state, tp); + if_linkstatehook_add(ifp, &tp->tp_ltask); /* Register callback if parent wants to unregister */ task_set(&tp->tp_dtask, trunk_port_ifdetach, tp); @@ -436,8 +436,8 @@ trunk_port_destroy(struct trunk_port *tp) ifp->if_ioctl = tp->tp_ioctl; ifp->if_output = tp->tp_output; - hook_disestablish(ifp->if_linkstatehooks, tp->lh_cookie); if_detachhook_del(ifp, &tp->tp_dtask); + if_linkstatehook_del(ifp, &tp->tp_ltask); /* Finally, remove the port from the trunk */ SLIST_REMOVE(&tr->tr_ports, tp, trunk_port, tp_entries); diff --git a/sys/net/if_trunk.h b/sys/net/if_trunk.h index 28f93d7a196..849f295a432 100644 --- a/sys/net/if_trunk.h +++ b/sys/net/if_trunk.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_trunk.h,v 1.28 2019/11/06 03:51:26 dlg Exp $ */ +/* $OpenBSD: if_trunk.h,v 1.29 2019/11/07 07:36:32 dlg Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Reyk Floeter <reyk@openbsd.org> @@ -165,7 +165,7 @@ struct trunk_port { u_char tp_iftype; /* interface type */ u_int32_t tp_prio; /* port priority */ u_int32_t tp_flags; /* port flags */ - void *lh_cookie; /* if state hook */ + struct task tp_ltask; /* if state hook */ struct task tp_dtask; /* if detach hook */ /* Redirected callbacks */ diff --git a/sys/net/if_var.h b/sys/net/if_var.h index deb09ad44da..3787fc54e6d 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_var.h,v 1.101 2019/11/06 03:51:26 dlg Exp $ */ +/* $OpenBSD: if_var.h,v 1.102 2019/11/07 07:36:32 dlg Exp $ */ /* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */ /* @@ -125,7 +125,7 @@ struct ifnet { /* and the entries */ TAILQ_HEAD(, ifmaddr) if_maddrlist; /* [N] list of multicast records */ TAILQ_HEAD(, ifg_list) if_groups; /* [N] list of groups per if */ struct hook_desc_head *if_addrhooks; /* [I] address change callbacks */ - struct hook_desc_head *if_linkstatehooks; /* [I] link change callbacks*/ + struct task_list if_linkstatehooks; /* [I] link change callbacks*/ struct task_list if_detachhooks; /* [I] detach callbacks */ /* [I] check or clean routes (+ or -)'d */ void (*if_rtrequest)(struct ifnet *, int, struct rtentry *); @@ -376,6 +376,8 @@ void if_ih_remove(struct ifnet *, int (*)(struct ifnet *, struct mbuf *, void if_detachhook_add(struct ifnet *, struct task *); void if_detachhook_del(struct ifnet *, struct task *); +void if_linkstatehook_add(struct ifnet *, struct task *); +void if_linkstatehook_del(struct ifnet *, struct task *); void if_rxr_livelocked(struct if_rxring *); void if_rxr_init(struct if_rxring *, u_int, u_int); diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c index 441a14ce304..a7905a4a099 100644 --- a/sys/net/if_vlan.c +++ b/sys/net/if_vlan.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vlan.c,v 1.201 2019/11/06 03:51:26 dlg Exp $ */ +/* $OpenBSD: if_vlan.c,v 1.202 2019/11/07 07:36:32 dlg Exp $ */ /* * Copyright 1998 Massachusetts Institute of Technology @@ -97,7 +97,7 @@ struct vlan_softc { SRPL_ENTRY(vlan_softc) sc_list; int sc_flags; struct refcnt sc_refcnt; - void *sc_lh_cookie; + struct task sc_ltask; struct task sc_dtask; struct ifih *sc_ifih; }; @@ -192,6 +192,7 @@ vlan_clone_create(struct if_clone *ifc, int unit) sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK|M_ZERO); sc->sc_dead = 0; LIST_INIT(&sc->sc_mc_listhead); + task_set(&sc->sc_ltask, vlan_link_hook, sc); task_set(&sc->sc_dtask, vlan_ifdetach, sc); ifp = &sc->sc_if; ifp->if_softc = sc; @@ -534,8 +535,7 @@ vlan_up(struct vlan_softc *sc) rw_exit(&vlan_tagh_lk); /* Register callback for physical link state changes */ - sc->sc_lh_cookie = hook_establish(ifp0->if_linkstatehooks, 1, - vlan_link_hook, sc); + if_linkstatehook_add(ifp0, &sc->sc_ltask); /* Register callback if parent wants to unregister */ if_detachhook_add(ifp0, &sc->sc_dtask); @@ -592,7 +592,7 @@ vlan_down(struct vlan_softc *sc) ifpromisc(ifp0, 0); vlan_multi_apply(sc, ifp0, SIOCDELMULTI); if_detachhook_del(ifp0, &sc->sc_dtask); - hook_disestablish(ifp0->if_linkstatehooks, sc->sc_lh_cookie); + if_linkstatehook_del(ifp0, &sc->sc_ltask); } if_put(ifp0); diff --git a/sys/net/if_vxlan.c b/sys/net/if_vxlan.c index a8838538305..1c4899315ee 100644 --- a/sys/net/if_vxlan.c +++ b/sys/net/if_vxlan.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vxlan.c,v 1.74 2019/11/06 03:51:26 dlg Exp $ */ +/* $OpenBSD: if_vxlan.c,v 1.75 2019/11/07 07:36:32 dlg Exp $ */ /* * Copyright (c) 2013 Reyk Floeter <reyk@openbsd.org> @@ -63,7 +63,7 @@ struct vxlan_softc { struct ip_moptions sc_imo; void *sc_ahcookie; - void *sc_lhcookie; + struct task sc_ltask; struct task sc_dtask; struct sockaddr_storage sc_src; @@ -138,6 +138,7 @@ vxlan_clone_create(struct if_clone *ifc, int unit) sc->sc_vnetid = VXLAN_VNI_UNSET; sc->sc_txhprio = IFQ_TOS2PRIO(IPTOS_PREC_ROUTINE); /* 0 */ sc->sc_df = htons(0); + task_set(&sc->sc_ltask, vxlan_link_change, sc); task_set(&sc->sc_dtask, vxlan_if_change, sc); task_set(&sc->sc_sendtask, vxlan_send_dispatch, sc); @@ -219,11 +220,7 @@ vxlan_multicast_cleanup(struct ifnet *ifp) hook_disestablish(mifp->if_addrhooks, sc->sc_ahcookie); sc->sc_ahcookie = NULL; } - if (sc->sc_lhcookie != NULL) { - hook_disestablish(mifp->if_linkstatehooks, - sc->sc_lhcookie); - sc->sc_lhcookie = NULL; - } + if_linkstatehook_del(mifp, &sc->sc_ltask); if_detachhook_del(mifp, &sc->sc_dtask); if_put(mifp); @@ -294,11 +291,10 @@ vxlan_multicast_join(struct ifnet *ifp, struct sockaddr *src, * Use interface hooks to track any changes on the interface * that is used to send out the tunnel traffic as multicast. */ + if_linkstatehook_add(mifp, &sc->sc_ltask); if_detachhook_add(mifp, &sc->sc_dtask); if ((sc->sc_ahcookie = hook_establish(mifp->if_addrhooks, - 0, vxlan_addr_change, sc)) == NULL || - (sc->sc_lhcookie = hook_establish(mifp->if_linkstatehooks, - 0, vxlan_link_change, sc)) == NULL) + 0, vxlan_addr_change, sc)) == NULL) panic("%s: cannot allocate interface hook", mifp->if_xname); |