From 183af5646236995a04c83ed0260cb521887a12e5 Mon Sep 17 00:00:00 2001 From: ru Date: Thu, 1 Feb 2007 14:32:37 +0000 Subject: [PATCH] - Don't forget to reset the M_VLANTAG when removing a tag, otherwise bad things may happen. [1] - More diff redux to HEAD. Submitted by: Vsevolod Lobko [1] --- sys/netgraph/ng_vlan.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/sys/netgraph/ng_vlan.c b/sys/netgraph/ng_vlan.c index 437f2323e9bb..8019cc2addf8 100644 --- a/sys/netgraph/ng_vlan.c +++ b/sys/netgraph/ng_vlan.c @@ -361,13 +361,17 @@ ng_vlan_rcvdata(hook_p hook, item_p item) * If from downstream, select between a match hook * or the nomatch hook. */ - mtag = m_tag_locate(m, MTAG_VLAN, MTAG_VLAN_TAG, NULL); - if (mtag != NULL || eh->ether_type == htons(ETHERTYPE_VLAN)) { - if (mtag != NULL) { + if (m->m_flags & M_VLANTAG || + eh->ether_type == htons(ETHERTYPE_VLAN)) { + if (m->m_flags & M_VLANTAG) { /* * Packet is tagged, m contains a normal * Ethernet frame; 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__)); vlan = EVL_VLANOFTAG(VLAN_TAG_VALUE(mtag)); (void)&evl; /* XXX silence GCC */ } else { @@ -378,11 +382,13 @@ ng_vlan_rcvdata(hook_p hook, item_p item) } evl = mtod(m, struct ether_vlan_header *); vlan = EVL_VLANOFTAG(ntohs(evl->evl_tag)); + (void)&mtag; /* XXX silence GCC */ } if ((f = ng_vlan_findentry(priv, vlan)) != NULL) { - if (mtag != NULL) + if (m->m_flags & M_VLANTAG) { m_tag_delete(m, mtag); - else { + m->m_flags &= ~M_VLANTAG; + } else { evl->evl_encap_proto = evl->evl_proto; bcopy(mtod(m, caddr_t), mtod(m, caddr_t) +