the spec says vlan 0 and vlan 4095 are reserved, so we probably
shouldnt use them.
this tweaks the vlan tag check only allow valid ids per the spec.
ok?
Index: if_vlan.c
===================================================================
RCS file: /cvs/src/sys/net/if_vlan.c,v
retrieving revision 1.150
diff -u -p -r1.150 if_vlan.c
--- if_vlan.c 8 Dec 2015 11:35:42 -0000 1.150
+++ if_vlan.c 22 Dec 2015 01:04:24 -0000
@@ -156,6 +156,8 @@ vlan_clone_create(struct if_clone *ifc,
else
ifv->ifv_type = ETHERTYPE_VLAN;
+ ifv->ifv_tag = EVL_VLID_MIN;
+
refcnt_init(&ifv->ifv_refcnt);
ifp->if_start = vlan_start;
@@ -586,6 +588,7 @@ vlan_ioctl(struct ifnet *ifp, u_long cmd
struct ifvlan *ifv;
struct vlanreq vlr;
int error = 0, s;
+ uint16_t tag;
ifr = (struct ifreq *)data;
ifa = (struct ifaddr *)data;
@@ -630,15 +633,18 @@ vlan_ioctl(struct ifnet *ifp, u_long cmd
error = ENOENT;
break;
}
+
/*
* Don't let the caller set up a VLAN tag with
* anything except VLID bits.
*/
- if (vlr.vlr_tag & ~EVL_VLID_MASK) {
+ tag = vlr.vlr_tag;
+ if (tag < EVL_VLID_MIN || tag > EVL_VLID_MAX) {
error = EINVAL;
break;
}
- error = vlan_config(ifv, pr, vlr.vlr_tag);
+
+ error = vlan_config(ifv, pr, tag);
if (error)
break;
ifp->if_flags |= IFF_RUNNING;
Index: if_vlan_var.h
===================================================================
RCS file: /cvs/src/sys/net/if_vlan_var.h,v
retrieving revision 1.31
diff -u -p -r1.31 if_vlan_var.h
--- if_vlan_var.h 3 Dec 2015 16:27:32 -0000 1.31
+++ if_vlan_var.h 22 Dec 2015 01:04:24 -0000
@@ -42,7 +42,10 @@ struct ether_vlan_header {
u_int16_t evl_proto;
};
-#define EVL_VLID_MASK 0x0FFF
+#define EVL_VLID_MASK 0xFFF
+/* 0x000 and 0xFFF are reserved */
+#define EVL_VLID_MIN 0x001
+#define EVL_VLID_MAX 0xFFE
#define EVL_VLANOFTAG(tag) ((tag) & EVL_VLID_MASK)
#define EVL_PRIOFTAG(tag) (((tag) >> EVL_PRIO_BITS) & 7)
#define EVL_ENCAPLEN 4 /* length in octets of encapsulation */