svn commit: r345657 - head/sys/net

Eric Joyner erj at FreeBSD.org
Thu Mar 28 20:43:48 UTC 2019


Author: erj
Date: Thu Mar 28 20:43:47 2019
New Revision: 345657
URL: https://svnweb.freebsd.org/changeset/base/345657

Log:
  iflib: hold the CTX lock in iflib_pseudo_register
  
  From Jake:
  The iflib_device_register function takes the CTX lock before calling
  IFDI_ATTACH_PRE, and releases it upon finishing the registration.
  
  Mirror this process in iflib_pseudo_register, so that we always hold the
  CTX lock during the attach process when registering a pseudo interface
  or a regular interface.
  
  This was caught by code inspection while attempting to analyze where the
  CTX lock was held.
  
  Submitted by:	Jacob Keller <jacob.e.keller at intel.com>
  Reviewed by:	shurd@, erj@
  MFC after:	1 week
  Sponsored by:	Intel Corporation
  Differential Revision:	https://reviews.freebsd.org/D19604

Modified:
  head/sys/net/iflib.c

Modified: head/sys/net/iflib.c
==============================================================================
--- head/sys/net/iflib.c	Thu Mar 28 20:41:02 2019	(r345656)
+++ head/sys/net/iflib.c	Thu Mar 28 20:43:47 2019	(r345657)
@@ -4662,10 +4662,10 @@ iflib_pseudo_register(device_t dev, if_shared_ctx_t sc
 	 * XXX sanity check that ntxd & nrxd are a power of 2
 	 */
 	iflib_reset_qvalues(ctx);
-
+	CTX_LOCK(ctx);
 	if ((err = IFDI_ATTACH_PRE(ctx)) != 0) {
 		device_printf(dev, "IFDI_ATTACH_PRE failed %d\n", err);
-		goto fail_ctx_free;
+		goto fail_unlock;
 	}
 	if (sctx->isc_flags & IFLIB_GEN_MAC)
 		iflib_gen_mac(ctx);
@@ -4819,6 +4819,7 @@ iflib_pseudo_register(device_t dev, if_shared_ctx_t sc
 	if_setgetcounterfn(ctx->ifc_ifp, iflib_if_get_counter);
 	iflib_add_device_sysctl_post(ctx);
 	ctx->ifc_flags |= IFC_INIT_DONE;
+	CTX_UNLOCK(ctx);
 	return (0);
 fail_detach:
 	ether_ifdetach(ctx->ifc_ifp);
@@ -4827,6 +4828,8 @@ fail_queues:
 	iflib_rx_structures_free(ctx);
 fail_iflib_detach:
 	IFDI_DETACH(ctx);
+fail_unlock:
+	CTX_UNLOCK(ctx);
 fail_ctx_free:
 	free(ctx->ifc_softc, M_IFLIB);
 	free(ctx, M_IFLIB);


More information about the svn-src-head mailing list