MCPcopy Create free account
hub / github.com/F-Stack/f-stack / bstp_reinit

Function bstp_reinit

freebsd/net/bridgestp.c:2021–2109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2019}
2020
2021void
2022bstp_reinit(struct bstp_state *bs)
2023{
2024 struct epoch_tracker et;
2025 struct bstp_port *bp;
2026 struct ifnet *ifp, *mif;
2027 u_char *e_addr;
2028 void *bridgeptr;
2029 static const u_char llzero[ETHER_ADDR_LEN]; /* 00:00:00:00:00:00 */
2030
2031 BSTP_LOCK_ASSERT(bs);
2032
2033 if (LIST_EMPTY(&bs->bs_bplist))
2034 goto disablestp;
2035
2036 mif = NULL;
2037 bridgeptr = LIST_FIRST(&bs->bs_bplist)->bp_ifp->if_bridge;
2038 KASSERT(bridgeptr != NULL, ("Invalid bridge pointer"));
2039 /*
2040 * Search through the Ethernet adapters and find the one with the
2041 * lowest value. Make sure the adapter which we take the MAC address
2042 * from is part of this bridge, so we can have more than one independent
2043 * bridges in the same STP domain.
2044 */
2045 NET_EPOCH_ENTER(et);
2046 CK_STAILQ_FOREACH(ifp, &V_ifnet, if_link) {
2047 if (ifp->if_type != IFT_ETHER)
2048 continue; /* Not Ethernet */
2049
2050 if (ifp->if_bridge != bridgeptr)
2051 continue; /* Not part of our bridge */
2052
2053 if (bstp_addr_cmp(IF_LLADDR(ifp), llzero) == 0)
2054 continue; /* No mac address set */
2055
2056 if (mif == NULL) {
2057 mif = ifp;
2058 continue;
2059 }
2060 if (bstp_addr_cmp(IF_LLADDR(ifp), IF_LLADDR(mif)) < 0) {
2061 mif = ifp;
2062 continue;
2063 }
2064 }
2065 NET_EPOCH_EXIT(et);
2066 if (mif == NULL)
2067 goto disablestp;
2068
2069 e_addr = IF_LLADDR(mif);
2070 bs->bs_bridge_pv.pv_dbridge_id =
2071 (((uint64_t)bs->bs_bridge_priority) << 48) |
2072 (((uint64_t)e_addr[0]) << 40) |
2073 (((uint64_t)e_addr[1]) << 32) |
2074 (((uint64_t)e_addr[2]) << 24) |
2075 (((uint64_t)e_addr[3]) << 16) |
2076 (((uint64_t)e_addr[4]) << 8) |
2077 (((uint64_t)e_addr[5]));
2078

Callers 10

bstp_set_htimeFunction · 0.85
bstp_set_fdelayFunction · 0.85
bstp_set_maxageFunction · 0.85
bstp_set_protocolFunction · 0.85
bstp_set_priorityFunction · 0.85
bstp_set_port_priorityFunction · 0.85
bstp_set_path_costFunction · 0.85
bstp_initFunction · 0.85
bstp_enableFunction · 0.85
bstp_disableFunction · 0.85

Calls 5

bstp_addr_cmpFunction · 0.85
taskqueue_enqueueFunction · 0.85
bstp_assign_rolesFunction · 0.85
bstp_timer_startFunction · 0.85
bstp_set_port_roleFunction · 0.85

Tested by

no test coverage detected