Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 23 Aug 2025 00:11:27 GMT
From:      Lexi Winter <ivy@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 8b728c63f777 - stable/14 - ifconfig/ifbridge.c: add get_vlan_id()
Message-ID:  <202508230011.57N0BRnG099888@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by ivy:

URL: https://cgit.FreeBSD.org/src/commit/?id=8b728c63f777f3b2e220fe28fbe24b74f5a7c388

commit 8b728c63f777f3b2e220fe28fbe24b74f5a7c388
Author:     Lexi Winter <ivy@FreeBSD.org>
AuthorDate: 2025-07-28 14:09:29 +0000
Commit:     Lexi Winter <ivy@FreeBSD.org>
CommitDate: 2025-08-23 00:10:15 +0000

    ifconfig/ifbridge.c: add get_vlan_id()
    
    This is like get_val() but takes an ether_vlanid_t* and ensures the
    value is a valid VLAN ID. This avoids redundant comparisons and
    casting when parsing VLAN IDs.
    
    Reviewed by:    des
    Differential Revision:  https://reviews.freebsd.org/D51548
    
    (cherry picked from commit 287a5fdcd3c941ce73705c664b5df4932ba3bad4)
---
 sbin/ifconfig/ifbridge.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/sbin/ifconfig/ifbridge.c b/sbin/ifconfig/ifbridge.c
index 2d0af1255a73..973c4f9cfe6e 100644
--- a/sbin/ifconfig/ifbridge.c
+++ b/sbin/ifconfig/ifbridge.c
@@ -79,6 +79,20 @@ get_val(const char *cp, u_long *valp)
 	return (0);
 }
 
+static int
+get_vlan_id(const char *cp, ether_vlanid_t *valp)
+{
+	u_long val;
+
+	if (get_val(cp, &val) == -1)
+		return (-1);
+	if (val < 0x1 || val > 0xffe)
+		return (-1);
+
+	*valp = (ether_vlanid_t)val;
+	return (0);
+}
+
 static int
 do_cmd(if_ctx *ctx, u_long op, void *arg, size_t argsize, int set)
 {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202508230011.57N0BRnG099888>