Module Name:    src
Committed By:   rin
Date:           Thu Sep 14 03:08:31 UTC 2023

Modified Files:
        src/sys/lib/libsa: netif.c

Log Message:
netif_open: Fail with ENXIO instead of panic if no netif available

Avoid undesirable freeze for efiboot/x86 when interfaces are really
unavailable, or fail to be configured by buggy UEFI firmware.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/lib/libsa/netif.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/lib/libsa/netif.c
diff -u src/sys/lib/libsa/netif.c:1.26 src/sys/lib/libsa/netif.c:1.27
--- src/sys/lib/libsa/netif.c:1.26	Sun Mar 31 20:08:45 2019
+++ src/sys/lib/libsa/netif.c	Thu Sep 14 03:08:31 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: netif.c,v 1.26 2019/03/31 20:08:45 christos Exp $	*/
+/*	$NetBSD: netif.c,v 1.27 2023/09/14 03:08:31 rin Exp $	*/
 
 /*
  * Copyright (c) 1993 Adam Glass
@@ -292,8 +292,10 @@ fnd:
 	(void)memset(s, 0, sizeof(*s));
 	netif_init();
 	nif = netif_select(machdep_hint);
-	if (!nif)
-		panic("netboot: no interfaces left untried");
+	if (!nif) {
+		errno = ENXIO;
+		return -1;
+	}
 	if (netif_probe(nif, machdep_hint)) {
 		printf("%s: couldn't probe %s%d\n", __func__,
 		    nif->nif_driver->netif_bname, nif->nif_unit);

Reply via email to