git: 9523a569fc02 - stable/13 - sys/net: add a new ether_vlanid_t type
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 19 May 2025 02:54:35 UTC
The branch stable/13 has been updated by ivy: URL: https://cgit.FreeBSD.org/src/commit/?id=9523a569fc02cf7d61e30016d2eb5e562981fe57 commit 9523a569fc02cf7d61e30016d2eb5e562981fe57 Author: Lexi Winter <ivy@FreeBSD.org> AuthorDate: 2025-04-15 16:13:23 +0000 Commit: Lexi Winter <ivy@FreeBSD.org> CommitDate: 2025-05-19 02:49:20 +0000 sys/net: add a new ether_vlanid_t type ether_vlanid_t is a type to represent a VLAN ID, for example inside a .1q tag. since this is specific to Ethernet, put it in net/ethernet.h. change bridge to use the new type instead of uint{16,32}_t. Reviewed by: adrian, kp Differential Revision: https://reviews.freebsd.org/D49836 (cherry picked from commit 96f830456fd449c4cb5a7df8a2f6c3c96993b43e) --- sys/net/ethernet.h | 5 +++++ sys/net/if_bridge.c | 28 ++++++++++++++++------------ sys/net/if_bridgevar.h | 2 +- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/sys/net/ethernet.h b/sys/net/ethernet.h index 6a16f6f92b57..8822602d33e4 100644 --- a/sys/net/ethernet.h +++ b/sys/net/ethernet.h @@ -78,6 +78,11 @@ struct ether_addr { (((addr)[0] | (addr)[1] | (addr)[2] | \ (addr)[3] | (addr)[4] | (addr)[5]) == 0x00) +/* + * This is the type of the VLAN ID inside the tag, not the tag itself. + */ +typedef uint16_t ether_vlanid_t; + /* * 802.1q Virtual LAN header. */ diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c index dd506d558c99..b385772bdf73 100644 --- a/sys/net/if_bridge.c +++ b/sys/net/if_bridge.c @@ -270,7 +270,7 @@ struct bridge_rtnode { unsigned long brt_expire; /* expiration time */ uint8_t brt_flags; /* address flags */ uint8_t brt_addr[ETHER_ADDR_LEN]; - uint16_t brt_vlan; /* vlan id */ + ether_vlanid_t brt_vlan; /* vlan id */ struct vnet *brt_vnet; struct epoch_context brt_epoch_ctx; }; @@ -343,21 +343,21 @@ static void bridge_broadcast(struct bridge_softc *, struct ifnet *, static void bridge_span(struct bridge_softc *, struct mbuf *); static int bridge_rtupdate(struct bridge_softc *, const uint8_t *, - uint16_t, struct bridge_iflist *, int, uint8_t); + ether_vlanid_t, struct bridge_iflist *, int, uint8_t); static struct ifnet *bridge_rtlookup(struct bridge_softc *, const uint8_t *, - uint16_t); + ether_vlanid_t); static void bridge_rttrim(struct bridge_softc *); static void bridge_rtage(struct bridge_softc *); static void bridge_rtflush(struct bridge_softc *, int); static int bridge_rtdaddr(struct bridge_softc *, const uint8_t *, - uint16_t); + ether_vlanid_t); static void bridge_rtable_init(struct bridge_softc *); static void bridge_rtable_fini(struct bridge_softc *); static int bridge_rtnode_addr_cmp(const uint8_t *, const uint8_t *); static struct bridge_rtnode *bridge_rtnode_lookup(struct bridge_softc *, - const uint8_t *, uint16_t); + const uint8_t *, ether_vlanid_t); static int bridge_rtnode_insert(struct bridge_softc *, struct bridge_rtnode *); static void bridge_rtnode_destroy(struct bridge_softc *, @@ -2147,7 +2147,7 @@ bridge_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *sa, struct ether_header *eh; struct ifnet *bifp, *dst_if; struct bridge_softc *sc; - uint16_t vlan; + ether_vlanid_t vlan; NET_EPOCH_ASSERT(); @@ -2464,7 +2464,7 @@ bridge_input(struct ifnet *ifp, struct mbuf *m) struct ifnet *bifp; struct ether_header *eh; struct mbuf *mc, *mc2; - uint16_t vlan; + ether_vlanid_t vlan; int error; NET_EPOCH_ASSERT(); @@ -2761,8 +2761,9 @@ bridge_span(struct bridge_softc *sc, struct mbuf *m) * Add a bridge routing entry. */ static int -bridge_rtupdate(struct bridge_softc *sc, const uint8_t *dst, uint16_t vlan, - struct bridge_iflist *bif, int setflags, uint8_t flags) +bridge_rtupdate(struct bridge_softc *sc, const uint8_t *dst, + ether_vlanid_t vlan, struct bridge_iflist *bif, + int setflags, uint8_t flags) { struct bridge_rtnode *brt; struct bridge_iflist *obif; @@ -2873,7 +2874,8 @@ bridge_rtupdate(struct bridge_softc *sc, const uint8_t *dst, uint16_t vlan, * Lookup the destination interface for an address. */ static struct ifnet * -bridge_rtlookup(struct bridge_softc *sc, const uint8_t *addr, uint16_t vlan) +bridge_rtlookup(struct bridge_softc *sc, const uint8_t *addr, + ether_vlanid_t vlan) { struct bridge_rtnode *brt; @@ -2984,7 +2986,8 @@ bridge_rtflush(struct bridge_softc *sc, int full) * Remove an address from the table. */ static int -bridge_rtdaddr(struct bridge_softc *sc, const uint8_t *addr, uint16_t vlan) +bridge_rtdaddr(struct bridge_softc *sc, const uint8_t *addr, + ether_vlanid_t vlan) { struct bridge_rtnode *brt; int found = 0; @@ -3113,7 +3116,8 @@ bridge_rtnode_addr_cmp(const uint8_t *a, const uint8_t *b) * vlan id or if zero then just return the first match. */ static struct bridge_rtnode * -bridge_rtnode_lookup(struct bridge_softc *sc, const uint8_t *addr, uint16_t vlan) +bridge_rtnode_lookup(struct bridge_softc *sc, const uint8_t *addr, + ether_vlanid_t vlan) { struct bridge_rtnode *brt; uint32_t hash; diff --git a/sys/net/if_bridgevar.h b/sys/net/if_bridgevar.h index 3b96a997f052..8f1de6793340 100644 --- a/sys/net/if_bridgevar.h +++ b/sys/net/if_bridgevar.h @@ -181,7 +181,7 @@ struct ifbareq { unsigned long ifba_expire; /* address expire time */ uint8_t ifba_flags; /* address flags */ uint8_t ifba_dst[ETHER_ADDR_LEN];/* destination address */ - uint16_t ifba_vlan; /* vlan id */ + ether_vlanid_t ifba_vlan; /* vlan id */ }; #define IFBAF_TYPEMASK 0x03 /* address type mask */