git: 73b29b47f75b - stable/14 - sys/net: add DOT1Q_VID_{MIN,MAX}
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 07 May 2025 21:23:42 UTC
The branch stable/14 has been updated by ivy:
URL: https://cgit.FreeBSD.org/src/commit/?id=73b29b47f75b3a7565f7831ea020be3d51c4e542
commit 73b29b47f75b3a7565f7831ea020be3d51c4e542
Author: Lexi Winter <ivy@FreeBSD.org>
AuthorDate: 2025-04-15 16:13:33 +0000
Commit: Lexi Winter <ivy@FreeBSD.org>
CommitDate: 2025-05-07 21:14:43 +0000
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)
---
sys/net/if_vlan.c | 2 +-
sys/net/if_vlan_var.h | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c
index c586b513e008..dce1cff5bc69 100644
--- a/sys/net/if_vlan.c
+++ b/sys/net/if_vlan.c
@@ -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);
}
diff --git a/sys/net/if_vlan_var.h b/sys/net/if_vlan_var.h
index b86ff2efac60..e7171974289b 100644
--- a/sys/net/if_vlan_var.h
+++ b/sys/net/if_vlan_var.h
@@ -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.