kernel - Clean up if_bridge bif_state tests
authorMatthew Dillon <dillon@apollo.backplane.com>
Sat, 23 Feb 2013 19:47:01 +0000 (11:47 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Sat, 23 Feb 2013 19:47:01 +0000 (11:47 -0800)
* bif_state is only valid when IFBIF_STP is set, adjust two bits of
  code that were using bif_state unconditionally.

* This is a semi-operational change because bif_state's default value
  when IFBIF_STP is not set resulted in correct operation anyway.

  However, setting STP and then clearing it on a sub-interface could
  cause problems with stale state.

sys/net/bridge/if_bridge.c

index 81dd736..c9d8131 100644 (file)
@@ -2406,8 +2406,10 @@ bridge_forward(struct bridge_softc *sc, struct mbuf *m)
                        /* learning, blocking, bonded, forwarding */
                        break;
                }
+               from_blocking = (bif->bif_state == BSTP_IFSTATE_BLOCKING);
+       } else {
+               from_blocking = 0;
        }
-       from_blocking = (bif->bif_state == BSTP_IFSTATE_BLOCKING);
 
        eh = mtod(m, struct ether_header *);
 
@@ -2809,7 +2811,8 @@ bridge_input(struct ifnet *ifp, struct mbuf *m)
                                m->m_flags |= M_ETHER_BRIDGED;
                        }
                        if ((bif->bif_flags & IFBIF_LEARNING) &&
-                           bif->bif_state != BSTP_IFSTATE_BLOCKING) {
+                           ((bif->bif_flags & IFBIF_STP) == 0 ||
+                            bif->bif_state != BSTP_IFSTATE_BLOCKING)) {
                                bridge_rtupdate(sc, eh->ether_shost,
                                                ifp, IFBAF_DYNAMIC);
                        }