summaryrefslogtreecommitdiffstats
path: root/sys/dev/ed
diff options
context:
space:
mode:
authorarchie <archie@FreeBSD.org>2000-05-14 02:18:43 +0000
committerarchie <archie@FreeBSD.org>2000-05-14 02:18:43 +0000
commitfa21035b4e2f11d2c8f90174690853600b670e2d (patch)
tree9afb8dacfff6d7607064d8aa2bbf2da5069e8be6 /sys/dev/ed
parentd066b073153b986a54fd18a31d6bcc5d697933a2 (diff)
downloadFreeBSD-src-fa21035b4e2f11d2c8f90174690853600b670e2d.zip
FreeBSD-src-fa21035b4e2f11d2c8f90174690853600b670e2d.tar.gz
Move code to handle BPF and bridging for incoming Ethernet packets out
of the individual drivers and into the common routine ether_input(). Also, remove the (incomplete) hack for matching ethernet headers in the ip_fw code. The good news: net result of 1016 lines removed, and this should make bridging now work with *all* Ethernet drivers. The bad news: it's nearly impossible to test every driver, especially for bridging, and I was unable to get much testing help on the mailing lists. Reviewed by: freebsd-net
Diffstat (limited to 'sys/dev/ed')
-rw-r--r--sys/dev/ed/if_ed.c66
1 files changed, 13 insertions, 53 deletions
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;
}
/*
OpenPOWER on IntegriCloud