Author: kp
Date: Tue Sep  8 14:54:10 2020
New Revision: 365457
URL: https://svnweb.freebsd.org/changeset/base/365457

Log:
  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
  Reviewed by:  lutz_donnerhacke.de
  MFC after:    4 days
  Differential Revision:        https://reviews.freebsd.org/D26324

Modified:
  head/sys/net/if.c
  head/sys/net/if_epair.c

Modified: head/sys/net/if.c
==============================================================================
--- head/sys/net/if.c   Tue Sep  8 13:24:44 2020        (r365456)
+++ head/sys/net/if.c   Tue Sep  8 14:54:10 2020        (r365457)
@@ -1298,6 +1298,11 @@ 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 (0);
+
        /*
         * Perform interface-specific reassignment tasks, if provided by
         * the driver.

Modified: head/sys/net/if_epair.c
==============================================================================
--- head/sys/net/if_epair.c     Tue Sep  8 13:24:44 2020        (r365456)
+++ head/sys/net/if_epair.c     Tue Sep  8 14:54:10 2020        (r365457)
@@ -611,8 +611,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