Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 Feb 2012 17:43:57 GMT
From:      Ivan Rozhuk <rozhuk.im@gmail.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   kern/165296: Fix EVL_APPLY_VLID, update EVL_APPLY_PRI macro
Message-ID:  <201202191743.q1JHhvBl044033@red.freebsd.org>
Resent-Message-ID: <201202191750.q1JHo1Nu066908@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         165296
>Category:       kern
>Synopsis:       Fix EVL_APPLY_VLID, update EVL_APPLY_PRI macro
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Feb 19 17:50:01 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Ivan Rozhuk
>Release:        9.0
>Organization:
>Environment:
FreeBSD firewall 9.0-STABLE FreeBSD 9.0-STABLE #0: Sat Jan 21 11:32:18 IRKT 2012     root@firewall:/tmp/obj/usr/src/sys/RIM  i386

>Description:
EVL_APPLY_VLID macro removes the flag Canonical Format Indicator (CFI) and the Priority Code Point (PCP) instead of removing VLAN Identifier (VID). The new VID is superimposed on the old one.
(m) -> m_pkthdr.ether_vtag & = EVL_VLID_MASK; \
(m) -> m_pkthdr.ether_vtag | = (vlid); \

The correct version:
(m) -> m_pkthdr.ether_vtag & = ~ EVL_VLID_MASK; \
(m) -> m_pkthdr.ether_vtag | = ((vlid) & EVL_VLID_MASK); \

>How-To-Repeat:

>Fix:
apply patch

Patch attached with submission follows:

--- ./if_vlan_var.h.orig	2011-09-23 09:51:37.000000000 +0900
+++ ./if_vlan_var.h	2012-02-20 02:28:50.000000000 +0900
@@ -52,27 +52,24 @@
 #define EVL_APPLY_VLID(m, vlid)						\
 	do {								\
 		if ((m)->m_flags & M_VLANTAG) {				\
-			(m)->m_pkthdr.ether_vtag &= EVL_VLID_MASK;	\
-			(m)->m_pkthdr.ether_vtag |= (vlid);		\
+			(m)->m_pkthdr.ether_vtag &= ~EVL_VLID_MASK;	\
 		} else {						\
-			(m)->m_pkthdr.ether_vtag = (vlid);		\
+			(m)->m_pkthdr.ether_vtag = 0;			\
 			(m)->m_flags |= M_VLANTAG;			\
 		}							\
+		(m)->m_pkthdr.ether_vtag |= ((vlid) & EVL_VLID_MASK);	\
 	} while (0)
 
 /* Set the priority ID in an mbuf packet header non-destructively. */
 #define EVL_APPLY_PRI(m, pri)						\
 	do {								\
 		if ((m)->m_flags & M_VLANTAG) {				\
-			uint16_t __vlantag = (m)->m_pkthdr.ether_vtag;	\
-			(m)->m_pkthdr.ether_vtag |= EVL_MAKETAG(	\
-			    EVL_VLANOFTAG(__vlantag), (pri),		\
-			    EVL_CFIOFTAG(__vlantag));			\
+			(m)->m_pkthdr.ether_vtag &= ~EVL_PRI_MASK;	\
 		} else {						\
-			(m)->m_pkthdr.ether_vtag =			\
-			    EVL_MAKETAG(0, (pri), 0);			\
+			(m)->m_pkthdr.ether_vtag = 0;			\
 			(m)->m_flags |= M_VLANTAG;			\
 		}							\
+		(m)->m_pkthdr.ether_vtag |= (((pri) & 7) << 1);		\
 	} while (0)
 
 /* sysctl(3) tags, for compatibility purposes */


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201202191743.q1JHhvBl044033>