diff options
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/an/if_an.c | 13 | ||||
-rw-r--r-- | sys/dev/awi/awi.c | 2 | ||||
-rw-r--r-- | sys/dev/cs/if_cs.c | 7 | ||||
-rw-r--r-- | sys/dev/dc/if_dc.c | 40 | ||||
-rw-r--r-- | sys/dev/de/if_de.c | 29 | ||||
-rw-r--r-- | sys/dev/ed/if_ed.c | 66 | ||||
-rw-r--r-- | sys/dev/ep/if_ep.c | 36 | ||||
-rw-r--r-- | sys/dev/ep/if_epvar.h | 1 | ||||
-rw-r--r-- | sys/dev/ex/if_ex.c | 17 | ||||
-rw-r--r-- | sys/dev/fe/if_fe.c | 62 | ||||
-rw-r--r-- | sys/dev/fxp/if_fxp.c | 51 | ||||
-rw-r--r-- | sys/dev/ie/if_ie.c | 158 | ||||
-rw-r--r-- | sys/dev/sf/if_sf.c | 11 | ||||
-rw-r--r-- | sys/dev/sk/if_sk.c | 10 | ||||
-rw-r--r-- | sys/dev/sn/if_sn.c | 20 | ||||
-rw-r--r-- | sys/dev/ti/if_ti.c | 17 | ||||
-rw-r--r-- | sys/dev/tx/if_tx.c | 50 | ||||
-rw-r--r-- | sys/dev/usb/usb_ethersubr.c | 18 | ||||
-rw-r--r-- | sys/dev/vr/if_vr.c | 36 | ||||
-rw-r--r-- | sys/dev/vx/if_vx.c | 17 | ||||
-rw-r--r-- | sys/dev/wi/if_wi.c | 13 | ||||
-rw-r--r-- | sys/dev/wl/if_wl.c | 21 | ||||
-rw-r--r-- | sys/dev/xe/if_xe.c | 24 |
23 files changed, 60 insertions, 659 deletions
diff --git a/sys/dev/an/if_an.c b/sys/dev/an/if_an.c index dc63b93..34a5263 100644 --- a/sys/dev/an/if_an.c +++ b/sys/dev/an/if_an.c @@ -455,25 +455,12 @@ static void an_rxeof(sc) ifp->if_ipackets++; - /* Handle BPF listeners. */ - if (ifp->if_bpf) { - bpf_mtap(ifp, m); - if (ifp->if_flags & IFF_PROMISC && - (bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr, - ETHER_ADDR_LEN) && (eh->ether_dhost[0] & 1) == 0)) { - m_freem(m); - return; - } - } - /* Receive packet. */ m_adj(m, sizeof(struct ether_header)); #ifdef ANCACHE an_cache_store(sc, eh, m, rx_frame.an_rx_signal_strength); #endif ether_input(ifp, eh, m); - - return; } static void an_txeof(sc, status) diff --git a/sys/dev/awi/awi.c b/sys/dev/awi/awi.c index 35f3ac5..75a5737 100644 --- a/sys/dev/awi/awi.c +++ b/sys/dev/awi/awi.c @@ -1311,7 +1311,9 @@ awi_input(sc, m, rxts, rssi) break; } ifp->if_ipackets++; +#ifndef __FreeBSD__ AWI_BPF_MTAP(sc, m, AWI_BPF_NORM); +#endif #ifdef __NetBSD__ m->m_flags |= M_HASFCS; (*ifp->if_input)(ifp, m); diff --git a/sys/dev/cs/if_cs.c b/sys/dev/cs/if_cs.c index 99ae8a4..2801b26 100644 --- a/sys/dev/cs/if_cs.c +++ b/sys/dev/cs/if_cs.c @@ -62,10 +62,6 @@ #include <isa/isavar.h> -#ifdef BRIDGE -#include <net/bridge.h> -#endif - #include <machine/clock.h> #include <dev/cs/if_csreg.h> @@ -952,9 +948,6 @@ cs_get_packet(struct cs_softc *sc) eh = mtod(m, struct ether_header *); - if (ifp->if_bpf) - bpf_mtap(ifp, m); - #ifdef CS_DEBUG for (i=0;i<length;i++) printf(" %02x",(unsigned char)*((char *)(m->m_data+i))); diff --git a/sys/dev/dc/if_dc.c b/sys/dev/dc/if_dc.c index 67f46f8..7344561 100644 --- a/sys/dev/dc/if_dc.c +++ b/sys/dev/dc/if_dc.c @@ -122,11 +122,6 @@ #include <net/bpf.h> -#include "opt_bdg.h" -#ifdef BRIDGE -#include <net/bridge.h> -#endif - #include <vm/vm.h> /* for vtophys */ #include <vm/pmap.h> /* for vtophys */ #include <machine/clock.h> /* for DELAY */ @@ -2133,47 +2128,12 @@ static void dc_rxeof(sc) ifp->if_ipackets++; eh = mtod(m, struct ether_header *); - /* Handle BPF listeners. Let the BPF user see the packet */ - if (ifp->if_bpf) - bpf_mtap(ifp, m); - -#ifdef BRIDGE - if (do_bridge) { - struct ifnet *bdg_ifp ; - bdg_ifp = bridge_in(m); - if (bdg_ifp != BDG_LOCAL && bdg_ifp != BDG_DROP) - bdg_forward(&m, bdg_ifp); - if (((bdg_ifp != BDG_LOCAL) && (bdg_ifp != BDG_BCAST) && (bdg_ifp != BDG_MCAST)) || bdg_ifp == BDG_DROP) { - m_freem(m); - continue; - } - } - - eh = mtod(m, struct ether_header *); -#endif - - /* Don't pass it up to the ether_input() layer unless it's - * a broadcast packet, multicast packet, matches our ethernet - * address or the interface is in promiscuous mode. - */ - if (ifp->if_bpf) { - if (ifp->if_flags & IFF_PROMISC && - (bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr, - ETHER_ADDR_LEN) && - (eh->ether_dhost[0] & 1) == 0)) { - m_freem(m); - continue; - } - } - /* Remove header from mbuf and pass it on. */ m_adj(m, sizeof(struct ether_header)); ether_input(ifp, eh, m); } sc->dc_cdata.dc_rx_prod = i; - - return; } /* diff --git a/sys/dev/de/if_de.c b/sys/dev/de/if_de.c index 8054bd5..e949c94 100644 --- a/sys/dev/de/if_de.c +++ b/sys/dev/de/if_de.c @@ -89,11 +89,6 @@ #include <pci/pcireg.h> #include <pci/dc21040reg.h> -#include "opt_bdg.h" -#ifdef BRIDGE -#include <net/bridge.h> -#endif - /* * Intel CPUs should use I/O mapped access. */ @@ -3475,34 +3470,15 @@ tulip_rx_intr( #endif /* TULIP_BUS_DMA */ eh = *mtod(ms, struct ether_header *); +#ifndef __FreeBSD__ if (sc->tulip_if.if_bpf != NULL) { if (me == ms) bpf_tap(&sc->tulip_if, mtod(ms, caddr_t), total_len); else bpf_mtap(&sc->tulip_if, ms); } +#endif sc->tulip_flags |= TULIP_RXACT; - -#ifdef BRIDGE /* see code in if_ed.c */ - ms->m_pkthdr.rcvif = ifp; /* XXX */ - ms->m_pkthdr.len = total_len; /* XXX */ - if (do_bridge) { - struct ifnet *bdg_ifp ; - bdg_ifp = bridge_in(ms); - if (bdg_ifp == BDG_DROP) - goto next ; /* and drop */ - if (bdg_ifp != BDG_LOCAL) - bdg_forward(&ms, bdg_ifp); - if (bdg_ifp != BDG_LOCAL && bdg_ifp != BDG_BCAST && - bdg_ifp != BDG_MCAST) - goto next ; /* and drop */ - /* all others accepted locally */ - } else -#endif - if ((sc->tulip_flags & (TULIP_PROMISC|TULIP_HASHONLY)) - && (eh.ether_dhost[0] & 1) == 0 - && !TULIP_ADDREQUAL(eh.ether_dhost, sc->tulip_enaddr)) - goto next; accept = 1; } else { ifp->if_ierrors++; @@ -3551,7 +3527,6 @@ tulip_rx_intr( #endif #endif /* TULIP_BUS_DMA */ } - next: #if defined(TULIP_DEBUG) cnt++; #endif diff --git a/sys/dev/ed/if_ed.c b/sys/dev/ed/if_ed.c index e8db0ee..7ab2645 100644 --- a/sys/dev/ed/if_ed.c +++ b/sys/dev/ed/if_ed.c @@ -77,7 +77,7 @@ static void ed_watchdog __P((struct ifnet *)); static void ds_getmcaf __P((struct ed_softc *, u_long *)); -static void ed_get_packet __P((struct ed_softc *, char *, /* u_short */ int, int)); +static void ed_get_packet __P((struct ed_softc *, char *, /* u_short */ int)); static __inline void ed_rint __P((struct ed_softc *)); static __inline void ed_xmit __P((struct ed_softc *)); @@ -2206,7 +2206,7 @@ ed_rint(sc) * Go get packet. */ ed_get_packet(sc, packet_ptr + sizeof(struct ed_ring), - len - sizeof(struct ed_ring), packet_hdr.rsr & ED_RSR_PHY); + len - sizeof(struct ed_ring)); ifp->if_ipackets++; } else { /* @@ -2612,14 +2612,13 @@ ed_ring_copy(sc, src, dst, amount) /* * Retreive packet from shared memory and send to the next level up via - * ether_input(). If there is a BPF listener, give a copy to BPF, too. + * ether_input(). */ static void -ed_get_packet(sc, buf, len, multicast) +ed_get_packet(sc, buf, len) struct ed_softc *sc; char *buf; u_short len; - int multicast; { struct ether_header *eh; struct mbuf *m; @@ -2657,37 +2656,19 @@ ed_get_packet(sc, buf, len, multicast) #ifdef BRIDGE /* - * Get link layer header, invoke brige_in, then - * depending on the outcome of the test fetch the rest of the - * packet and either pass up or call bdg_forward. + * Don't read in the entire packet if we know we're going to drop it */ if (do_bridge) { - struct ifnet *ifp ; - int need_more = 1 ; /* in case not bpf */ - - if (sc->arpcom.ac_if.if_bpf) { - need_more = 0 ; - ed_ring_copy(sc, buf, (char *)eh, len); - bpf_mtap(&sc->arpcom.ac_if, m); - } else - ed_ring_copy(sc, buf, (char *)eh, 14); - ifp = bridge_in(m); - if (ifp == BDG_DROP) { + struct ifnet *bif; + + ed_ring_copy(sc, buf, (char *)eh, ETHER_HDR_LEN); + if ((bif = bridge_in(&sc->arpcom.ac_if, eh)) == BDG_DROP) { m_freem(m); - return ; + return; } - /* else fetch rest of pkt and continue */ - if (need_more && len > 14) - ed_ring_copy(sc, buf+14, (char *)(eh+1), len - 14); - if (ifp != BDG_LOCAL ) - bdg_forward(&m, ifp); /* not local, need forwarding */ - if (ifp == BDG_LOCAL || ifp == BDG_BCAST || ifp == BDG_MCAST) - goto getit ; - /* not local and not multicast, just drop it */ - if (m) - m_freem(m); - return ; - } + ed_ring_copy(sc, buf + ETHER_HDR_LEN, + (char *)eh + ETHER_HDR_LEN, len - ETHER_HDR_LEN); + } else #endif /* * Get packet, including link layer address, from interface. @@ -2695,33 +2676,12 @@ ed_get_packet(sc, buf, len, multicast) ed_ring_copy(sc, buf, (char *)eh, len); /* - * Check if there's a BPF listener on this interface. If so, hand off - * the raw packet to bpf. - */ - if (sc->arpcom.ac_if.if_bpf) - bpf_mtap(&sc->arpcom.ac_if, m); - /* - * If we are in promiscuous mode, we have to check whether - * this packet is really for us. - */ - if ((sc->arpcom.ac_if.if_flags & IFF_PROMISC) && - bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr, - sizeof(eh->ether_dhost)) != 0 && multicast == 0) { - m_freem(m); - return; - } - -#ifdef BRIDGE -getit: -#endif - /* * Remove link layer address. */ m->m_pkthdr.len = m->m_len = len - sizeof(struct ether_header); m->m_data += sizeof(struct ether_header); ether_input(&sc->arpcom.ac_if, eh, m); - return; } /* diff --git a/sys/dev/ep/if_ep.c b/sys/dev/ep/if_ep.c index e4b4001..a1762b6 100644 --- a/sys/dev/ep/if_ep.c +++ b/sys/dev/ep/if_ep.c @@ -410,8 +410,7 @@ ep_if_init(xsc) #ifdef EP_LOCAL_STATS sc->rx_no_first = sc->rx_no_mbuf = - sc->rx_bpf_disc = sc->rx_overrunf = sc->rx_overrunl = - sc->tx_underrun = 0; + sc->rx_overrunf = sc->rx_overrunl = sc->tx_underrun = 0; #endif EP_FSET(sc, F_RX_FIRST); if (sc->top) { @@ -593,8 +592,8 @@ rescan: printf("\tStat: %x\n", sc->stat); printf("\tIpackets=%d, Opackets=%d\n", ifp->if_ipackets, ifp->if_opackets); - printf("\tNOF=%d, NOMB=%d, BPFD=%d, RXOF=%d, RXOL=%d, TXU=%d\n", - sc->rx_no_first, sc->rx_no_mbuf, sc->rx_bpf_disc, sc->rx_overrunf, + printf("\tNOF=%d, NOMB=%d, RXOF=%d, RXOL=%d, TXU=%d\n", + sc->rx_no_first, sc->rx_no_mbuf, sc->rx_overrunf, sc->rx_overrunl, sc->tx_underrun); #else @@ -772,35 +771,6 @@ read_again: top->m_pkthdr.rcvif = &sc->arpcom.ac_if; top->m_pkthdr.len = sc->cur_len; - if (ifp->if_bpf) { - bpf_mtap(ifp, top); - - /* - * Note that the interface cannot be in promiscuous mode if there are - * no BPF listeners. And if we are in promiscuous mode, we have to - * check if this packet is really ours. - */ - eh = mtod(top, struct ether_header *); - if ((ifp->if_flags & IFF_PROMISC) && - (eh->ether_dhost[0] & 1) == 0 && - bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr, - sizeof(eh->ether_dhost)) != 0 && - bcmp(eh->ether_dhost, etherbroadcastaddr, - sizeof(eh->ether_dhost)) != 0) { - if (sc->top) { - m_freem(sc->top); - sc->top = 0; - } - EP_FSET(sc, F_RX_FIRST); -#ifdef EP_LOCAL_STATS - sc->rx_bpf_disc++; -#endif - while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS); - outw(BASE + EP_COMMAND, SET_RX_EARLY_THRESH | RX_INIT_EARLY_THRESH); - return; - } - } - eh = mtod(top, struct ether_header *); m_adj(top, sizeof(struct ether_header)); ether_input(ifp, eh, top); diff --git a/sys/dev/ep/if_epvar.h b/sys/dev/ep/if_epvar.h index 9329e27..21cceae 100644 --- a/sys/dev/ep/if_epvar.h +++ b/sys/dev/ep/if_epvar.h @@ -69,7 +69,6 @@ struct ep_softc { short tx_underrun; short rx_no_first; short rx_no_mbuf; - short rx_bpf_disc; short rx_overrunf; short rx_overrunl; #endif diff --git a/sys/dev/ex/if_ex.c b/sys/dev/ex/if_ex.c index 166e01a..d804999 100644 --- a/sys/dev/ex/if_ex.c +++ b/sys/dev/ex/if_ex.c @@ -761,23 +761,6 @@ ex_rx_intr(struct ex_softc *sc) } /* QQQ */ } #endif - if (ifp->if_bpf != NULL) { - bpf_mtap(ifp, ipkt); - - /* - * Note that the interface cannot be in promiscuous mode - * if there are no BPF listeners. And if we are in - * promiscuous mode, we have to check if this packet is - * really ours. - */ - if ((ifp->if_flags & IFF_PROMISC) && - (eh->ether_dhost[0] & 1) == 0 && - bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr, sizeof(eh->ether_dhost)) != 0 && - bcmp(eh->ether_dhost, etherbroadcastaddr, sizeof(eh->ether_dhost)) != 0) { - m_freem(ipkt); - goto rx_another; - } - } m_adj(ipkt, sizeof(struct ether_header)); ether_input(ifp, eh, ipkt); ifp->if_ipackets++; diff --git a/sys/dev/fe/if_fe.c b/sys/dev/fe/if_fe.c index ac0d57f..821c80b 100644 --- a/sys/dev/fe/if_fe.c +++ b/sys/dev/fe/if_fe.c @@ -66,7 +66,6 @@ * cons of multiple frame transmission. * o To test IPX codes. * o To test FreeBSD3.0-current. - * o To test BRIDGE codes. */ #include "fe.h" @@ -92,10 +91,6 @@ #include <net/bpf.h> -#ifdef BRIDGE -#include <net/bridge.h> -#endif - #include <machine/clock.h> #include <i386/isa/isa_device.h> @@ -3819,7 +3814,7 @@ fe_ioctl ( struct ifnet * ifp, u_long command, caddr_t data ) /* * Retrieve packet from receive buffer and send to the next level up via - * ether_input(). If there is a BPF listener, give a copy to BPF, too. + * ether_input(). * Returns 0 if success, -1 if error (i.e., mbuf allocation failure). */ static int @@ -3897,61 +3892,6 @@ fe_get_packet ( struct fe_softc * sc, u_short len ) insw( sc->ioaddr[ FE_BMPR8 ], eh, ( len + 1 ) >> 1 ); } -#define ETHER_ADDR_IS_MULTICAST(A) (*(char *)(A) & 1) - - /* - * Check if there's a BPF listener on this interface. - * If it is, hand off the raw packet to bpf. - */ - if ( sc->sc_if.if_bpf ) { - bpf_mtap( &sc->sc_if, m ); - } - -#ifdef BRIDGE - if (do_bridge) { - struct ifnet *ifp; - - ifp = bridge_in(m); - if (ifp == BDG_DROP) { - m_freem(m); - return 0; - } - if (ifp != BDG_LOCAL) - bdg_forward(&m, ifp); /* not local, need forwarding */ - if (ifp == BDG_LOCAL || ifp == BDG_BCAST || ifp == BDG_MCAST) - goto getit; - /* not local and not multicast, just drop it */ - if (m) - m_freem(m); - return 0; - } -#endif - - /* - * Make sure this packet is (or may be) directed to us. - * That is, the packet is either unicasted to our address, - * or broad/multi-casted. If any other packets are - * received, it is an indication of an error -- probably - * 86960 is in a wrong operation mode. - * Promiscuous mode is an exception. Under the mode, all - * packets on the media must be received. (We must have - * programmed the 86960 so.) - */ - - if ( ( sc->sc_if.if_flags & IFF_PROMISC ) - && !ETHER_ADDR_IS_MULTICAST( eh->ether_dhost ) - && bcmp( eh->ether_dhost, sc->sc_enaddr, ETHER_ADDR_LEN ) != 0 ) { - /* - * The packet was not for us. This is normal since - * we are now in promiscuous mode. Just drop the packet. - */ - m_freem( m ); - return 0; - } - -#ifdef BRIDGE -getit: -#endif /* Strip off the Ethernet header. */ m->m_pkthdr.len -= sizeof ( struct ether_header ); m->m_len -= sizeof ( struct ether_header ); diff --git a/sys/dev/fxp/if_fxp.c b/sys/dev/fxp/if_fxp.c index 94ae0f1..b5de024 100644 --- a/sys/dev/fxp/if_fxp.c +++ b/sys/dev/fxp/if_fxp.c @@ -105,13 +105,6 @@ #define vtophys(va) alpha_XXX_dmamap((vm_offset_t)(va)) #endif /* __alpha__ */ - -#include "opt_bdg.h" -#ifdef BRIDGE -#include <net/if_types.h> -#include <net/bridge.h> -#endif - /* * NOTE! On the Alpha, we have an alignment constraint. The * card DMAs the packet immediately following the RFA. However, @@ -1169,53 +1162,13 @@ rcvloop: goto rcvloop; } m->m_pkthdr.rcvif = ifp; - m->m_pkthdr.len = m->m_len = - total_len ; + m->m_pkthdr.len = m->m_len = total_len; eh = mtod(m, struct ether_header *); - if (ifp->if_bpf) - bpf_tap(FXP_BPFTAP_ARG(ifp), - mtod(m, caddr_t), - total_len); -#ifdef BRIDGE - if (do_bridge) { - struct ifnet *bdg_ifp ; - bdg_ifp = bridge_in(m); - if (bdg_ifp == BDG_DROP) - goto dropit ; - if (bdg_ifp != BDG_LOCAL) - bdg_forward(&m, bdg_ifp); - if (bdg_ifp != BDG_LOCAL && - bdg_ifp != BDG_BCAST && - bdg_ifp != BDG_MCAST) - goto dropit ; - goto getit ; - } -#endif - /* - * Only pass this packet up - * if it is for us. - */ - if ((ifp->if_flags & - IFF_PROMISC) && - (rfa->rfa_status & - FXP_RFA_STATUS_IAMATCH) && - (eh->ether_dhost[0] & 1) - == 0) { -#ifdef BRIDGE -dropit: -#endif - if (m) - m_freem(m); - goto rcvloop; - } -#ifdef BRIDGE -getit: -#endif m->m_data += sizeof(struct ether_header); m->m_len -= sizeof(struct ether_header); - m->m_pkthdr.len = m->m_len ; + m->m_pkthdr.len = m->m_len; ether_input(ifp, eh, m); } goto rcvloop; diff --git a/sys/dev/ie/if_ie.c b/sys/dev/ie/if_ie.c index bbb276a..c9ce52d 100644 --- a/sys/dev/ie/if_ie.c +++ b/sys/dev/ie/if_ie.c @@ -158,8 +158,6 @@ static int ie_debug = IED_RNR; /* Forward declaration */ struct ie_softc; -static struct mbuf *last_not_for_us; - static int ieprobe(struct isa_device * dvp); static int ieattach(struct isa_device * dvp); static ointhand2_t ieintr; @@ -202,7 +200,7 @@ static int ietint(int unit, struct ie_softc * ie); static int iernr(int unit, struct ie_softc * ie); static void start_receiver(int unit); static __inline int ieget(int, struct ie_softc *, struct mbuf **, - struct ether_header *, int *); + struct ether_header *); static v_caddr_t setup_rfa(v_caddr_t ptr, struct ie_softc * ie); static int mc_setup(int, v_caddr_t, volatile struct ie_sys_ctl_block *); static void ie_mc_reset(int unit); @@ -1029,102 +1027,48 @@ ether_equal(u_char * one, u_char * two) } /* - * Check for a valid address. to_bpf is filled in with one of the following: - * 0 -> BPF doesn't get this packet - * 1 -> BPF does get this packet - * 2 -> BPF does get this packet, but we don't - * Return value is true if the packet is for us, and false otherwise. - * - * This routine is a mess, but it's also critical that it be as fast - * as possible. It could be made cleaner if we can assume that the - * only client which will fiddle with IFF_PROMISC is BPF. This is - * probably a good assumption, but we do not make it here. (Yet.) + * Determine quickly whether we should bother reading in this packet. + * This depends on whether BPF and/or bridging is enabled, whether we + * are receiving multicast address, and whether promiscuous mode is enabled. + * We assume that if IFF_PROMISC is set, then *somebody* wants to see + * all incoming packets. */ static __inline int -check_eh(struct ie_softc * ie, struct ether_header * eh, int *to_bpf) +check_eh(struct ie_softc *ie, struct ether_header *eh) { - int i; - - switch (ie->promisc) { - case IFF_ALLMULTI: - /* - * Receiving all multicasts, but no unicasts except those - * destined for us. - */ - /* BPF gets this packet if anybody cares */ - *to_bpf = (ie->arpcom.ac_if.if_bpf != 0); - if (eh->ether_dhost[0] & 1) { - return (1); - } - if (ether_equal(eh->ether_dhost, ie->arpcom.ac_enaddr)) - return (1); - return (0); + /* Optimize the common case: normal operation. We've received + either a unicast with our dest or a multicast packet. */ + if (ie->promisc == 0) { + int i; - case IFF_PROMISC: - /* - * Receiving all packets. These need to be passed on to - * BPF. - */ - *to_bpf = (ie->arpcom.ac_if.if_bpf != 0); - /* If for us, accept and hand up to BPF */ - if (ether_equal(eh->ether_dhost, ie->arpcom.ac_enaddr)) + /* If not multicast, it's definitely for us */ + if ((eh->ether_dhost[0] & 1) == 0) return (1); - if (*to_bpf) - *to_bpf = 2; /* we don't need to see it */ - - /* - * Not a multicast, so BPF wants to see it but we don't. - */ - if (!(eh->ether_dhost[0] & 1)) + /* Accept broadcasts (loose but fast check) */ + if (eh->ether_dhost[0] == 0xff) return (1); - /* - * If it's one of our multicast groups, accept it and pass - * it up. - */ + /* Compare against our multicast addresses */ for (i = 0; i < ie->mcast_count; i++) { if (ether_equal(eh->ether_dhost, - (u_char *)&ie->mcast_addrs[i])) { - if (*to_bpf) - *to_bpf = 1; + (u_char *)&ie->mcast_addrs[i])) return (1); - } } - return (1); - - case IFF_ALLMULTI | IFF_PROMISC: - /* - * Acting as a multicast router, and BPF running at the same - * time. Whew! (Hope this is a fast machine...) - */ - *to_bpf = (ie->arpcom.ac_if.if_bpf != 0); - /* We want to see multicasts. */ - if (eh->ether_dhost[0] & 1) - return (1); - - /* We want to see our own packets */ - if (ether_equal(eh->ether_dhost, ie->arpcom.ac_enaddr)) - return (1); + return (0); + } - /* Anything else goes to BPF but nothing else. */ - if (*to_bpf) - *to_bpf = 2; + /* Always accept packets when in promiscuous mode */ + if ((ie->promisc & IFF_PROMISC) != 0) return (1); - default: - /* - * Only accept unicast packets destined for us, or - * multicasts for groups that we belong to. For now, we - * assume that the '586 will only return packets that we - * asked it for. This isn't strictly true (it uses hashing - * for the multicast filter), but it will do in this case, - * and we want to get out of here as quickly as possible. - */ - *to_bpf = (ie->arpcom.ac_if.if_bpf != 0); + /* Always accept packets directed at us */ + if (ether_equal(eh->ether_dhost, ie->arpcom.ac_enaddr)) return (1); - } - return (0); + + /* Must have IFF_ALLMULTI but not IFF_PROMISC set. The chip is + actually in promiscuous mode, so discard unicast packets. */ + return((eh->ether_dhost[0] & 1) != 0); } /* @@ -1177,8 +1121,7 @@ ie_packet_len(int unit, struct ie_softc * ie) * operation considerably. (Provided that it works, of course.) */ static __inline int -ieget(int unit, struct ie_softc *ie, struct mbuf **mp, - struct ether_header *ehp, int *to_bpf) +ieget(int unit, struct ie_softc *ie, struct mbuf **mp, struct ether_header *ehp) { struct mbuf *m, *top, **mymp; int i; @@ -1205,7 +1148,7 @@ ieget(int unit, struct ie_softc *ie, struct mbuf **mp, * This is only a consideration when FILTER is defined; i.e., when * we are either running BPF or doing multicasting. */ - if (!check_eh(ie, ehp, to_bpf)) { + if (!check_eh(ie, ehp)) { ie_drop_packet_buffer(unit, ie); ie->arpcom.ac_if.if_ierrors--; /* just this case, it's not an * error @@ -1356,8 +1299,6 @@ ie_readframe(int unit, struct ie_softc *ie, int num/* frame number to read */) struct mbuf *m = 0; struct ether_header eh; - int bpf_gets_it = 0; - bcopy((v_caddr_t) (ie->rframes[num]), &rfd, sizeof(struct ie_recv_frame_desc)); @@ -1372,7 +1313,7 @@ ie_readframe(int unit, struct ie_softc *ie, int num/* frame number to read */) ie->rfhead = (ie->rfhead + 1) % ie->nframes; if (rfd.ie_fd_status & IE_FD_OK) { - if (ieget(unit, ie, &m, &eh, &bpf_gets_it)) { + if (ieget(unit, ie, &m, &eh)) { ie->arpcom.ac_if.if_ierrors++; /* this counts as an * error */ return; @@ -1391,45 +1332,6 @@ ie_readframe(int unit, struct ie_softc *ie, int num/* frame number to read */) if (!m) return; - if (last_not_for_us) { - m_freem(last_not_for_us); - last_not_for_us = 0; - } - /* - * Check for a BPF filter; if so, hand it up. Note that we have to - * stick an extra mbuf up front, because bpf_mtap expects to have - * the ether header at the front. It doesn't matter that this - * results in an ill-formatted mbuf chain, since BPF just looks at - * the data. (It doesn't try to free the mbuf, tho' it will make a - * copy for tcpdump.) - */ - if (bpf_gets_it) { - struct mbuf m0; - - m0.m_len = sizeof eh; - m0.m_data = (caddr_t)&eh; - m0.m_next = m; - - /* Pass it up */ - bpf_mtap(&ie->arpcom.ac_if, &m0); - } - /* - * A signal passed up from the filtering code indicating that the - * packet is intended for BPF but not for the protocol machinery. We - * can save a few cycles by not handing it off to them. - */ - if (bpf_gets_it == 2) { - last_not_for_us = m; - return; - } - /* - * In here there used to be code to check destination addresses upon - * receipt of a packet. We have deleted that code, and replaced it - * with code to check the address much earlier in the cycle, before - * copying the data in; this saves us valuable cycles when operating - * as a multicast router or when using BPF. - */ - /* * Finally pass this packet up to higher layers. */ diff --git a/sys/dev/sf/if_sf.c b/sys/dev/sf/if_sf.c index 5fb33a9..19432dc 100644 --- a/sys/dev/sf/if_sf.c +++ b/sys/dev/sf/if_sf.c @@ -1019,20 +1019,9 @@ static void sf_rxeof(sc) eh = mtod(m, struct ether_header *); ifp->if_ipackets++; - if (ifp->if_bpf) { - bpf_mtap(ifp, m); - if (ifp->if_flags & IFF_PROMISC && - (bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr, - ETHER_ADDR_LEN) && !(eh->ether_dhost[0] & 1))) { - m_freem(m); - continue; - } - } - /* Remove header from mbuf and pass it on. */ m_adj(m, sizeof(struct ether_header)); ether_input(ifp, eh, m); - } csr_write_4(sc, SF_CQ_CONSIDX, diff --git a/sys/dev/sk/if_sk.c b/sys/dev/sk/if_sk.c index ed923fa..4246b2a 100644 --- a/sys/dev/sk/if_sk.c +++ b/sys/dev/sk/if_sk.c @@ -1654,16 +1654,6 @@ static void sk_rxeof(sc_if) ifp->if_ipackets++; eh = mtod(m, struct ether_header *); - if (ifp->if_bpf) { - bpf_mtap(ifp, m); - if (ifp->if_flags & IFF_PROMISC && - (bcmp(eh->ether_dhost, sc_if->arpcom.ac_enaddr, - ETHER_ADDR_LEN) && !(eh->ether_dhost[0] & 1))) { - m_freem(m); - continue; - } - } - /* Remove header from mbuf and pass it on. */ m_adj(m, sizeof(struct ether_header)); ether_input(ifp, eh, m); diff --git a/sys/dev/sn/if_sn.c b/sys/dev/sn/if_sn.c index 9e65f3b..860d3ef 100644 --- a/sys/dev/sn/if_sn.c +++ b/sys/dev/sn/if_sn.c @@ -1096,26 +1096,6 @@ read_another: } ++sc->arpcom.ac_if.if_ipackets; - if (sc->arpcom.ac_if.if_bpf) - { - bpf_mtap(&sc->arpcom.ac_if, m); - - /* - * Note that the interface cannot be in promiscuous mode if - * there are no BPF listeners. And if we are in promiscuous - * mode, we have to check if this packet is really ours. - */ - if ((sc->arpcom.ac_if.if_flags & IFF_PROMISC) && - (eh->ether_dhost[0] & 1) == 0 && - bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr, - sizeof(eh->ether_dhost)) != 0 && - bcmp(eh->ether_dhost, etherbroadcastaddr, - sizeof(eh->ether_dhost)) != 0) { - m_freem(m); - goto out; - } - } - /* * Remove link layer addresses and whatnot. */ diff --git a/sys/dev/ti/if_ti.c b/sys/dev/ti/if_ti.c index de9c3bd..fe4c861 100644 --- a/sys/dev/ti/if_ti.c +++ b/sys/dev/ti/if_ti.c @@ -1851,23 +1851,6 @@ static void ti_rxeof(sc) eh = mtod(m, struct ether_header *); m->m_pkthdr.rcvif = ifp; - /* - * Handle BPF listeners. Let the BPF user see the packet, but - * don't pass it up to the ether_input() layer unless it's - * a broadcast packet, multicast packet, matches our ethernet - * address or the interface is in promiscuous mode. - */ - if (ifp->if_bpf) { - bpf_mtap(ifp, m); - if (ifp->if_flags & IFF_PROMISC && - (bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr, - ETHER_ADDR_LEN) && - (eh->ether_dhost[0] & 1) == 0)) { - m_freem(m); - continue; - } - } - /* Remove header from mbuf and pass it on. */ m_adj(m, sizeof(struct ether_header)); diff --git a/sys/dev/tx/if_tx.c b/sys/dev/tx/if_tx.c index 0f37ca3..d575bca 100644 --- a/sys/dev/tx/if_tx.c +++ b/sys/dev/tx/if_tx.c @@ -52,7 +52,6 @@ #include <sys/queue.h> #if defined(__FreeBSD__) -#include "opt_bdg.h" #define NBPFILTER 1 #include <net/if.h> @@ -62,10 +61,6 @@ #include <net/bpf.h> -#ifdef BRIDGE -#include <net/bridge.h> -#endif - #include <vm/vm.h> /* for vtophys */ #include <vm/pmap.h> /* for vtophys */ #include <machine/clock.h> /* for DELAY */ @@ -932,51 +927,6 @@ epic_rx_done(sc) bpf_mtap( EPIC_BPFTAP_ARG(&sc->sc_if), m ); #endif /* NBPFILTER > 0 */ -#ifdef BRIDGE - if (do_bridge) { - struct ifnet *bdg_ifp ; - bdg_ifp = bridge_in(m); - if (bdg_ifp == BDG_DROP) { - if (m) - m_free(m); - continue; /* and drop */ - } - if (bdg_ifp != BDG_LOCAL) - bdg_forward(&m, bdg_ifp); - if (bdg_ifp != BDG_LOCAL && bdg_ifp != BDG_BCAST && - bdg_ifp != BDG_MCAST) { - if (m) - m_free(m); - continue; /* and drop */ - } - /* all others accepted locally */ - } -#endif - -#if defined (__FreeBSD__) - /* - * This deserves explanation - * If the bridge is _on_, then the following check - * must not be done because occasionally the bridge - * gets packets that are local but have the ethernet - * address of one of the other interfaces. - * - * But if the bridge is off, then we have to drop - * stuff that came in just via bpf. - * - * In OpenBSD such filter stands in ether_input. (?) - */ - /* Accept only our packets, broadcasts and multicasts */ -#ifdef BRIDGE - if (do_bridge) -#endif - if ((eh->ether_dhost[0] & 1) == 0 && - bcmp(eh->ether_dhost,sc->sc_macaddr,ETHER_ADDR_LEN)){ - m_freem(m); - continue; - } -#endif - /* Second mbuf holds packet ifself */ m->m_pkthdr.len = m->m_len = len - sizeof(struct ether_header); m->m_data += sizeof( struct ether_header ); diff --git a/sys/dev/usb/usb_ethersubr.c b/sys/dev/usb/usb_ethersubr.c index c712bd6..da2328c 100644 --- a/sys/dev/usb/usb_ethersubr.c +++ b/sys/dev/usb/usb_ethersubr.c @@ -96,26 +96,8 @@ Static void usbintr() q = (struct usb_qdat *)m->m_pkthdr.rcvif; ifp = q->ifp; m->m_pkthdr.rcvif = ifp; - /* - * Handle BPF listeners. Let the BPF user see the packet, but - * don't pass it up to the ether_input() layer unless it's - * a broadcast packet, multicast packet, matches our ethernet - * address or the interface is in promiscuous mode. - */ - if (ifp->if_bpf) { - bpf_mtap(ifp, m); - if (ifp->if_flags & IFF_PROMISC && - (bcmp(eh->ether_dhost, - ((struct arpcom *)ifp->if_softc)->ac_enaddr, - ETHER_ADDR_LEN) && !(eh->ether_dhost[0] & 1))) { - m_freem(m); - goto done; - } - } - m_adj(m, sizeof(struct ether_header)); ether_input(ifp, eh, m); -done: /* Re-arm the receiver */ (*q->if_rxstart)(ifp); diff --git a/sys/dev/vr/if_vr.c b/sys/dev/vr/if_vr.c index 6e1ed0e..c28c207 100644 --- a/sys/dev/vr/if_vr.c +++ b/sys/dev/vr/if_vr.c @@ -75,11 +75,6 @@ #include <net/bpf.h> -#include "opt_bdg.h" -#ifdef BRIDGE -#include <net/bridge.h> -#endif /* BRIDGE */ - #include <vm/vm.h> /* for vtophys */ #include <vm/pmap.h> /* for vtophys */ #include <machine/clock.h> /* for DELAY */ @@ -1045,37 +1040,6 @@ static void vr_rxeof(sc) ifp->if_ipackets++; eh = mtod(m, struct ether_header *); - /* - * Handle BPF listeners. Let the BPF user see the packet, but - * don't pass it up to the ether_input() layer unless it's - * a broadcast packet, multicast packet, matches our ethernet - * address or the interface is in promiscuous mode. - */ - if (ifp->if_bpf) { - bpf_mtap(ifp, m); - if (ifp->if_flags & IFF_PROMISC && - (bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr, - ETHER_ADDR_LEN) && - (eh->ether_dhost[0] & 1) == 0)) { - m_freem(m); - continue; - } - } - -#ifdef BRIDGE - if (do_bridge) { - struct ifnet *bdg_ifp; - bdg_ifp = bridge_in(m); - if (bdg_ifp != BDG_LOCAL && bdg_ifp != BDG_DROP) - bdg_forward(&m, bdg_ifp); - if (((bdg_ifp != BDG_LOCAL) && (bdg_ifp != BDG_BCAST) && - (bdg_ifp != BDG_MCAST)) || bdg_ifp == BDG_DROP) { - m_freem(m); - continue; - } - } -#endif /* BRIDGE */ - /* Remove header from mbuf and pass it on. */ m_adj(m, sizeof(struct ether_header)); ether_input(ifp, eh, m); diff --git a/sys/dev/vx/if_vx.c b/sys/dev/vx/if_vx.c index 0aac072..33f376f 100644 --- a/sys/dev/vx/if_vx.c +++ b/sys/dev/vx/if_vx.c @@ -739,26 +739,17 @@ again: eh = mtod(m, struct ether_header *); /* - * Check if there's a BPF listener on this interface. - * If so, hand off the raw packet to BPF. - */ - if (sc->arpcom.ac_if.if_bpf) { - bpf_mtap(&sc->arpcom.ac_if, m); - } - - /* * XXX: Some cards seem to be in promiscous mode all the time. * we need to make sure we only get our own stuff always. * bleah! */ - if ((eh->ether_dhost[0] & 1) == 0 && /* !mcast and !bcast */ - bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr, - sizeof(eh->ether_dhost)) != 0) { + if ((eh->ether_dhost[0] & 1) == 0 /* !mcast and !bcast */ + && bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr, ETHER_ADDR_LEN) != 0) { m_freem(m); - return; + return; } - /* We assume the header fit entirely in one mbuf. */ + m_adj(m, sizeof(struct ether_header)); ether_input(ifp, eh, m); diff --git a/sys/dev/wi/if_wi.c b/sys/dev/wi/if_wi.c index eb8053b..441beaf 100644 --- a/sys/dev/wi/if_wi.c +++ b/sys/dev/wi/if_wi.c @@ -430,25 +430,12 @@ static void wi_rxeof(sc) ifp->if_ipackets++; - /* Handle BPF listeners. */ - if (ifp->if_bpf) { - bpf_mtap(ifp, m); - if (ifp->if_flags & IFF_PROMISC && - (bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr, - ETHER_ADDR_LEN) && (eh->ether_dhost[0] & 1) == 0)) { - m_freem(m); - return; - } - } - /* Receive packet. */ m_adj(m, sizeof(struct ether_header)); #ifdef WICACHE wi_cache_store(sc, eh, m, rx_frame.wi_q_info); #endif ether_input(ifp, eh, m); - - return; } static void wi_txeof(sc, status) diff --git a/sys/dev/wl/if_wl.c b/sys/dev/wl/if_wl.c index 6111b8d..44f2849 100644 --- a/sys/dev/wl/if_wl.c +++ b/sys/dev/wl/if_wl.c @@ -1075,27 +1075,10 @@ wlread(int unit, u_short fd_p) m->m_pkthdr.len = clen; /* - * Check if there's a BPF listener on this interface. If so, hand off - * the raw packet to bpf. - */ - if (ifp->if_bpf) { - /* bpf assumes header is in mbufs. It isn't. We can - * fool it without allocating memory as follows. - * Trick borrowed from if_ie.c - */ - struct mbuf m0; - m0.m_len = sizeof eh; - m0.m_data = (caddr_t) &eh; - m0.m_next = m; - - bpf_mtap(ifp, &m0); - - } - /* * If hw is in promiscuous mode (note that I said hardware, not if * IFF_PROMISC is set in ifnet flags), then if this is a unicast - * packet and the MAC dst is not us, drop it. This check was formerly - * inside the bpf if, above, but IFF_MULTI causes hw promisc without + * packet and the MAC dst is not us, drop it. This check in normally + * inside ether_input(), but IFF_MULTI causes hw promisc without * a bpf listener, so this is wrong. * Greg Troxel <gdt@ir.bbn.com>, 1998-08-07 */ diff --git a/sys/dev/xe/if_xe.c b/sys/dev/xe/if_xe.c index c78e430..d5160ed 100644 --- a/sys/dev/xe/if_xe.c +++ b/sys/dev/xe/if_xe.c @@ -1050,29 +1050,7 @@ xe_intr(void *xscp) bus_space_read_multi_2(scp->bst, scp->bsh, XE_EDP, (u_int16_t *) ehp, len >> 1); - /* - * Check if there's a BPF listener on this interface. If so, hand - * off the raw packet to bpf. - */ - if (ifp->if_bpf) { -#if XE_DEBUG > 1 - device_printf(scp->dev, "passing input packet to BPF\n"); -#endif - bpf_mtap(ifp, mbp); - - /* - * Note that the interface cannot be in promiscuous mode if there - * are no BPF listeners. And if we are in promiscuous mode, we - * have to check if this packet is really ours. - */ - if ((ifp->if_flags & IFF_PROMISC) && - bcmp(ehp->ether_dhost, scp->arpcom.ac_enaddr, sizeof(ehp->ether_dhost)) != 0 && - (rsr & XE_RSR_PHYS_PACKET)) { - m_freem(mbp); - mbp = NULL; - } - } - + /* Deliver packet to upper layers */ if (mbp != NULL) { mbp->m_pkthdr.len = mbp->m_len = len - ETHER_HDR_LEN; mbp->m_data += ETHER_HDR_LEN; /* Strip off Ethernet header */ |