The branch stable/14 has been updated by zlei:

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

commit aa79996e605735dcd9b1bf83d6affefa404530d1
Author:     Zhenlei Huang <z...@freebsd.org>
AuthorDate: 2025-01-21 15:02:13 +0000
Commit:     Zhenlei Huang <z...@freebsd.org>
CommitDate: 2025-01-28 15:22:15 +0000

    if_vxlan(4): Invoke vxlan_stop event handler only when the interface is 
configured
    
    It is harmless but pointless to invoke vxlan_stop event handler when the
    interface was not previously configured. This change will also prevent
    an assert panic from t4_vxlan_stop_handler().
    
    Reviewed by:    kib
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D48494
    
    (cherry picked from commit 960c5bb0f6bf44aeb09fa14fd0f82c2e82ebe2e2)
---
 sys/net/if_vxlan.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/sys/net/if_vxlan.c b/sys/net/if_vxlan.c
index 2bde1d894a3b..0bbb3e0bcf9c 100644
--- a/sys/net/if_vxlan.c
+++ b/sys/net/if_vxlan.c
@@ -1814,6 +1814,7 @@ vxlan_teardown_locked(struct vxlan_softc *sc)
 {
        struct ifnet *ifp;
        struct vxlan_socket *vso;
+       bool running;
 
        sx_assert(&vxlan_sx, SA_XLOCKED);
        VXLAN_LOCK_WASSERT(sc);
@@ -1821,6 +1822,7 @@ vxlan_teardown_locked(struct vxlan_softc *sc)
 
        ifp = sc->vxl_ifp;
        ifp->if_flags &= ~IFF_UP;
+       running = (ifp->if_drv_flags & IFF_DRV_RUNNING) != 0;
        ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
        callout_stop(&sc->vxl_callout);
        vso = sc->vxl_sock;
@@ -1828,8 +1830,10 @@ vxlan_teardown_locked(struct vxlan_softc *sc)
 
        VXLAN_WUNLOCK(sc);
        if_link_state_change(ifp, LINK_STATE_DOWN);
-       EVENTHANDLER_INVOKE(vxlan_stop, ifp, sc->vxl_src_addr.in4.sin_family,
-           ntohs(sc->vxl_src_addr.in4.sin_port));
+       if (running)
+               EVENTHANDLER_INVOKE(vxlan_stop, ifp,
+                   sc->vxl_src_addr.in4.sin_family,
+                   ntohs(sc->vxl_src_addr.in4.sin_port));
 
        if (vso != NULL) {
                vxlan_socket_remove_softc(vso, sc);

Reply via email to