Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/net - add a constant for the vlan mask.



details:   https://anonhg.NetBSD.org/src/rev/a26dd138e294
branches:  trunk
changeset: 356473:a26dd138e294
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Sep 28 16:26:14 2017 +0000

description:
- add a constant for the vlan mask.
- enforce that we have a tag before we get it.

diffstat:

 sys/net/if_ether.h |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (34 lines):

diff -r 4c7d7bb182eb -r a26dd138e294 sys/net/if_ether.h
--- a/sys/net/if_ether.h        Thu Sep 28 16:24:39 2017 +0000
+++ b/sys/net/if_ether.h        Thu Sep 28 16:26:14 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ether.h,v 1.67 2017/09/26 07:42:06 knakahara Exp $  */
+/*     $NetBSD: if_ether.h,v 1.68 2017/09/28 16:26:14 christos Exp $   */
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -60,6 +60,7 @@
  * Some Ethernet extensions.
  */
 #define        ETHER_VLAN_ENCAP_LEN 4  /* length of 802.1Q VLAN encapsulation */
+#define        ETHER_VLAN_MASK 0xFFF   /* bits in a vlan tag */
 #define        ETHER_PPPOE_ENCAP_LEN 8 /* length of PPPoE encapsulation */
 
 /*
@@ -299,7 +300,7 @@
 vlan_set_tag(struct mbuf *m, u_int16_t vlanid)
 {
 
-       KASSERT((vlanid & ~0x0FFF) == 0);
+       KASSERT((vlanid & ~ETHER_VLAN_MASK) == 0);
 
        m->m_pkthdr.ether_vtag = vlanid;
        m->m_flags |= M_VLANTAG;
@@ -316,6 +317,7 @@
 static inline uint16_t
 vlan_get_tag(struct mbuf *m)
 {
+       KASSERT(m->m_flags & M_VLANTAG);
        return m->m_pkthdr.ether_vtag;
 }
 



Home | Main Index | Thread Index | Old Index