diff options
author | Rebecca Cran <bcran@FreeBSD.org> | 2019-06-19 18:47:44 +0000 |
---|---|---|
committer | Rebecca Cran <bcran@FreeBSD.org> | 2019-06-19 18:47:44 +0000 |
commit | 3109cebc227c0964e24853d3a7ff5423514270ad (patch) | |
tree | 9b2f1452917d7792b170a15eaf7fe9cf489e1038 /stand/efi | |
parent | ab877e64d0580feaac3a510b11f553c6d10b0013 (diff) | |
download | src-3109cebc227c0964e24853d3a7ff5423514270ad.tar.gz src-3109cebc227c0964e24853d3a7ff5423514270ad.zip |
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.
Submitted by: scottph
Reviewed by: tsoome, emaste
Tested by: tsoome, bcran
Differential Revision: https://reviews.freebsd.org/D20642
Notes
Notes:
svn path=/head/; revision=349201
Diffstat (limited to 'stand/efi')
-rw-r--r-- | stand/efi/libefi/efinet.c | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/stand/efi/libefi/efinet.c b/stand/efi/libefi/efinet.c index 8a3e418ef28c..ff8988d7e33c 100644 --- a/stand/efi/libefi/efinet.c +++ b/stand/efi/libefi/efinet.c @@ -108,6 +108,24 @@ 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; @@ -305,19 +322,6 @@ efinet_dev_init() 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++; } |