git: c59492025073 - main - sys/net: add DOT1Q_VID_{MIN,MAX}
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 15 Apr 2025 21:43:34 UTC
The branch main has been updated by kp:
URL: https://cgit.FreeBSD.org/src/commit/?id=c59492025073bd57c7dc3bb5bd843ab0a1391c7a
commit c59492025073bd57c7dc3bb5bd843ab0a1391c7a
Author: Lexi Winter <lexi@hemlock.eden.le-fay.org>
AuthorDate: 2025-04-15 16:13:33 +0000
Commit: Kristof Provost <kp@FreeBSD.org>
CommitDate: 2025-04-15 21:42:59 +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
---
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 774298d4a53a..a37a9d41fc53 100644
--- a/sys/net/if_vlan.c
+++ b/sys/net/if_vlan.c
@@ -1273,7 +1273,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.