Lines Matching refs:bif

179 bstp_transmit_config(struct bridge_softc *sc, struct bridge_iflist *bif)
181 if (bif->bif_hold_timer.active) {
182 bif->bif_config_pending = 1;
186 bif->bif_config_bpdu.cu_message_type = BSTP_MSGTYPE_CFG;
187 bif->bif_config_bpdu.cu_rootid = sc->sc_designated_root;
188 bif->bif_config_bpdu.cu_root_path_cost = sc->sc_root_path_cost;
189 bif->bif_config_bpdu.cu_bridge_id = sc->sc_bridge_id;
190 bif->bif_config_bpdu.cu_port_id = bif->bif_port_id;
193 bif->bif_config_bpdu.cu_message_age = 0;
195 bif->bif_config_bpdu.cu_message_age =
199 bif->bif_config_bpdu.cu_max_age = sc->sc_max_age;
200 bif->bif_config_bpdu.cu_hello_time = sc->sc_hello_time;
201 bif->bif_config_bpdu.cu_forward_delay = sc->sc_forward_delay;
202 bif->bif_config_bpdu.cu_topology_change_acknowledgment
203 = bif->bif_topology_change_acknowledge;
204 bif->bif_config_bpdu.cu_topology_change = sc->sc_topology_change;
206 if (bif->bif_config_bpdu.cu_message_age < sc->sc_max_age) {
207 bif->bif_topology_change_acknowledge = 0;
208 bif->bif_config_pending = 0;
209 bstp_send_config_bpdu(sc, bif, &bif->bif_config_bpdu);
210 bstp_timer_start(&bif->bif_hold_timer, 0);
215 bstp_send_config_bpdu(struct bridge_softc *sc, struct bridge_iflist *bif,
225 ifp = bif->bif_ifp;
290 bstp_supersedes_port_info(struct bridge_softc *sc, struct bridge_iflist *bif,
293 if (cu->cu_rootid < bif->bif_designated_root)
295 if (cu->cu_rootid > bif->bif_designated_root)
298 if (cu->cu_root_path_cost < bif->bif_designated_cost)
300 if (cu->cu_root_path_cost > bif->bif_designated_cost)
303 if (cu->cu_bridge_id < bif->bif_designated_bridge)
305 if (cu->cu_bridge_id > bif->bif_designated_bridge)
310 if (cu->cu_port_id <= bif->bif_designated_port)
317 struct bridge_iflist *bif, struct bstp_config_unit *cu)
319 bif->bif_designated_root = cu->cu_rootid;
320 bif->bif_designated_cost = cu->cu_root_path_cost;
321 bif->bif_designated_bridge = cu->cu_bridge_id;
322 bif->bif_designated_port = cu->cu_port_id;
323 bstp_timer_start(&bif->bif_message_age_timer, cu->cu_message_age);
339 struct bridge_iflist *bif;
341 BRIDGE_IFLIST_WRITER_FOREACH(bif, sc) {
342 if ((bif->bif_flags & IFBIF_STP) == 0)
344 if (bstp_designated_port(sc, bif) &&
345 (bif->bif_state != BSTP_IFSTATE_DISABLED))
346 bstp_transmit_config(sc, bif);
351 bstp_designated_port(struct bridge_softc *sc, struct bridge_iflist *bif)
353 return ((bif->bif_designated_bridge == sc->sc_bridge_id)
354 && (bif->bif_designated_port == bif->bif_port_id));
361 struct bridge_iflist *bif = sc->sc_root_port;
368 KASSERT(bif != NULL);
369 ifp = bif->bif_ifp;
410 struct bridge_iflist *root_port = NULL, *bif;
412 BRIDGE_IFLIST_WRITER_FOREACH(bif, sc) {
413 if ((bif->bif_flags & IFBIF_STP) == 0)
415 if (bstp_designated_port(sc, bif))
417 if (bif->bif_state == BSTP_IFSTATE_DISABLED)
419 if (bif->bif_designated_root >= sc->sc_bridge_id)
424 if (bif->bif_designated_root < root_port->bif_designated_root)
426 if (bif->bif_designated_root > root_port->bif_designated_root)
429 if ((bif->bif_designated_cost + bif->bif_path_cost) <
432 if ((bif->bif_designated_cost + bif->bif_path_cost) >
436 if (bif->bif_designated_bridge <
439 if (bif->bif_designated_bridge >
443 if (bif->bif_designated_port < root_port->bif_designated_port)
445 if (bif->bif_designated_port > root_port->bif_designated_port)
448 if (bif->bif_port_id >= root_port->bif_port_id)
451 root_port = bif;
468 struct bridge_iflist *bif;
470 BRIDGE_IFLIST_WRITER_FOREACH(bif, sc) {
471 if ((bif->bif_flags & IFBIF_STP) == 0)
473 if (bstp_designated_port(sc, bif))
475 if (bif->bif_designated_root != sc->sc_designated_root)
478 if (sc->sc_root_path_cost < bif->bif_designated_cost)
480 if (sc->sc_root_path_cost > bif->bif_designated_cost)
483 if (sc->sc_bridge_id < bif->bif_designated_bridge)
485 if (sc->sc_bridge_id > bif->bif_designated_bridge)
488 if (bif->bif_port_id > bif->bif_designated_port)
491 bstp_become_designated_port(sc, bif);
496 bstp_become_designated_port(struct bridge_softc *sc, struct bridge_iflist *bif)
498 bif->bif_designated_root = sc->sc_designated_root;
499 bif->bif_designated_cost = sc->sc_root_path_cost;
500 bif->bif_designated_bridge = sc->sc_bridge_id;
501 bif->bif_designated_port = bif->bif_port_id;
507 struct bridge_iflist *bif;
509 BRIDGE_IFLIST_WRITER_FOREACH(bif, sc) {
510 if ((bif->bif_flags & IFBIF_STP) == 0)
512 if (bif == sc->sc_root_port) {
513 bif->bif_config_pending = 0;
514 bif->bif_topology_change_acknowledge = 0;
515 bstp_make_forwarding(sc, bif);
516 } else if (bstp_designated_port(sc, bif)) {
517 bstp_timer_stop(&bif->bif_message_age_timer);
518 bstp_make_forwarding(sc, bif);
520 bif->bif_config_pending = 0;
521 bif->bif_topology_change_acknowledge = 0;
522 bstp_make_blocking(sc, bif);
529 struct bridge_iflist *bif)
531 if (bif->bif_state == BSTP_IFSTATE_BLOCKING) {
532 bstp_set_port_state(bif, BSTP_IFSTATE_LISTENING);
533 bstp_timer_start(&bif->bif_forward_delay_timer, 0);
538 bstp_make_blocking(struct bridge_softc *sc, struct bridge_iflist *bif)
540 if ((bif->bif_state != BSTP_IFSTATE_DISABLED) &&
541 (bif->bif_state != BSTP_IFSTATE_BLOCKING)) {
542 if ((bif->bif_state == BSTP_IFSTATE_FORWARDING) ||
543 (bif->bif_state == BSTP_IFSTATE_LEARNING)) {
544 if (bif->bif_change_detection_enabled) {
548 bstp_set_port_state(bif, BSTP_IFSTATE_BLOCKING);
549 bstp_timer_stop(&bif->bif_forward_delay_timer);
554 bstp_set_port_state(struct bridge_iflist *bif, uint8_t state)
556 bif->bif_state = state;
581 struct bridge_iflist *bif)
583 bif->bif_topology_change_acknowledge = 1;
584 bstp_transmit_config(sc, bif);
588 bstp_input(struct bridge_softc *sc, struct bridge_iflist *bif, struct mbuf *m)
599 if ((bif->bif_flags & IFBIF_STP) == 0)
628 bstp_received_tcn_bpdu(sc, bif, &tu);
669 bstp_received_config_bpdu(sc, bif, &cu);
683 bstp_received_config_bpdu(struct bridge_softc *sc, struct bridge_iflist *bif,
690 if (bif->bif_state != BSTP_IFSTATE_DISABLED) {
691 if (bstp_supersedes_port_info(sc, bif, cu)) {
692 bstp_record_config_information(sc, bif, cu);
707 if (bif == sc->sc_root_port) {
714 } else if (bstp_designated_port(sc, bif))
715 bstp_transmit_config(sc, bif);
720 bstp_received_tcn_bpdu(struct bridge_softc *sc, struct bridge_iflist *bif,
723 if (bif->bif_state != BSTP_IFSTATE_DISABLED &&
724 bstp_designated_port(sc, bif)) {
726 bstp_acknowledge_topology_change(sc, bif);
739 struct bridge_iflist *bif)
744 bstp_become_designated_port(sc, bif);
762 struct bridge_iflist *bif)
764 if (bif->bif_state == BSTP_IFSTATE_LISTENING) {
765 bstp_set_port_state(bif, BSTP_IFSTATE_LEARNING);
766 bstp_timer_start(&bif->bif_forward_delay_timer, 0);
767 } else if (bif->bif_state == BSTP_IFSTATE_LEARNING) {
768 bstp_set_port_state(bif, BSTP_IFSTATE_FORWARDING);
770 bif->bif_change_detection_enabled)
779 struct bridge_iflist *bif;
781 BRIDGE_IFLIST_WRITER_FOREACH(bif, sc) {
782 if ((bif->bif_flags & IFBIF_STP) == 0)
784 if (bif->bif_designated_bridge == sc->sc_bridge_id)
805 bstp_hold_timer_expiry(struct bridge_softc *sc, struct bridge_iflist *bif)
807 if (bif->bif_config_pending)
808 bstp_transmit_config(sc, bif);
814 struct bridge_iflist *bif, *mif;
820 BRIDGE_IFLIST_WRITER_FOREACH(bif, sc) {
821 if ((bif->bif_flags & IFBIF_STP) == 0)
823 if (bif->bif_ifp->if_type != IFT_ETHER)
825 bif->bif_port_id = (bif->bif_priority << 8) |
826 (bif->bif_ifp->if_index & 0xff);
829 mif = bif;
832 if (memcmp(CLLADDR(bif->bif_ifp->if_sadl),
834 mif = bif;
874 BRIDGE_IFLIST_WRITER_FOREACH(bif, sc) {
875 if (bif->bif_flags & IFBIF_STP)
876 bstp_enable_port(sc, bif);
878 bstp_disable_port(sc, bif);
891 struct bridge_iflist *bif;
894 BRIDGE_IFLIST_WRITER_FOREACH(bif, sc) {
895 bstp_set_port_state(bif, BSTP_IFSTATE_DISABLED);
896 bstp_timer_stop(&bif->bif_hold_timer);
897 bstp_timer_stop(&bif->bif_message_age_timer);
898 bstp_timer_stop(&bif->bif_forward_delay_timer);
911 bstp_initialize_port(struct bridge_softc *sc, struct bridge_iflist *bif)
913 bstp_become_designated_port(sc, bif);
914 bstp_set_port_state(bif, BSTP_IFSTATE_BLOCKING);
915 bif->bif_topology_change_acknowledge = 0;
916 bif->bif_config_pending = 0;
917 bif->bif_change_detection_enabled = 1;
918 bstp_timer_stop(&bif->bif_message_age_timer);
919 bstp_timer_stop(&bif->bif_forward_delay_timer);
920 bstp_timer_stop(&bif->bif_hold_timer);
924 bstp_enable_port(struct bridge_softc *sc, struct bridge_iflist *bif)
926 bstp_initialize_port(sc, bif);
931 bstp_disable_port(struct bridge_softc *sc, struct bridge_iflist *bif)
936 bstp_become_designated_port(sc, bif);
937 bstp_set_port_state(bif, BSTP_IFSTATE_DISABLED);
938 bif->bif_topology_change_acknowledge = 0;
939 bif->bif_config_pending = 0;
940 bstp_timer_stop(&bif->bif_message_age_timer);
941 bstp_timer_stop(&bif->bif_forward_delay_timer);
961 struct bridge_iflist *bif;
966 BRIDGE_IFLIST_WRITER_FOREACH(bif, sc) {
967 if ((bif->bif_flags & IFBIF_STP) == 0)
969 if (bstp_designated_port(sc, bif))
970 bif->bif_designated_bridge = new_bridge_id;
991 bstp_set_port_priority(struct bridge_softc *sc, struct bridge_iflist *bif,
994 if (bstp_designated_port(sc, bif))
995 bif->bif_designated_port = new_port_id;
997 bif->bif_port_id = new_port_id;
999 if ((sc->sc_bridge_id == bif->bif_designated_bridge) &&
1000 (bif->bif_port_id < bif->bif_designated_port)) {
1001 bstp_become_designated_port(sc, bif);
1007 bstp_set_path_cost(struct bridge_softc *sc, struct bridge_iflist *bif,
1010 bif->bif_path_cost = path_cost;
1017 bstp_ifupdstatus(struct bridge_softc *sc, struct bridge_iflist *bif)
1019 struct ifnet *ifp = bif->bif_ifp;
1028 if (bif->bif_state == BSTP_IFSTATE_DISABLED)
1029 bstp_enable_port(sc, bif);
1033 if (bif->bif_state == BSTP_IFSTATE_DISABLED)
1034 bstp_enable_port(sc, bif);
1038 if (bif->bif_state != BSTP_IFSTATE_DISABLED)
1039 bstp_disable_port(sc, bif);
1045 if (bif->bif_state != BSTP_IFSTATE_DISABLED)
1046 bstp_disable_port(sc, bif);
1053 struct bridge_iflist *bif;
1057 BRIDGE_IFLIST_WRITER_FOREACH(bif, sc) {
1058 if ((bif->bif_flags & IFBIF_STP) == 0)
1067 bstp_ifupdstatus(sc, bif);
1080 BRIDGE_IFLIST_WRITER_FOREACH(bif, sc) {
1081 if ((bif->bif_flags & IFBIF_STP) == 0)
1083 if (bstp_timer_expired(&bif->bif_message_age_timer,
1085 bstp_message_age_timer_expiry(sc, bif);
1088 BRIDGE_IFLIST_WRITER_FOREACH(bif, sc) {
1089 if ((bif->bif_flags & IFBIF_STP) == 0)
1091 if (bstp_timer_expired(&bif->bif_forward_delay_timer,
1093 bstp_forward_delay_timer_expiry(sc, bif);
1095 if (bstp_timer_expired(&bif->bif_hold_timer,
1097 bstp_hold_timer_expiry(sc, bif);