diff options
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/bridgestp.c | 41 | ||||
-rw-r--r-- | sys/net/bridgestp.h | 7 | ||||
-rw-r--r-- | sys/net/if_bridge.c | 10 |
3 files changed, 33 insertions, 25 deletions
diff --git a/sys/net/bridgestp.c b/sys/net/bridgestp.c index 0264784..3549fce 100644 --- a/sys/net/bridgestp.c +++ b/sys/net/bridgestp.c @@ -2114,39 +2114,46 @@ bstp_stop(struct bstp_state *bs) } int -bstp_add(struct bstp_state *bs, struct bstp_port *bp, struct ifnet *ifp) +bstp_create(struct bstp_state *bs, struct bstp_port *bp, struct ifnet *ifp) { - KASSERT(bp->bp_active == 0, ("already a bstp member")); - - switch (ifp->if_type) { - case IFT_ETHER: /* These can do spanning tree. */ - break; - default: - /* Nothing else can. */ - return (EINVAL); - } - bzero(bp, sizeof(struct bstp_port)); BSTP_LOCK(bs); bp->bp_ifp = ifp; bp->bp_bs = bs; bp->bp_priority = BSTP_DEFAULT_PORT_PRIORITY; - bp->bp_txcount = 0; TASK_INIT(&bp->bp_statetask, 0, bstp_notify_state, bp); TASK_INIT(&bp->bp_rtagetask, 0, bstp_notify_rtage, bp); /* Init state */ - bp->bp_infois = BSTP_INFO_DISABLED; bp->bp_flags = BSTP_PORT_AUTOEDGE; bstp_set_port_state(bp, BSTP_IFSTATE_DISCARDING); bstp_set_port_proto(bp, bs->bs_protover); bstp_set_port_role(bp, BSTP_ROLE_DISABLED); bstp_set_port_tc(bp, BSTP_TCSTATE_INACTIVE); bp->bp_path_cost = bstp_calc_path_cost(bp); + BSTP_UNLOCK(bs); + return (0); +} - LIST_INSERT_HEAD(&bs->bs_bplist, bp, bp_next); +int +bstp_enable(struct bstp_port *bp) +{ + struct bstp_state *bs = bp->bp_bs; + struct ifnet *ifp = bp->bp_ifp; + + KASSERT(bp->bp_active == 0, ("already a bstp member")); + switch (ifp->if_type) { + case IFT_ETHER: /* These can do spanning tree. */ + break; + default: + /* Nothing else can. */ + return (EINVAL); + } + + BSTP_LOCK(bs); + LIST_INSERT_HEAD(&bs->bs_bplist, bp, bp_next); bp->bp_active = 1; bp->bp_flags |= BSTP_PORT_NEWINFO; bstp_reinit(bs); @@ -2156,15 +2163,15 @@ bstp_add(struct bstp_state *bs, struct bstp_port *bp, struct ifnet *ifp) } void -bstp_delete(struct bstp_port *bp) +bstp_disable(struct bstp_port *bp) { struct bstp_state *bs = bp->bp_bs; KASSERT(bp->bp_active == 1, ("not a bstp member")); BSTP_LOCK(bs); + bstp_disable_port(bs, bp); LIST_REMOVE(bp, bp_next); - bp->bp_bs = NULL; bp->bp_active = 0; bstp_reinit(bs); BSTP_UNLOCK(bs); @@ -2174,7 +2181,7 @@ bstp_delete(struct bstp_port *bp) * The bstp_port structure is about to be freed by the parent bridge. */ void -bstp_drain(struct bstp_port *bp) +bstp_destroy(struct bstp_port *bp) { KASSERT(bp->bp_active == 0, ("port is still attached")); taskqueue_drain(taskqueue_swi, &bp->bp_statetask); diff --git a/sys/net/bridgestp.h b/sys/net/bridgestp.h index 20c1eff..8e09cf9 100644 --- a/sys/net/bridgestp.h +++ b/sys/net/bridgestp.h @@ -367,9 +367,10 @@ void bstp_attach(struct bstp_state *, bstp_state_cb_t, bstp_rtage_cb_t); void bstp_detach(struct bstp_state *); void bstp_init(struct bstp_state *); void bstp_stop(struct bstp_state *); -int bstp_add(struct bstp_state *, struct bstp_port *, struct ifnet *); -void bstp_delete(struct bstp_port *); -void bstp_drain(struct bstp_port *); +int bstp_create(struct bstp_state *, struct bstp_port *, struct ifnet *); +int bstp_enable(struct bstp_port *); +void bstp_disable(struct bstp_port *); +void bstp_destroy(struct bstp_port *); void bstp_linkstate(struct ifnet *, int); int bstp_set_htime(struct bstp_state *, int); int bstp_set_fdelay(struct bstp_state *, int); diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c index edf3831..068ade7 100644 --- a/sys/net/if_bridge.c +++ b/sys/net/if_bridge.c @@ -875,7 +875,7 @@ bridge_delete_member(struct bridge_softc *sc, struct bridge_iflist *bif, } if (bif->bif_flags & IFBIF_STP) - bstp_delete(&bif->bif_stp); + bstp_disable(&bif->bif_stp); ifs->if_bridge = NULL; BRIDGE_XLOCK(sc); @@ -885,7 +885,7 @@ bridge_delete_member(struct bridge_softc *sc, struct bridge_iflist *bif, bridge_rtdelete(sc, ifs, IFBF_FLUSHALL); BRIDGE_UNLOCK(sc); - bstp_drain(&bif->bif_stp); /* prepare to free */ + bstp_destroy(&bif->bif_stp); /* prepare to free */ BRIDGE_LOCK(sc); free(bif, M_DEVBUF); } @@ -970,6 +970,7 @@ bridge_ioctl_add(struct bridge_softc *sc, void *arg) } ifs->if_bridge = sc; + bstp_create(&sc->sc_stp, &bif->bif_stp, bif->bif_ifp); /* * XXX: XLOCK HERE!?! * @@ -1044,14 +1045,13 @@ bridge_ioctl_sifflags(struct bridge_softc *sc, void *arg) if (req->ifbr_ifsflags & IFBIF_STP) { if ((bif->bif_flags & IFBIF_STP) == 0) { - error = bstp_add(&sc->sc_stp, &bif->bif_stp, - bif->bif_ifp); + error = bstp_enable(&bif->bif_stp); if (error) return (error); } } else { if ((bif->bif_flags & IFBIF_STP) != 0) - bstp_delete(&bif->bif_stp); + bstp_disable(&bif->bif_stp); } bif->bif_flags = req->ifbr_ifsflags; |