git: a2b4b71ce33a - stable/15 - vlan: Notify the parent when replacing a VLAN ID

From: Kevin Bowling <kbowling_at_FreeBSD.org>
Date: Thu, 29 Oct 2026 06:09:14 UTC
The branch stable/15 has been updated by kbowling:

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

commit a2b4b71ce33a9308d9444c92e29b397ebab20cf1
Author:     Kevin Bowling <kbowling@FreeBSD.org>
AuthorDate: 2026-09-16 17:13:01 +0000
Commit:     Kevin Bowling <kbowling@FreeBSD.org>
CommitDate: 2026-10-29 06:09:06 +0000

    vlan: Notify the parent when replacing a VLAN ID
    
    Changing the VID of an existing VLAN interface rehashes the interface and
    announces the new VID, but does not unregister the old VID.  Parent
    drivers and VLAN event consumers can consequently retain stale filter
    membership.
    
    After successfully inserting the new VID, emit vlan_unconfig for the old
    VID before the existing vlan_config notification.  Do not unregister
    anything if insertion fails and the old VID is restored.
    
    Sponsored by:   BBOX.io
    
    (cherry picked from commit 50b3763bab6295ac40f6e6a6562bd2d92a1d0768)
---
 sys/net/if_vlan.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c
index 5f03beac0b76..a5161c7f0f92 100644
--- a/sys/net/if_vlan.c
+++ b/sys/net/if_vlan.c
@@ -1706,6 +1706,8 @@ vlan_config(struct ifvlan *ifv, struct ifnet *p, uint16_t vid,
 				/* Re-insert back where we found it. */
 				ret = vlan_inshash(trunk, ifv);
 				MPASS(ret == 0);
+			} else {
+				EVENTHANDLER_INVOKE(vlan_unconfig, p, oldvid);
 			}
 		}
 		/* Will unlock */