mirror of
https://github.com/ipxe/ipxe
synced 2025-12-18 02:20:19 +03:00
[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>
This commit is contained in:
@@ -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
|
* Called before a fresh boot attempt in order to free up memory. We
|
||||||
* don't just close the device immediately after the boot fails,
|
* don't just close the device immediately after the boot fails,
|
||||||
* because there may still be TCP connections in the process of
|
* because there may still be TCP connections in the process of
|
||||||
* closing.
|
* closing.
|
||||||
*/
|
*/
|
||||||
static void close_all_netdevs ( void ) {
|
static void close_other_netdevs ( struct net_device *netdev ) {
|
||||||
struct net_device *netdev;
|
struct net_device *other;
|
||||||
|
|
||||||
for_each_netdev ( netdev ) {
|
for_each_netdev ( other ) {
|
||||||
ifclose ( netdev );
|
if ( other != netdev )
|
||||||
|
ifclose ( other );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -388,7 +389,7 @@ int netboot ( struct net_device *netdev ) {
|
|||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Close all other network devices */
|
/* Close all other network devices */
|
||||||
close_all_netdevs();
|
close_other_netdevs ( netdev );
|
||||||
|
|
||||||
/* Open device and display device status */
|
/* Open device and display device status */
|
||||||
if ( ( rc = ifopen ( netdev ) ) != 0 )
|
if ( ( rc = ifopen ( netdev ) ) != 0 )
|
||||||
|
|||||||
Reference in New Issue
Block a user