Author: kp
Date: Sat Sep 12 18:58:36 2020
New Revision: 365669
URL: https://svnweb.freebsd.org/changeset/base/365669

Log:
  MFC r365457:
  
  net: mitigate vnet / epair cleanup races
  
  There's a race where dying vnets move their interfaces back to their original
  vnet, and if_epair cleanup (where deleting one interface also deletes the 
other
  end of the epair). This is commonly triggered by the pf tests, but also by
  cleanup of vnet jails.
  
  As we've not yet been able to fix the root cause of the issue work around the
  panic by not dereferencing a NULL softc in epair_qflush() and by not
  re-attaching DYING interfaces.
  
  This isn't a full fix, but makes a very common panic far less likely.
  
  PR:           244703, 238870
  Approved by:  re (gjb)

Modified:
  releng/12.2/sys/net/if.c
  releng/12.2/sys/net/if_epair.c
Directory Properties:
  releng/12.2/   (props changed)

Modified: releng/12.2/sys/net/if.c
==============================================================================
--- releng/12.2/sys/net/if.c    Sat Sep 12 18:42:14 2020        (r365668)
+++ releng/12.2/sys/net/if.c    Sat Sep 12 18:58:36 2020        (r365669)
@@ -1280,6 +1280,10 @@ if_vmove(struct ifnet *ifp, struct vnet *new_vnet)
        ifindex_free_locked(ifp->if_index);
        IFNET_WUNLOCK();
 
+       /* Don't re-attach DYING interfaces. */
+       if (ifp->if_flags & IFF_DYING)
+               return;
+
        /*
         * Perform interface-specific reassignment tasks, if provided by
         * the driver.

Modified: releng/12.2/sys/net/if_epair.c
==============================================================================
--- releng/12.2/sys/net/if_epair.c      Sat Sep 12 18:42:14 2020        
(r365668)
+++ releng/12.2/sys/net/if_epair.c      Sat Sep 12 18:58:36 2020        
(r365669)
@@ -609,8 +609,14 @@ epair_qflush(struct ifnet *ifp)
        struct epair_softc *sc;
        
        sc = ifp->if_softc;
-       KASSERT(sc != NULL, ("%s: ifp=%p, epair_softc gone? sc=%p\n",
-           __func__, ifp, sc));
+
+       /*
+        * See epair_clone_destroy(), we can end up getting called twice.
+        * Don't do anything on the second call.
+        */
+       if (sc == NULL)
+               return;
+
        /*
         * Remove this ifp from all backpointer lists. The interface will not
         * usable for flushing anyway nor should it have anything to flush
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to