From a930847e8fda73b5d669020b34d381b323554708 Mon Sep 17 00:00:00 2001 From: yar Date: Fri, 16 Sep 2005 11:44:43 +0000 Subject: 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 --- sys/net/if_vlan.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c index 758800a..5c7166e 100644 --- a/sys/net/if_vlan.c +++ b/sys/net/if_vlan.c @@ -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) && -- cgit v1.1