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

Function bridge_forward

freebsd/net/if_bridge.c:2193–2331  ·  view source on GitHub ↗

* bridge_forward: * * The forwarding function of the bridge. * * NOTE: Releases the lock on return. */

Source from the content-addressed store, hash-verified

2191 * NOTE: Releases the lock on return.
2192 */
2193static void
2194bridge_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 /*

Callers 2

bridge_inputFunction · 0.85
if_bridge.cFile · 0.85

Calls 8

if_inc_counterFunction · 0.85
bridge_rtupdateFunction · 0.85
bridge_rtlookupFunction · 0.85
bridge_pfilFunction · 0.85
bridge_broadcastFunction · 0.85
bridge_lookup_member_ifFunction · 0.85
bridge_enqueueFunction · 0.85
m_freemFunction · 0.50

Tested by

no test coverage detected