aboutsummaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorAndrew Thompson <thompsa@FreeBSD.org>2007-08-24 10:34:30 +0000
committerAndrew Thompson <thompsa@FreeBSD.org>2007-08-24 10:34:30 +0000
commit30548df03b4b9bc5594dbf133d301fb4f4427494 (patch)
treed81642108b27c7be37b981bea5edcb897135076d /sys/net
parent794bd8b8429935a508169dd59e2c3bb56cc71f1a (diff)
Notes
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/bridgestp.c49
-rw-r--r--sys/net/bridgestp.h1
2 files changed, 42 insertions, 8 deletions
diff --git a/sys/net/bridgestp.c b/sys/net/bridgestp.c
index 1ae8093e49e0..db948fdd4b21 100644
--- a/sys/net/bridgestp.c
+++ b/sys/net/bridgestp.c
@@ -1331,6 +1331,9 @@ bstp_set_port_proto(struct bstp_port *bp, int proto)
bstp_timer_stop(&bp->bp_migrate_delay_timer);
/* clear unsupported features */
bp->bp_operedge = 0;
+ /* STP compat mode only uses 16 bits of the 32 */
+ if (bp->bp_path_cost > 65535)
+ bp->bp_path_cost = 65535;
break;
case BSTP_PROTO_RSTP:
@@ -1617,6 +1620,10 @@ bstp_set_path_cost(struct bstp_port *bp, uint32_t path_cost)
if (path_cost > BSTP_MAX_PATH_COST)
return (EINVAL);
+ /* STP compat mode only uses 16 bits of the 32 */
+ if (bp->bp_protover == BSTP_PROTO_STP && path_cost > 65535)
+ path_cost = 65535;
+
BSTP_LOCK(bs);
if (path_cost == 0) { /* use auto */
@@ -1681,7 +1688,8 @@ bstp_set_autoptp(struct bstp_port *bp, int set)
BSTP_LOCK(bs);
if (set) {
bp->bp_flags |= BSTP_PORT_AUTOPTP;
- bstp_ifupdstatus(bs, bp);
+ if (bp->bp_role != BSTP_ROLE_DISABLED)
+ bstp_ifupdstatus(bs, bp);
} else
bp->bp_flags &= ~BSTP_PORT_AUTOPTP;
BSTP_UNLOCK(bs);
@@ -1701,6 +1709,12 @@ bstp_calc_path_cost(struct bstp_port *bp)
if (bp->bp_flags & BSTP_PORT_ADMCOST)
return bp->bp_path_cost;
+ if (ifp->if_link_state == LINK_STATE_DOWN) {
+ /* Recalc when the link comes up again */
+ bp->bp_flags |= BSTP_PORT_PNDCOST;
+ return (BSTP_DEFAULT_PATH_COST);
+ }
+
if (ifp->if_baudrate < 1000)
return (BSTP_DEFAULT_PATH_COST);
@@ -1809,6 +1823,12 @@ bstp_ifupdstatus(struct bstp_state *bs, struct bstp_port *bp)
ifmr.ifm_active & IFM_FDX ? 1 : 0;
}
+ /* Calc the cost if the link was down previously */
+ if (bp->bp_flags & BSTP_PORT_PNDCOST) {
+ bp->bp_path_cost = bstp_calc_path_cost(bp);
+ bp->bp_flags &= ~BSTP_PORT_PNDCOST;
+ }
+
if (bp->bp_role == BSTP_ROLE_DISABLED)
bstp_enable_port(bs, bp);
} else {
@@ -1999,27 +2019,25 @@ bstp_reinit(struct bstp_state *bs)
struct bstp_port *bp;
struct ifnet *ifp, *mif;
u_char *e_addr;
+ static const u_char llzero[ETHER_ADDR_LEN]; /* 00:00:00:00:00:00 */
BSTP_LOCK_ASSERT(bs);
- if (LIST_EMPTY(&bs->bs_bplist)) {
- callout_stop(&bs->bs_bstpcallout);
- return;
- }
-
mif = NULL;
/*
* Search through the Ethernet adapters and find the one with the
* lowest value. The adapter which we take the MAC address from does
* not need to be part of the bridge, it just needs to be a unique
- * value. It is not possible for mif to be null, at this point we have
- * at least one stp port and hence at least one NIC.
+ * value.
*/
IFNET_RLOCK();
TAILQ_FOREACH(ifp, &ifnet, if_link) {
if (ifp->if_type != IFT_ETHER)
continue;
+ if (bstp_addr_cmp(IF_LLADDR(ifp), llzero) == 0)
+ continue;
+
if (mif == NULL) {
mif = ifp;
continue;
@@ -2031,6 +2049,21 @@ bstp_reinit(struct bstp_state *bs)
}
IFNET_RUNLOCK();
+ if (LIST_EMPTY(&bs->bs_bplist) || mif == NULL) {
+ /* Set the bridge and root id (lower bits) to zero */
+ bs->bs_bridge_pv.pv_dbridge_id =
+ ((uint64_t)bs->bs_bridge_priority) << 48;
+ bs->bs_bridge_pv.pv_root_id = bs->bs_bridge_pv.pv_dbridge_id;
+ bs->bs_root_pv = bs->bs_bridge_pv;
+ /* Disable any remaining ports, they will have no MAC address */
+ LIST_FOREACH(bp, &bs->bs_bplist, bp_next) {
+ bp->bp_infois = BSTP_INFO_DISABLED;
+ bstp_set_port_role(bp, BSTP_ROLE_DISABLED);
+ }
+ callout_stop(&bs->bs_bstpcallout);
+ return;
+ }
+
e_addr = IF_LLADDR(mif);
bs->bs_bridge_pv.pv_dbridge_id =
(((uint64_t)bs->bs_bridge_priority) << 48) |
diff --git a/sys/net/bridgestp.h b/sys/net/bridgestp.h
index 0f003118af98..d320b6596720 100644
--- a/sys/net/bridgestp.h
+++ b/sys/net/bridgestp.h
@@ -110,6 +110,7 @@
#define BSTP_PORT_AUTOEDGE 0x0010
#define BSTP_PORT_AUTOPTP 0x0020
#define BSTP_PORT_ADMEDGE 0x0040
+#define BSTP_PORT_PNDCOST 0x0080
/* BPDU priority */
#define BSTP_PDU_SUPERIOR 1