summaryrefslogtreecommitdiffstats
path: root/sys/net/ethernet.h
diff options
context:
space:
mode:
authorcsjp <csjp@FreeBSD.org>2006-11-18 23:17:22 +0000
committercsjp <csjp@FreeBSD.org>2006-11-18 23:17:22 +0000
commit5aa5d3eb87ef22b838901d976a898e7826d9032f (patch)
tree8daa14e003cb59b6b1fab70f6be511048b5bb81d /sys/net/ethernet.h
parentaee58e2da0c688785939850d85b12b57fbb12396 (diff)
downloadFreeBSD-src-5aa5d3eb87ef22b838901d976a898e7826d9032f.zip
FreeBSD-src-5aa5d3eb87ef22b838901d976a898e7826d9032f.tar.gz
Currently, drivers that support hardware offload of VLAN tag
processing are forced to toggle this functionality when the card is put in and out of promiscuous mode. The main reason for this is because the hardware strips the VLAN tag, making it impossible for the tag information to show up in network diagnostic tools like tcpdump(1). This change introduces ether_vlan_mtap(), which is called if the mbuf has M_VLANTAG set. VLAN information is extracted from the mbuf and inserted into a stack allocated ether vlan header which is then inserted through the bpf machinery via bpf_mtap2(). The original mbuf's data pointer and lengths are temporarily adjusted to eliminate the original Ethernet header for the duration of the tap operation. This should have no long term effects on the mbuf. Also, define a new macro, ETHER_BPF_MTAP which should be used by drivers which support hardware offload of VLAN tag processing. The fixes for the relevant drivers will follow shortly. Discussed with: rwatson, andre, jhb (and others) Much feedback from: sam, ru MFC after: 1 month [1] [1] The version that is eventually MFCed will be somewhat different then this, as there has been significant work done to the VLAN code in HEAD.
Diffstat (limited to 'sys/net/ethernet.h')
-rw-r--r--sys/net/ethernet.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/sys/net/ethernet.h b/sys/net/ethernet.h
index befdd93..f091f60 100644
--- a/sys/net/ethernet.h
+++ b/sys/net/ethernet.h
@@ -343,6 +343,22 @@ struct ether_addr {
#define ETHERMTU (ETHER_MAX_LEN-ETHER_HDR_LEN-ETHER_CRC_LEN)
#define ETHERMIN (ETHER_MIN_LEN-ETHER_HDR_LEN-ETHER_CRC_LEN)
#define ETHERMTU_JUMBO (ETHER_MAX_LEN_JUMBO - ETHER_HDR_LEN - ETHER_CRC_LEN)
+/*
+ * The ETHER_BPF_MTAP macro should be used by drivers which support hardware
+ * offload for VLAN tag processing. It will check the mbuf to see if it has
+ * M_VLANTAG set, and if it does, will pass the packet along to
+ * ether_vlan_mtap. This function will re-insert VLAN tags for the duration
+ * of the tap, show they show up properly for network analyzers.
+ */
+#define ETHER_BPF_MTAP(_ifp, _m) do { \
+ if (bpf_peers_present((_ifp)->if_bpf)) { \
+ M_ASSERTVALID(_m); \
+ if (((_m)->m_flags & M_VLANTAG) != 0) \
+ ether_vlan_mtap((_ifp)->if_bpf, (_m), NULL, 0); \
+ else \
+ bpf_mtap((_ifp)->if_bpf, (_m)); \
+ } \
+} while (0)
#ifdef _KERNEL
@@ -350,6 +366,7 @@ struct ifnet;
struct mbuf;
struct rtentry;
struct sockaddr;
+struct bpf_if;
extern uint32_t ether_crc32_le(const uint8_t *, size_t);
extern uint32_t ether_crc32_be(const uint8_t *, size_t);
@@ -361,6 +378,8 @@ extern int ether_output(struct ifnet *,
struct mbuf *, struct sockaddr *, struct rtentry *);
extern int ether_output_frame(struct ifnet *, struct mbuf *);
extern char *ether_sprintf(const u_int8_t *);
+void ether_vlan_mtap(struct bpf_if *, struct mbuf *,
+ void *, u_int);
#else /* _KERNEL */
OpenPOWER on IntegriCloud