git: 50b3763bab62 - main - vlan: Notify the parent when replacing a VLAN ID

From: Kevin Bowling <kbowling_at_FreeBSD.org>
Date: Wed, 16 Sep 2026 19:51:08 UTC
The branch main has been updated by kbowling:

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

commit 50b3763bab6295ac40f6e6a6562bd2d92a1d0768
Author:     Kevin Bowling <kbowling@FreeBSD.org>
AuthorDate: 2026-09-16 17:13:01 +0000
Commit:     Kevin Bowling <kbowling@FreeBSD.org>
CommitDate: 2026-09-16 19:50:27 +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.
    
    MFC after:      2 weeks
    Sponsored by:   BBOX.io
---
 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 ab05b4d075c7..959c68a7f32b 100644
--- a/sys/net/if_vlan.c
+++ b/sys/net/if_vlan.c
@@ -1704,6 +1704,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 */