View | Details | Raw Unified | Return to bug 164369 | Differences between
and this patch

Collapse All | Expand All

(-)bridgestp.c (-20 / +30 lines)
Lines 2012-2035 bstp_reinit(struct bstp_state *bs) Link Here
2012
	struct bstp_port *bp;
2012
	struct bstp_port *bp;
2013
	struct ifnet *ifp, *mif;
2013
	struct ifnet *ifp, *mif;
2014
	u_char *e_addr;
2014
	u_char *e_addr;
2015
	void *bridgeptr;
2015
	static const u_char llzero[ETHER_ADDR_LEN];	/* 00:00:00:00:00:00 */
2016
	static const u_char llzero[ETHER_ADDR_LEN];	/* 00:00:00:00:00:00 */
2016
2017
2017
	BSTP_LOCK_ASSERT(bs);
2018
	BSTP_LOCK_ASSERT(bs);
2018
2019
2020
	if (LIST_EMPTY(&bs->bs_bplist))
2021
		goto disablestp;
2022
2019
	mif = NULL;
2023
	mif = NULL;
2024
	bridgeptr = LIST_FIRST(&bs->bs_bplist)->bp_ifp->if_bridge;
2025
	KASSERT(bridgeptr != NULL, ("Invalid bridge pointer"));
2020
	/*
2026
	/*
2021
	 * Search through the Ethernet adapters and find the one with the
2027
	 * Search through the Ethernet adapters and find the one with the
2022
	 * lowest value. The adapter which we take the MAC address from does
2028
	 * lowest value. Make sure the adapter which we take the MAC address
2023
	 * not need to be part of the bridge, it just needs to be a unique
2029
	 * from is part of this bridge, so we can have more than one independent
2024
	 * value.
2030
	 * bridges in the same STP domain.
2025
	 */
2031
	 */
2026
	IFNET_RLOCK_NOSLEEP();
2032
	IFNET_RLOCK_NOSLEEP();
2027
	TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
2033
	TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
2028
		if (ifp->if_type != IFT_ETHER)
2034
		if (ifp->if_type != IFT_ETHER)
2029
			continue;
2035
			continue;	/* Not Ethernet */
2030
2036
2037
		if (ifp->if_bridge != bridgeptr)
2038
			continue;	/* Not part of our bridge */
2039
2031
		if (bstp_addr_cmp(IF_LLADDR(ifp), llzero) == 0)
2040
		if (bstp_addr_cmp(IF_LLADDR(ifp), llzero) == 0)
2032
			continue;
2041
			continue;	/* No mac address set */
2033
2042
2034
		if (mif == NULL) {
2043
		if (mif == NULL) {
2035
			mif = ifp;
2044
			mif = ifp;
Lines 2041-2062 bstp_reinit(struct bstp_state *bs) Link Here
2041
		}
2050
		}
2042
	}
2051
	}
2043
	IFNET_RUNLOCK_NOSLEEP();
2052
	IFNET_RUNLOCK_NOSLEEP();
2053
	if (mif == NULL)
2054
		goto disablestp;
2044
2055
2045
	if (LIST_EMPTY(&bs->bs_bplist) || mif == NULL) {
2046
		/* Set the bridge and root id (lower bits) to zero */
2047
		bs->bs_bridge_pv.pv_dbridge_id =
2048
		    ((uint64_t)bs->bs_bridge_priority) << 48;
2049
		bs->bs_bridge_pv.pv_root_id = bs->bs_bridge_pv.pv_dbridge_id;
2050
		bs->bs_root_pv = bs->bs_bridge_pv;
2051
		/* Disable any remaining ports, they will have no MAC address */
2052
		LIST_FOREACH(bp, &bs->bs_bplist, bp_next) {
2053
			bp->bp_infois = BSTP_INFO_DISABLED;
2054
			bstp_set_port_role(bp, BSTP_ROLE_DISABLED);
2055
		}
2056
		callout_stop(&bs->bs_bstpcallout);
2057
		return;
2058
	}
2059
2060
	e_addr = IF_LLADDR(mif);
2056
	e_addr = IF_LLADDR(mif);
2061
	bs->bs_bridge_pv.pv_dbridge_id =
2057
	bs->bs_bridge_pv.pv_dbridge_id =
2062
	    (((uint64_t)bs->bs_bridge_priority) << 48) |
2058
	    (((uint64_t)bs->bs_bridge_priority) << 48) |
Lines 2083-2088 bstp_reinit(struct bstp_state *bs) Link Here
2083
2079
2084
	bstp_assign_roles(bs);
2080
	bstp_assign_roles(bs);
2085
	bstp_timer_start(&bs->bs_link_timer, BSTP_LINK_TIMER);
2081
	bstp_timer_start(&bs->bs_link_timer, BSTP_LINK_TIMER);
2082
	return;
2083
2084
disablestp:
2085
	/* Set the bridge and root id (lower bits) to zero */
2086
	bs->bs_bridge_pv.pv_dbridge_id =
2087
	    ((uint64_t)bs->bs_bridge_priority) << 48;
2088
	bs->bs_bridge_pv.pv_root_id = bs->bs_bridge_pv.pv_dbridge_id;
2089
	bs->bs_root_pv = bs->bs_bridge_pv;
2090
	/* Disable any remaining ports, they will have no MAC address */
2091
	LIST_FOREACH(bp, &bs->bs_bplist, bp_next) {
2092
		bp->bp_infois = BSTP_INFO_DISABLED;
2093
		bstp_set_port_role(bp, BSTP_ROLE_DISABLED);
2094
	}
2095
	callout_stop(&bs->bs_bstpcallout);
2086
}
2096
}
2087
2097
2088
static int
2098
static int

Return to bug 164369