* bridge_input: * * Receive input from a member interface. Queue the packet for * bridging if it is not for us. */
| 2337 | * bridging if it is not for us. |
| 2338 | */ |
| 2339 | static struct mbuf * |
| 2340 | bridge_input(struct ifnet *ifp, struct mbuf *m) |
| 2341 | { |
| 2342 | struct bridge_softc *sc = ifp->if_bridge; |
| 2343 | struct bridge_iflist *bif, *bif2; |
| 2344 | struct ifnet *bifp; |
| 2345 | struct ether_header *eh; |
| 2346 | struct mbuf *mc, *mc2; |
| 2347 | uint16_t vlan; |
| 2348 | int error; |
| 2349 | |
| 2350 | NET_EPOCH_ASSERT(); |
| 2351 | |
| 2352 | if ((sc->sc_ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) |
| 2353 | return (m); |
| 2354 | |
| 2355 | bifp = sc->sc_ifp; |
| 2356 | vlan = VLANTAGOF(m); |
| 2357 | |
| 2358 | /* |
| 2359 | * Implement support for bridge monitoring. If this flag has been |
| 2360 | * set on this interface, discard the packet once we push it through |
| 2361 | * the bpf(4) machinery, but before we do, increment the byte and |
| 2362 | * packet counters associated with this interface. |
| 2363 | */ |
| 2364 | if ((bifp->if_flags & IFF_MONITOR) != 0) { |
| 2365 | m->m_pkthdr.rcvif = bifp; |
| 2366 | ETHER_BPF_MTAP(bifp, m); |
| 2367 | if_inc_counter(bifp, IFCOUNTER_IPACKETS, 1); |
| 2368 | if_inc_counter(bifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); |
| 2369 | m_freem(m); |
| 2370 | return (NULL); |
| 2371 | } |
| 2372 | bif = bridge_lookup_member_if(sc, ifp); |
| 2373 | if (bif == NULL) { |
| 2374 | return (m); |
| 2375 | } |
| 2376 | |
| 2377 | eh = mtod(m, struct ether_header *); |
| 2378 | |
| 2379 | bridge_span(sc, m); |
| 2380 | |
| 2381 | if (m->m_flags & (M_BCAST|M_MCAST)) { |
| 2382 | /* Tap off 802.1D packets; they do not get forwarded. */ |
| 2383 | if (memcmp(eh->ether_dhost, bstp_etheraddr, |
| 2384 | ETHER_ADDR_LEN) == 0) { |
| 2385 | bstp_input(&bif->bif_stp, ifp, m); /* consumes mbuf */ |
| 2386 | return (NULL); |
| 2387 | } |
| 2388 | |
| 2389 | if ((bif->bif_flags & IFBIF_STP) && |
| 2390 | bif->bif_stp.bp_state == BSTP_IFSTATE_DISCARDING) { |
| 2391 | return (m); |
| 2392 | } |
| 2393 | |
| 2394 | /* |
| 2395 | * Make a deep copy of the packet and enqueue the copy |
| 2396 | * for bridge processing; return the original packet for |
nothing calls this directly
no test coverage detected