Test the new M_VLANTAG packet flag before calling

m_tag_locate().  This adds little overhead of a simple
bitwise operation in case hardware VLAN acceleration
is on, yet saves the more expensive function call if
the acceleration is off.

Reviewed by:	ru, glebius
X-MFC-after:	6.0
This commit is contained in:
Yaroslav Tykhiy 2005-09-16 11:44:43 +00:00
parent ad61f89618
commit f4ec4126bb

View File

@ -562,16 +562,19 @@ vlan_input(struct ifnet *ifp, struct mbuf *m)
struct m_tag *mtag;
u_int tag;
mtag = m_tag_locate(m, MTAG_VLAN, MTAG_VLAN_TAG, NULL);
if (mtag != NULL) {
if (m->m_flags & M_VLANTAG) {
/*
* Packet is tagged, 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);
m->m_flags &= ~M_VLANTAG;
} else {
mtag = NULL;
switch (ifp->if_type) {
case IFT_ETHER:
if (m->m_len < sizeof(*evl) &&