aboutsummaryrefslogtreecommitdiff
path: root/src/usr/autoboot.c
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2021-02-01 23:32:34 +0000
committerMichael Brown <mcb30@ipxe.org>2021-02-01 23:33:50 +0000
commit0c94659a8ab29cfd4e20b35bf98e364de9901d77 (patch)
treef0aa4648d6fd9baf09b85d05e3b7fe9927f3c7eb /src/usr/autoboot.c
parent6f1cb791ee7939c7302c8f815d178e89295b0eda (diff)
downloadipxe-0c94659a8ab29cfd4e20b35bf98e364de9901d77.zip
ipxe-0c94659a8ab29cfd4e20b35bf98e364de9901d77.tar.gz
ipxe-0c94659a8ab29cfd4e20b35bf98e364de9901d77.tar.bz2
[autoboot] Avoid closing and immediately reopening network device
Some network devices can take a substantial time to close and reopen. Avoid closing the device from which we are about to attempt booting, in case it happens to be already open. Suggested-by: Christian Iversen <ci@iversenit.dk> Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/usr/autoboot.c')
-rw-r--r--src/usr/autoboot.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/usr/autoboot.c b/src/usr/autoboot.c
index 51b07e1..62e90ec 100644
--- a/src/usr/autoboot.c
+++ b/src/usr/autoboot.c
@@ -210,18 +210,19 @@ int uriboot ( struct uri *filename, struct uri **root_paths,
}
/**
- * Close all open net devices
+ * Close all but one network device
*
* Called before a fresh boot attempt in order to free up memory. We
* don't just close the device immediately after the boot fails,
* because there may still be TCP connections in the process of
* closing.
*/
-static void close_all_netdevs ( void ) {
- struct net_device *netdev;
+static void close_other_netdevs ( struct net_device *netdev ) {
+ struct net_device *other;
- for_each_netdev ( netdev ) {
- ifclose ( netdev );
+ for_each_netdev ( other ) {
+ if ( other != netdev )
+ ifclose ( other );
}
}
@@ -388,7 +389,7 @@ int netboot ( struct net_device *netdev ) {
int rc;
/* Close all other network devices */
- close_all_netdevs();
+ close_other_netdevs ( netdev );
/* Open device and display device status */
if ( ( rc = ifopen ( netdev ) ) != 0 )