* bridge_forward: * * The forwarding function of the bridge. * * NOTE: Releases the lock on return. */
| 2191 | * NOTE: Releases the lock on return. |
| 2192 | */ |
| 2193 | static void |
| 2194 | bridge_forward(struct bridge_softc *sc, struct bridge_iflist *sbif, |
| 2195 | struct mbuf *m) |
| 2196 | { |
| 2197 | struct bridge_iflist *dbif; |
| 2198 | struct ifnet *src_if, *dst_if, *ifp; |
| 2199 | struct ether_header *eh; |
| 2200 | uint16_t vlan; |
| 2201 | uint8_t *dst; |
| 2202 | int error; |
| 2203 | |
| 2204 | NET_EPOCH_ASSERT(); |
| 2205 | |
| 2206 | src_if = m->m_pkthdr.rcvif; |
| 2207 | ifp = sc->sc_ifp; |
| 2208 | |
| 2209 | if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); |
| 2210 | if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); |
| 2211 | vlan = VLANTAGOF(m); |
| 2212 | |
| 2213 | if ((sbif->bif_flags & IFBIF_STP) && |
| 2214 | sbif->bif_stp.bp_state == BSTP_IFSTATE_DISCARDING) |
| 2215 | goto drop; |
| 2216 | |
| 2217 | eh = mtod(m, struct ether_header *); |
| 2218 | dst = eh->ether_dhost; |
| 2219 | |
| 2220 | /* If the interface is learning, record the address. */ |
| 2221 | if (sbif->bif_flags & IFBIF_LEARNING) { |
| 2222 | error = bridge_rtupdate(sc, eh->ether_shost, vlan, |
| 2223 | sbif, 0, IFBAF_DYNAMIC); |
| 2224 | /* |
| 2225 | * If the interface has addresses limits then deny any source |
| 2226 | * that is not in the cache. |
| 2227 | */ |
| 2228 | if (error && sbif->bif_addrmax) |
| 2229 | goto drop; |
| 2230 | } |
| 2231 | |
| 2232 | if ((sbif->bif_flags & IFBIF_STP) != 0 && |
| 2233 | sbif->bif_stp.bp_state == BSTP_IFSTATE_LEARNING) |
| 2234 | goto drop; |
| 2235 | |
| 2236 | /* |
| 2237 | * At this point, the port either doesn't participate |
| 2238 | * in spanning tree or it is in the forwarding state. |
| 2239 | */ |
| 2240 | |
| 2241 | /* |
| 2242 | * If the packet is unicast, destined for someone on |
| 2243 | * "this" side of the bridge, drop it. |
| 2244 | */ |
| 2245 | if ((m->m_flags & (M_BCAST|M_MCAST)) == 0) { |
| 2246 | dst_if = bridge_rtlookup(sc, dst, vlan); |
| 2247 | if (src_if == dst_if) |
| 2248 | goto drop; |
| 2249 | } else { |
| 2250 | /* |
no test coverage detected