Hi!

In theory 802.1q header with vlan tag 0 can be used to just signal
priority. Now I'm seeing this in the wild. On a untagged port some
packets are coming with dotq header and some without. Currently we drop
all the packets with dotq header and vlan tag 0.

Following patch fixes this by recording the priority and removing the
header, so existing code to handle the packet. At least NetBSD does
something similar.

Rivo

diff --git sys/net/if_ethersubr.c sys/net/if_ethersubr.c
index 76f6c3147e0..68f5b03b4f4 100644
--- sys/net/if_ethersubr.c
+++ sys/net/if_ethersubr.c
@@ -362,6 +362,22 @@ ether_input(struct ifnet *ifp, struct mbuf *m, void 
*cookie)
 
        etype = ntohs(eh->ether_type);
 
+       /*
+        * 802.1Q header with a tag of 0 can be used to store priority.
+        */
+       if (etype == ETHERTYPE_VLAN) {
+               struct ether_vlan_header *evl = (void *)eh;
+               if (EVL_VLANOFTAG(evl->evl_tag) == EVL_VLID_NULL) {
+                       etype = ntohs(evl->evl_proto);
+                       m->m_pkthdr.pf.prio = EVL_PRIOFTAG(evl->evl_tag);
+                       /* IEEE 802.1p has prio 0 and 1 swapped */
+                       if (m->m_pkthdr.pf.prio <= 1)
+                               m->m_pkthdr.pf.prio = !m->m_pkthdr.pf.prio;
+                       memmove((char *)eh + EVL_ENCAPLEN, eh, sizeof(*eh));
+                       m_adj(m, EVL_ENCAPLEN);
+               }
+       }
+
        switch (etype) {
        case ETHERTYPE_IP:
                input = ipv4_input;

Reply via email to