diff options
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/if_vlan.c | 22 | ||||
-rw-r--r-- | sys/net/if_vlan_var.h | 55 |
2 files changed, 21 insertions, 56 deletions
diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c index 0b82e4d..0fef217 100644 --- a/sys/net/if_vlan.c +++ b/sys/net/if_vlan.c @@ -850,15 +850,7 @@ vlan_start(struct ifnet *ifp) * packet tag that holds it. */ if (p->if_capenable & IFCAP_VLAN_HWTAGGING) { - struct m_tag *mtag = (struct m_tag *) - uma_zalloc(zone_mtag_vlan, M_NOWAIT); - if (mtag == NULL) { - ifp->if_oerrors++; - m_freem(m); - continue; - } - VLAN_TAG_VALUE(mtag) = ifv->ifv_tag; - m_tag_prepend(m, mtag); + m->m_pkthdr.ether_vtag = ifv->ifv_tag; m->m_flags |= M_VLANTAG; } else { struct ether_vlan_header *evl; @@ -915,7 +907,7 @@ vlan_input(struct ifnet *ifp, struct mbuf *m) { struct ifvlantrunk *trunk = ifp->if_vlantrunk; struct ifvlan *ifv; - struct m_tag *mtag; + int inenc = 0; uint16_t tag; KASSERT(trunk != NULL, ("%s: no trunk", __func__)); @@ -925,11 +917,7 @@ vlan_input(struct ifnet *ifp, struct mbuf *m) * Packet is tagged, but m contains a normal * Ethernet frame; the tag is stored out-of-band. */ - mtag = m_tag_locate(m, MTAG_VLAN, MTAG_VLAN_TAG, NULL); - KASSERT(mtag != NULL, - ("%s: M_VLANTAG without m_tag", __func__)); - tag = EVL_VLANOFTAG(VLAN_TAG_VALUE(mtag)); - m_tag_delete(m, mtag); + tag = EVL_VLANOFTAG(m->m_pkthdr.ether_vtag); m->m_flags &= ~M_VLANTAG; } else { struct ether_vlan_header *evl; @@ -937,7 +925,7 @@ vlan_input(struct ifnet *ifp, struct mbuf *m) /* * Packet is tagged in-band as specified by 802.1q. */ - mtag = NULL; + inenc = 1; switch (ifp->if_type) { case IFT_ETHER: if (m->m_len < sizeof(*evl) && @@ -980,7 +968,7 @@ vlan_input(struct ifnet *ifp, struct mbuf *m) } TRUNK_RUNLOCK(trunk); - if (mtag == NULL) { + if (inenc) { /* * Packet had an in-line encapsulation header; * remove it. The original header has already diff --git a/sys/net/if_vlan_var.h b/sys/net/if_vlan_var.h index d4a2448..79bc461 100644 --- a/sys/net/if_vlan_var.h +++ b/sys/net/if_vlan_var.h @@ -70,53 +70,30 @@ struct vlanreq { */ /* - * Drivers that support hardware VLAN tagging pass a packet's tag - * up through the stack by appending a packet tag with this value. - * Output is handled likewise, the driver must locate the packet - * tag to extract the VLAN tag. The following macros are used to - * do this work. On input, do: + * VLAN tags are stored in host byte order. Byte swapping may be + * necessary. * - * VLAN_INPUT_TAG(ifp, m, tag,); + * Drivers that support hardware VLAN tag stripping fill in the + * received VLAN tag (containing both vlan and priority information) + * into the ether_vtag mbuf packet header field: + * + * m->m_pkthdr.ether_vtag = vlan_id; // ntohs()? + * m->m_flags |= M_VLANTAG; + * + * to mark the packet m with the specified VLAN tag. * - * to mark the packet m with the specified VLAN tag. The last - * parameter provides code to execute in case of an error. On - * output the driver should check mbuf to see if a VLAN tag is - * present and only then check for a tag; this is done with: + * On output the driver should check the mbuf for the M_VLANTAG + * flag to see if a VLAN tag is present and valid: * - * struct m_tag *mtag; - * mtag = VLAN_OUTPUT_TAG(ifp, m); - * if (mtag != NULL) { - * ... = VLAN_TAG_VALUE(mtag); + * if (m->m_flags & M_VLANTAG) { + * ... = m->m_pkthdr.ether_vtag; // htons()? * ... pass tag to hardware ... * } * * Note that a driver must indicate it supports hardware VLAN - * tagging by marking IFCAP_VLAN_HWTAGGING in if_capabilities. - */ - -/* - * This macro must expand to a lvalue so that it can be used - * to set a tag with a simple assignment. + * stripping/insertion by marking IFCAP_VLAN_HWTAGGING in + * if_capabilities. */ -#define VLAN_TAG_VALUE(_mt) (*(u_int *)((_mt) + 1)) - -#define VLAN_INPUT_TAG(_ifp, _m, _t) do { \ - struct m_tag *mtag = (struct m_tag *) \ - uma_zalloc(zone_mtag_vlan, M_NOWAIT); \ - if (mtag != NULL) { \ - VLAN_TAG_VALUE(mtag) = (_t); \ - m_tag_prepend((_m), mtag); \ - (_m)->m_flags |= M_VLANTAG; \ - } else { \ - (_ifp)->if_ierrors++; \ - m_freem(_m); \ - _m = NULL; \ - } \ -} while (0) - -#define VLAN_OUTPUT_TAG(_ifp, _m) \ - ((_m)->m_flags & M_VLANTAG ? \ - m_tag_locate((_m), MTAG_VLAN, MTAG_VLAN_TAG, NULL) : NULL) #define VLAN_CAPABILITIES(_ifp) do { \ if ((_ifp)->if_vlantrunk != NULL) \ |