[Bug 279195] kernel panic while re-configuring if_vlan(4) vlan id

From: <bugzilla-noreply_at_freebsd.org>
Date: Tue, 21 May 2024 08:34:19 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=279195

Kristof Provost <kp@freebsd.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kp@freebsd.org

--- Comment #2 from Kristof Provost <kp@freebsd.org> ---
Yeah, that seems to need this:

diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c
index b69d8107e30d..b936d4673404 100644
--- a/sys/net/if_vlan.c
+++ b/sys/net/if_vlan.c
@@ -1715,10 +1715,17 @@ vlan_config(struct ifvlan *ifv, struct ifnet *p,
uint16_t vid,
                ifv->ifv_proto = proto;

                if (ifv->ifv_vid != vid) {
+                       int oldvid = ifv->ifv_vid;
+
                        /* Re-hash */
                        vlan_remhash(trunk, ifv);
                        ifv->ifv_vid = vid;
                        error = vlan_inshash(trunk, ifv);
+                       if (error) {
+                               ifv->ifv_vid = oldvid;
+                               /* Re-insert back where we found it. */
+                               vlan_inshash(trunk, ifv);
+                       }
                }
                /* Will unlock */
                goto done;

After # ifconfig vlan0 vlan 110 you'll see that vlan0 thinks it's on 111, so
when it tries to vlan_remhash() it's not where it expects to find it.

There may be a similar problem in the case where we don't yet have a vlandev.

-- 
You are receiving this mail because:
You are the assignee for the bug.