diff options
author | thompsa <thompsa@FreeBSD.org> | 2006-11-26 18:43:48 +0000 |
---|---|---|
committer | thompsa <thompsa@FreeBSD.org> | 2006-11-26 18:43:48 +0000 |
commit | 8f2b5bd800be4781a09beff0785b6de9f437d176 (patch) | |
tree | 830196d4f4c7ae5711bcf53cc4a89909662fc904 /sys/net/bridgestp.c | |
parent | 48f2c3ea925ca18fa73b6355af0e6d31b2251e76 (diff) | |
download | FreeBSD-src-8f2b5bd800be4781a09beff0785b6de9f437d176.zip FreeBSD-src-8f2b5bd800be4781a09beff0785b6de9f437d176.tar.gz |
use two stage creation of stp ports, this means that the stp variables can be
set before the port is marked STP and they will no longer be overwrittten
Diffstat (limited to 'sys/net/bridgestp.c')
-rw-r--r-- | sys/net/bridgestp.c | 41 |
1 files changed, 24 insertions, 17 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); |