sys/net: add DOT1Q_VID_{MIN,MAX}

add a new typedef in if_vlan_var.h to represent the lowest (1) and
highest (4095) valid VLAN IDs in a .1q tag.

change if_vlan to use DOT1Q_VID_MAX instead of a magic number.

Reviewed by:	kp
Differential Revision:	https://reviews.freebsd.org/D49837

(cherry picked from commit c59492025073bd57c7dc3bb5bd843ab0a1391c7a)
This commit is contained in:
Lexi Winter 2025-04-15 18:13:33 +02:00 committed by Franco Fichtner
parent 7b4478faed
commit d9cbfa3794
2 changed files with 3 additions and 1 deletions

View File

@ -1272,7 +1272,7 @@ vlan_clone_create_nl(struct if_clone *ifc, char *name, size_t len,
error = nl_parse_nested(lattrs->ifla_idata, &vlan_parser, npt, &attrs);
if (error != 0)
return (error);
if (attrs.vlan_id > 4095) {
if (attrs.vlan_id > DOT1Q_VID_MAX) {
nlmsg_report_err_msg(npt, "Invalid VID: %d", attrs.vlan_id);
return (EINVAL);
}

View File

@ -130,6 +130,8 @@ struct vlanreq {
#define DOT1Q_VID_DEF_PVID 0x1
#define DOT1Q_VID_DEF_SR_PVID 0x2
#define DOT1Q_VID_RSVD_IMPL 0xfff
#define DOT1Q_VID_MIN 1 /* minimum valid vlan id */
#define DOT1Q_VID_MAX 4095 /* maximum valid vlan id */
/*
* 802.1q full tag. Proto and vid are stored in host byte order.