diff options
-rw-r--r-- | sys/dev/ic/re.c | 6 | ||||
-rw-r--r-- | sys/dev/pci/if_bge.c | 6 | ||||
-rw-r--r-- | sys/dev/pci/if_bnx.c | 7 | ||||
-rw-r--r-- | sys/dev/pci/if_em.c | 7 | ||||
-rw-r--r-- | sys/dev/pci/if_ix.c | 7 | ||||
-rw-r--r-- | sys/dev/pci/if_ixgb.c | 6 | ||||
-rw-r--r-- | sys/dev/pci/if_jme.c | 7 | ||||
-rw-r--r-- | sys/dev/pci/if_nfe.c | 6 | ||||
-rw-r--r-- | sys/dev/pci/if_nge.c | 6 | ||||
-rw-r--r-- | sys/dev/pci/if_stge.c | 6 | ||||
-rw-r--r-- | sys/dev/pci/if_ti.c | 6 | ||||
-rw-r--r-- | sys/dev/pci/if_txp.c | 6 | ||||
-rw-r--r-- | sys/dev/pci/if_vge.c | 6 | ||||
-rw-r--r-- | sys/dev/pci/if_xge.c | 6 | ||||
-rw-r--r-- | sys/net/bpf.c | 51 | ||||
-rw-r--r-- | sys/net/bpf.h | 3 |
16 files changed, 98 insertions, 44 deletions
diff --git a/sys/dev/ic/re.c b/sys/dev/ic/re.c index b6210caea42..32fcda48fb2 100644 --- a/sys/dev/ic/re.c +++ b/sys/dev/ic/re.c @@ -1,4 +1,4 @@ -/* $OpenBSD: re.c,v 1.98 2008/11/08 06:52:49 brad Exp $ */ +/* $OpenBSD: re.c,v 1.99 2008/11/09 15:08:25 naddy Exp $ */ /* $FreeBSD: if_re.c,v 1.31 2004/09/04 07:54:05 ru Exp $ */ /* * Copyright (c) 1997, 1998-2003 @@ -1468,7 +1468,7 @@ re_rxeof(struct rl_softc *sc) #if NBPFILTER > 0 if (ifp->if_bpf) - bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_IN); + bpf_mtap_ether(ifp->if_bpf, m, BPF_DIRECTION_IN); #endif ether_input_mbuf(ifp, m); } @@ -1890,7 +1890,7 @@ re_start(struct ifnet *ifp) * to him. */ if (ifp->if_bpf) - bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_OUT); + bpf_mtap_ether(ifp->if_bpf, m, BPF_DIRECTION_OUT); #endif } diff --git a/sys/dev/pci/if_bge.c b/sys/dev/pci/if_bge.c index 98bef6d6799..dd768e6507d 100644 --- a/sys/dev/pci/if_bge.c +++ b/sys/dev/pci/if_bge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bge.c,v 1.254 2008/11/08 07:37:07 deraadt Exp $ */ +/* $OpenBSD: if_bge.c,v 1.255 2008/11/09 15:08:26 naddy Exp $ */ /* * Copyright (c) 2001 Wind River Systems @@ -2535,7 +2535,7 @@ bge_rxeof(struct bge_softc *sc) * Handle BPF listeners. Let the BPF user see the packet. */ if (ifp->if_bpf) - bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_IN); + bpf_mtap_ether(ifp->if_bpf, m, BPF_DIRECTION_IN); #endif #ifdef BGE_CHECKSUM @@ -3028,7 +3028,7 @@ bge_start(struct ifnet *ifp) * to him. */ if (ifp->if_bpf) - bpf_mtap(ifp->if_bpf, m_head, BPF_DIRECTION_OUT); + bpf_mtap_ether(ifp->if_bpf, m_head, BPF_DIRECTION_OUT); #endif } if (pkts == 0) diff --git a/sys/dev/pci/if_bnx.c b/sys/dev/pci/if_bnx.c index e3237974cfa..22008bcb765 100644 --- a/sys/dev/pci/if_bnx.c +++ b/sys/dev/pci/if_bnx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bnx.c,v 1.69 2008/10/19 23:16:38 brad Exp $ */ +/* $OpenBSD: if_bnx.c,v 1.70 2008/11/09 15:08:26 naddy Exp $ */ /*- * Copyright (c) 2006 Broadcom Corporation @@ -4047,7 +4047,8 @@ bnx_rx_int_next_rx: * user see the packet. */ if (ifp->if_bpf) - bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_IN); + bpf_mtap_ether(ifp->if_bpf, m, + BPF_DIRECTION_IN); #endif DBPRINT(sc, BNX_VERBOSE_RECV, @@ -4546,7 +4547,7 @@ bnx_start(struct ifnet *ifp) #if NBPFILTER > 0 /* Send a copy of the frame to any BPF listeners. */ if (ifp->if_bpf) - bpf_mtap(ifp->if_bpf, m_head, BPF_DIRECTION_OUT); + bpf_mtap_ether(ifp->if_bpf, m_head, BPF_DIRECTION_OUT); #endif } diff --git a/sys/dev/pci/if_em.c b/sys/dev/pci/if_em.c index 51f6daf789c..c6fb6d456c1 100644 --- a/sys/dev/pci/if_em.c +++ b/sys/dev/pci/if_em.c @@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE. ***************************************************************************/ -/* $OpenBSD: if_em.c,v 1.194 2008/10/28 05:43:11 brad Exp $ */ +/* $OpenBSD: if_em.c,v 1.195 2008/11/09 15:08:26 naddy Exp $ */ /* $FreeBSD: if_em.c,v 1.46 2004/09/29 18:28:28 mlaier Exp $ */ #include <dev/pci/if_em.h> @@ -493,7 +493,7 @@ em_start(struct ifnet *ifp) #if NBPFILTER > 0 /* Send a copy of the frame to the BPF listener */ if (ifp->if_bpf) - bpf_mtap(ifp->if_bpf, m_head, BPF_DIRECTION_OUT); + bpf_mtap_ether(ifp->if_bpf, m_head, BPF_DIRECTION_OUT); #endif /* Set timeout in case hardware has problems transmitting */ @@ -2769,7 +2769,8 @@ discard: * user see the packet. */ if (ifp->if_bpf) - bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_IN); + bpf_mtap_ether(ifp->if_bpf, m, + BPF_DIRECTION_IN); #endif ether_input_mbuf(ifp, m); diff --git a/sys/dev/pci/if_ix.c b/sys/dev/pci/if_ix.c index d33859e00e9..c5626db5f80 100644 --- a/sys/dev/pci/if_ix.c +++ b/sys/dev/pci/if_ix.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ix.c,v 1.13 2008/10/28 05:39:18 brad Exp $ */ +/* $OpenBSD: if_ix.c,v 1.14 2008/11/09 15:08:26 naddy Exp $ */ /****************************************************************************** @@ -362,7 +362,7 @@ ixgbe_start_locked(struct tx_ring *txr, struct ifnet * ifp) #if NBPFILTER > 0 if (ifp->if_bpf) - bpf_mtap(ifp->if_bpf, m_head, BPF_DIRECTION_OUT); + bpf_mtap_ether(ifp->if_bpf, m_head, BPF_DIRECTION_OUT); #endif /* Set timeout in case hardware has problems transmitting */ @@ -2813,7 +2813,8 @@ discard: rxr->next_to_check = i; #if NBPFILTER > 0 if (ifp->if_bpf) - bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_IN); + bpf_mtap_ether(ifp->if_bpf, m, + BPF_DIRECTION_IN); #endif ether_input_mbuf(ifp, m); i = rxr->next_to_check; diff --git a/sys/dev/pci/if_ixgb.c b/sys/dev/pci/if_ixgb.c index 7fb01a52399..baac695eca5 100644 --- a/sys/dev/pci/if_ixgb.c +++ b/sys/dev/pci/if_ixgb.c @@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE. ***************************************************************************/ -/* $OpenBSD: if_ixgb.c,v 1.50 2008/10/28 05:43:11 brad Exp $ */ +/* $OpenBSD: if_ixgb.c,v 1.51 2008/11/09 15:08:26 naddy Exp $ */ #include <dev/pci/if_ixgb.h> @@ -331,7 +331,7 @@ ixgb_start(struct ifnet *ifp) #if NBPFILTER > 0 /* Send a copy of the frame to the BPF listener */ if (ifp->if_bpf) - bpf_mtap(ifp->if_bpf, m_head, BPF_DIRECTION_OUT); + bpf_mtap_ether(ifp->if_bpf, m_head, BPF_DIRECTION_OUT); #endif /* Set timeout in case hardware has problems transmitting */ @@ -1830,7 +1830,7 @@ ixgb_rxeof(struct ixgb_softc *sc, int count) * user see the packet. */ if (ifp->if_bpf) - bpf_mtap(ifp->if_bpf, sc->fmp, + bpf_mtap_ether(ifp->if_bpf, sc->fmp, BPF_DIRECTION_IN); #endif diff --git a/sys/dev/pci/if_jme.c b/sys/dev/pci/if_jme.c index bd27aa36131..b2c0707d444 100644 --- a/sys/dev/pci/if_jme.c +++ b/sys/dev/pci/if_jme.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_jme.c,v 1.12 2008/10/29 01:55:53 brad Exp $ */ +/* $OpenBSD: if_jme.c,v 1.13 2008/11/09 15:08:26 naddy Exp $ */ /*- * Copyright (c) 2008, Pyun YongHyeon <yongari@FreeBSD.org> * All rights reserved. @@ -1242,7 +1242,7 @@ jme_start(struct ifnet *ifp) * to him. */ if (ifp->if_bpf != NULL) - bpf_mtap(ifp->if_bpf, m_head, BPF_DIRECTION_OUT); + bpf_mtap_ether(ifp->if_bpf, m_head, BPF_DIRECTION_OUT); #endif } @@ -1715,7 +1715,8 @@ jme_rxpkt(struct jme_softc *sc) #if NBPFILTER > 0 if (ifp->if_bpf) - bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_IN); + bpf_mtap_ether(ifp->if_bpf, m, + BPF_DIRECTION_IN); #endif ifp->if_ipackets++; diff --git a/sys/dev/pci/if_nfe.c b/sys/dev/pci/if_nfe.c index 6a3234b0797..133f0b7ed9d 100644 --- a/sys/dev/pci/if_nfe.c +++ b/sys/dev/pci/if_nfe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_nfe.c,v 1.85 2008/10/28 05:53:20 brad Exp $ */ +/* $OpenBSD: if_nfe.c,v 1.86 2008/11/09 15:08:26 naddy Exp $ */ /*- * Copyright (c) 2006, 2007 Damien Bergamini <damien.bergamini@free.fr> @@ -813,7 +813,7 @@ nfe_rxeof(struct nfe_softc *sc) #if NBPFILTER > 0 if (ifp->if_bpf) - bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_IN); + bpf_mtap_ether(ifp->if_bpf, m, BPF_DIRECTION_IN); #endif ifp->if_ipackets++; ether_input_mbuf(ifp, m); @@ -1048,7 +1048,7 @@ nfe_start(struct ifnet *ifp) #if NBPFILTER > 0 if (ifp->if_bpf != NULL) - bpf_mtap(ifp->if_bpf, m0, BPF_DIRECTION_OUT); + bpf_mtap_ether(ifp->if_bpf, m0, BPF_DIRECTION_OUT); #endif } if (sc->txq.cur == old) /* nothing sent */ diff --git a/sys/dev/pci/if_nge.c b/sys/dev/pci/if_nge.c index fe5baf17164..7da2a2d5ea5 100644 --- a/sys/dev/pci/if_nge.c +++ b/sys/dev/pci/if_nge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_nge.c,v 1.65 2008/10/28 22:45:20 brad Exp $ */ +/* $OpenBSD: if_nge.c,v 1.66 2008/11/09 15:08:26 naddy Exp $ */ /* * Copyright (c) 2001 Wind River Systems * Copyright (c) 1997, 1998, 1999, 2000, 2001 @@ -1357,7 +1357,7 @@ nge_rxeof(sc) * Handle BPF listeners. Let the BPF user see the packet. */ if (ifp->if_bpf) - bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_IN); + bpf_mtap_ether(ifp->if_bpf, m, BPF_DIRECTION_IN); #endif /* Do IP checksum checking. */ @@ -1709,7 +1709,7 @@ nge_start(ifp) * to him. */ if (ifp->if_bpf) - bpf_mtap(ifp->if_bpf, m_head, BPF_DIRECTION_OUT); + bpf_mtap_ether(ifp->if_bpf, m_head, BPF_DIRECTION_OUT); #endif } if (pkts == 0) diff --git a/sys/dev/pci/if_stge.c b/sys/dev/pci/if_stge.c index 8d6a7154c21..91d27001ef2 100644 --- a/sys/dev/pci/if_stge.c +++ b/sys/dev/pci/if_stge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_stge.c,v 1.43 2008/10/22 22:57:12 brad Exp $ */ +/* $OpenBSD: if_stge.c,v 1.44 2008/11/09 15:08:26 naddy Exp $ */ /* $NetBSD: if_stge.c,v 1.27 2005/05/16 21:35:32 bouyer Exp $ */ /*- @@ -644,7 +644,7 @@ stge_start(struct ifnet *ifp) * Pass the packet to any BPF listeners. */ if (ifp->if_bpf) - bpf_mtap(ifp->if_bpf, m0, BPF_DIRECTION_OUT); + bpf_mtap_ether(ifp->if_bpf, m0, BPF_DIRECTION_OUT); #endif /* NBPFILTER > 0 */ } @@ -1068,7 +1068,7 @@ stge_rxintr(struct stge_softc *sc) * pass if up the stack if it's for us. */ if (ifp->if_bpf) - bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_IN); + bpf_mtap_ether(ifp->if_bpf, m, BPF_DIRECTION_IN); #endif /* NBPFILTER > 0 */ /* Pass it on. */ diff --git a/sys/dev/pci/if_ti.c b/sys/dev/pci/if_ti.c index 499a8bfc1c8..c73367510cf 100644 --- a/sys/dev/pci/if_ti.c +++ b/sys/dev/pci/if_ti.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ti.c,v 1.92 2008/10/20 01:02:52 brad Exp $ */ +/* $OpenBSD: if_ti.c,v 1.93 2008/11/09 15:08:26 naddy Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -1862,7 +1862,7 @@ ti_rxeof(struct ti_softc *sc) * Handle BPF listeners. Let the BPF user see the packet. */ if (ifp->if_bpf) - bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_IN); + bpf_mtap_ether(ifp->if_bpf, m, BPF_DIRECTION_IN); #endif if ((cur_rx->ti_ip_cksum ^ 0xffff) == 0) @@ -2247,7 +2247,7 @@ ti_start(struct ifnet *ifp) */ #if NBPFILTER > 0 if (ifp->if_bpf) - bpf_mtap(ifp->if_bpf, m_head, BPF_DIRECTION_OUT); + bpf_mtap_ether(ifp->if_bpf, m_head, BPF_DIRECTION_OUT); #endif } if (pkts == 0) diff --git a/sys/dev/pci/if_txp.c b/sys/dev/pci/if_txp.c index 343bb2c6dc1..326324b426a 100644 --- a/sys/dev/pci/if_txp.c +++ b/sys/dev/pci/if_txp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_txp.c,v 1.97 2008/10/16 19:18:03 naddy Exp $ */ +/* $OpenBSD: if_txp.c,v 1.98 2008/11/09 15:08:26 naddy Exp $ */ /* * Copyright (c) 2001 @@ -690,7 +690,7 @@ txp_rx_reclaim(struct txp_softc *sc, struct txp_rx_ring *r, * Handle BPF listeners. Let the BPF user see the packet. */ if (ifp->if_bpf) - bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_IN); + bpf_mtap_ether(ifp->if_bpf, m, BPF_DIRECTION_IN); #endif if (rxd->rx_stat & htole32(RX_STAT_IPCKSUMBAD)) @@ -1454,7 +1454,7 @@ txp_start(struct ifnet *ifp) #if NBPFILTER > 0 if (ifp->if_bpf) - bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_OUT); + bpf_mtap_ether(ifp->if_bpf, m, BPF_DIRECTION_OUT); #endif txd->tx_flags |= TX_FLAGS_VALID; diff --git a/sys/dev/pci/if_vge.c b/sys/dev/pci/if_vge.c index 0e845244a0e..ed280d7b627 100644 --- a/sys/dev/pci/if_vge.c +++ b/sys/dev/pci/if_vge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vge.c,v 1.41 2008/10/22 05:31:29 brad Exp $ */ +/* $OpenBSD: if_vge.c,v 1.42 2008/11/09 15:08:26 naddy Exp $ */ /* $FreeBSD: if_vge.c,v 1.3 2004/09/11 22:13:25 wpaul Exp $ */ /* * Copyright (c) 2004 @@ -1109,7 +1109,7 @@ vge_rxeof(struct vge_softc *sc) #if NBPFILTER > 0 if (ifp->if_bpf) - bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_IN); + bpf_mtap_ether(ifp->if_bpf, m, BPF_DIRECTION_IN); #endif ether_input_mbuf(ifp, m); @@ -1438,7 +1438,7 @@ vge_start(struct ifnet *ifp) */ #if NBPFILTER > 0 if (ifp->if_bpf) - bpf_mtap(ifp->if_bpf, m_head, BPF_DIRECTION_OUT); + bpf_mtap_ether(ifp->if_bpf, m_head, BPF_DIRECTION_OUT); #endif if (vge_encap(sc, m_head, idx)) { diff --git a/sys/dev/pci/if_xge.c b/sys/dev/pci/if_xge.c index e074a7eaa4d..7bef2d3296b 100644 --- a/sys/dev/pci/if_xge.c +++ b/sys/dev/pci/if_xge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_xge.c,v 1.47 2008/10/21 00:26:40 brad Exp $ */ +/* $OpenBSD: if_xge.c,v 1.48 2008/11/09 15:08:26 naddy Exp $ */ /* $NetBSD: if_xge.c,v 1.1 2005/09/09 10:30:27 ragge Exp $ */ /* @@ -952,7 +952,7 @@ xge_intr(void *pv) #if NBPFILTER > 0 if (ifp->if_bpf) - bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_IN); + bpf_mtap_ether(ifp->if_bpf, m, BPF_DIRECTION_IN); #endif /* NBPFILTER > 0 */ ether_input_mbuf(ifp, m); @@ -1178,7 +1178,7 @@ xge_start(struct ifnet *ifp) #if NBPFILTER > 0 if (ifp->if_bpf) - bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_OUT); + bpf_mtap_ether(ifp->if_bpf, m, BPF_DIRECTION_OUT); #endif /* NBPFILTER > 0 */ sc->sc_nexttx = NEXTTX(nexttx); diff --git a/sys/net/bpf.c b/sys/net/bpf.c index 8f1781bf447..0172c5d8f85 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bpf.c,v 1.69 2008/09/17 20:10:37 chl Exp $ */ +/* $OpenBSD: bpf.c,v 1.70 2008/11/09 15:08:26 naddy Exp $ */ /* $NetBSD: bpf.c,v 1.33 1997/02/21 23:59:35 thorpej Exp $ */ /* @@ -59,6 +59,11 @@ #include <netinet/in.h> #include <netinet/if_ether.h> +#include "vlan.h" +#if NVLAN > 0 +#include <net/if_vlan_var.h> +#endif + #define BPF_BUFSIZE 32768 #define PRINET 26 /* interruptible */ @@ -1237,6 +1242,50 @@ bpf_mtap_af(caddr_t arg, u_int32_t af, struct mbuf *m, u_int direction) } /* + * Incoming linkage from device drivers, where we have a mbuf chain + * but need to prepend a VLAN encapsulation header. + * + * Con up a minimal dummy header to pacify bpf. Allocate (only) a + * struct m_hdr on the stack. This is safe as bpf only reads from the + * fields in this header that we initialize, and will not try to free + * it or keep a pointer to it. + */ +void +bpf_mtap_ether(caddr_t arg, struct mbuf *m, u_int direction) +{ +#if NVLAN > 0 + struct m_hdr mh; + struct ether_vlan_header evh; + + if ((m->m_flags & M_VLANTAG) == 0) +#endif + { + bpf_mtap(arg, m, direction); + return; + } + +#if NVLAN > 0 + bcopy(mtod(m, char *), &evh, ETHER_HDR_LEN); + evh.evl_proto = evh.evl_encap_proto; + evh.evl_encap_proto = htons(ETHERTYPE_VLAN); + evh.evl_tag = htons(m->m_pkthdr.ether_vtag); + m->m_len -= ETHER_HDR_LEN; + m->m_data += ETHER_HDR_LEN; + + mh.mh_flags = 0; + mh.mh_next = m; + mh.mh_len = sizeof(evh); + mh.mh_data = (caddr_t)&evh; + + bpf_mtap(arg, (struct mbuf *) &mh, direction); + m->m_flags |= mh.mh_flags & M_FILDROP; + + m->m_len += ETHER_HDR_LEN; + m->m_data -= ETHER_HDR_LEN; +#endif +} + +/* * Move the packet data from interface memory (pkt) into the * store buffer. Return 1 if it's time to wakeup a listener (buffer full), * otherwise 0. "copy" is the routine called to do the actual data diff --git a/sys/net/bpf.h b/sys/net/bpf.h index 88d0a7fbc7f..fcf4c2588ec 100644 --- a/sys/net/bpf.h +++ b/sys/net/bpf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bpf.h,v 1.35 2008/06/29 19:31:16 deraadt Exp $ */ +/* $OpenBSD: bpf.h,v 1.36 2008/11/09 15:08:26 naddy Exp $ */ /* $NetBSD: bpf.h,v 1.15 1996/12/13 07:57:33 mikel Exp $ */ /* @@ -273,6 +273,7 @@ int bpf_tap(caddr_t, u_char *, u_int, u_int); void bpf_mtap(caddr_t, struct mbuf *, u_int); void bpf_mtap_hdr(caddr_t, caddr_t, u_int, struct mbuf *, u_int); void bpf_mtap_af(caddr_t, u_int32_t, struct mbuf *, u_int); +void bpf_mtap_ether(caddr_t, struct mbuf *, u_int); void bpfattach(caddr_t *, struct ifnet *, u_int, u_int); void bpfdetach(struct ifnet *); void bpfilterattach(int); |