diff options
author | Rafael Zalamena <rzalamena@cvs.openbsd.org> | 2016-10-03 12:26:14 +0000 |
---|---|---|
committer | Rafael Zalamena <rzalamena@cvs.openbsd.org> | 2016-10-03 12:26:14 +0000 |
commit | 77ba510b67f525bc2922ee3eb2b5df6b0eb4c199 (patch) | |
tree | a366fc52dd93fea292bedd6f9ab30c00a2c2dd88 /sys/net | |
parent | cbda7d0477b65b13bd552d7933d41ffead82f63a (diff) |
Use detach hook to notify bridge of interface removal instead of adding
code to if.c.
ok mpi@
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/if.c | 8 | ||||
-rw-r--r-- | sys/net/if_bridge.c | 9 | ||||
-rw-r--r-- | sys/net/if_bridge.h | 4 |
3 files changed, 10 insertions, 11 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index 5abe7516a51..af73a2ab106 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.451 2016/09/28 08:31:42 rzalamena Exp $ */ +/* $OpenBSD: if.c,v 1.452 2016/10/03 12:26:13 rzalamena Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -895,12 +895,6 @@ if_deactivate(struct ifnet *ifp) */ dohooks(ifp->if_detachhooks, HOOK_REMOVE | HOOK_FREE); -#if NBRIDGE > 0 - /* Remove the interface from any bridge it is part of. */ - if (ifp->if_bridgeport) - bridge_ifdetach(ifp); -#endif - #if NSWITCH > 0 if (ifp->if_switchport) switch_port_detach(ifp); diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c index 2e9135b1325..ee725ca8ad6 100644 --- a/sys/net/if_bridge.c +++ b/sys/net/if_bridge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bridge.c,v 1.285 2016/09/29 11:37:44 reyk Exp $ */ +/* $OpenBSD: if_bridge.c,v 1.286 2016/10/03 12:26:13 rzalamena Exp $ */ /* * Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net) @@ -106,6 +106,7 @@ void bridgeattach(int); int bridge_ioctl(struct ifnet *, u_long, caddr_t); +void bridge_ifdetach(void *); int bridge_input(struct ifnet *, struct mbuf *, void *); void bridge_process(struct ifnet *, struct mbuf *); void bridgeintr_frame(struct bridge_softc *, struct ifnet *, struct mbuf *); @@ -244,6 +245,7 @@ bridge_delete(struct bridge_softc *sc, struct bridge_iflist *p) p->ifp->if_bridgeport = NULL; error = ifpromisc(p->ifp, 0); + hook_disestablish(p->ifp->if_detachhooks, p->bif_dhcookie); if_ih_remove(p->ifp, bridge_input, NULL); TAILQ_REMOVE(&sc->sc_iflist, p, next); @@ -356,6 +358,8 @@ bridge_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) SIMPLEQ_INIT(&p->bif_brlin); SIMPLEQ_INIT(&p->bif_brlout); ifs->if_bridgeport = (caddr_t)p; + p->bif_dhcookie = hook_establish(ifs->if_detachhooks, 0, + bridge_ifdetach, ifs); if_ih_insert(p->ifp, bridge_input, NULL); TAILQ_INSERT_TAIL(&sc->sc_iflist, p, next); break; @@ -567,8 +571,9 @@ bridge_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) /* Detach an interface from a bridge. */ void -bridge_ifdetach(struct ifnet *ifp) +bridge_ifdetach(void *arg) { + struct ifnet *ifp = (struct ifnet *)arg; struct bridge_softc *sc; struct bridge_iflist *bif; diff --git a/sys/net/if_bridge.h b/sys/net/if_bridge.h index 09143db50cd..608874034a4 100644 --- a/sys/net/if_bridge.h +++ b/sys/net/if_bridge.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bridge.h,v 1.52 2016/09/29 11:37:44 reyk Exp $ */ +/* $OpenBSD: if_bridge.h,v 1.53 2016/10/03 12:26:13 rzalamena Exp $ */ /* * Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net) @@ -398,6 +398,7 @@ struct bridge_iflist { struct brl_head bif_brlout; /* output rules */ struct ifnet *ifp; /* member interface */ u_int32_t bif_flags; /* member flags */ + void *bif_dhcookie; }; #define bif_state bif_stp->bp_state @@ -450,7 +451,6 @@ struct bridge_softc { extern const u_int8_t bstp_etheraddr[]; struct llc; -void bridge_ifdetach(struct ifnet *); int bridge_output(struct ifnet *, struct mbuf *, struct sockaddr *, struct rtentry *); void bridge_update(struct ifnet *, struct ether_addr *, int); |