Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 24 Oct 2019 03:20:27 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r353990 - stable/12/stand/efi/libefi
Message-ID:  <201910240320.x9O3KSNK013489@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Thu Oct 24 03:20:27 2019
New Revision: 353990
URL: https://svnweb.freebsd.org/changeset/base/353990

Log:
  MFC r349201: efinet: Defer exclusively opening the network handles
  
  Don't commit to exclusive access to the network device handle by
  efinet until the loader has decided to load something through the
  network. This allows for the possibility of other users of the
  network device.

Modified:
  stable/12/stand/efi/libefi/efinet.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/stand/efi/libefi/efinet.c
==============================================================================
--- stable/12/stand/efi/libefi/efinet.c	Thu Oct 24 03:19:45 2019	(r353989)
+++ stable/12/stand/efi/libefi/efinet.c	Thu Oct 24 03:20:27 2019	(r353990)
@@ -108,7 +108,25 @@ efinet_match(struct netif *nif, void *machdep_hint)
 static int
 efinet_probe(struct netif *nif, void *machdep_hint)
 {
+	EFI_SIMPLE_NETWORK *net;
+	EFI_HANDLE h;
+	EFI_STATUS status;
 
+	h = nif->nif_driver->netif_ifs[nif->nif_unit].dif_private;
+	/*
+	 * Open the network device in exclusive mode. Without this
+	 * we will be racing with the UEFI network stack. It will
+	 * pull packets off the network leading to lost packets.
+	 */
+	status = BS->OpenProtocol(h, &sn_guid, (void **)&net,
+	    IH, NULL, EFI_OPEN_PROTOCOL_EXCLUSIVE);
+	if (status != EFI_SUCCESS) {
+		printf("Unable to open network interface %d for "
+		    "exclusive access: %lu\n", nif->nif_unit,
+		    EFI_ERROR_CODE(status));
+		return (efi_status_to_errno(status));
+	}
+
 	return (0);
 }
 
@@ -269,7 +287,6 @@ efinet_dev_init()
 	struct netif_dif *dif;
 	struct netif_stats *stats;
 	EFI_DEVICE_PATH *devpath, *node;
-	EFI_SIMPLE_NETWORK *net;
 	EFI_HANDLE *handles, *handles2;
 	EFI_STATUS status;
 	UINTN sz;
@@ -304,19 +321,6 @@ efinet_dev_init()
 		if (DevicePathType(node) != MESSAGING_DEVICE_PATH ||
 		    DevicePathSubType(node) != MSG_MAC_ADDR_DP)
 			continue;
-
-		/*
-		 * Open the network device in exclusive mode. Without this
-		 * we will be racing with the UEFI network stack. It will
-		 * pull packets off the network leading to lost packets.
-		 */
-		status = BS->OpenProtocol(handles[i], &sn_guid, (void **)&net,
-		    IH, NULL, EFI_OPEN_PROTOCOL_EXCLUSIVE);
-		if (status != EFI_SUCCESS) {
-			printf("Unable to open network interface %d for "
-			    "exclusive access: %lu\n", i,
-			    EFI_ERROR_CODE(status));
-		}
 
 		handles2[nifs] = handles[i];
 		nifs++;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201910240320.x9O3KSNK013489>