summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brown2008-11-21 21:34:42 +0100
committerMichael Brown2008-11-21 21:34:42 +0100
commite78bcb6175a2481cd985a754979d789abebd66c8 (patch)
tree6742130621b89da7630268c60ebc28758eb84a12
parent[netdevice] Provide function to retrieve the most recently opened net device (diff)
downloadipxe-e78bcb6175a2481cd985a754979d789abebd66c8.tar.gz
ipxe-e78bcb6175a2481cd985a754979d789abebd66c8.tar.xz
ipxe-e78bcb6175a2481cd985a754979d789abebd66c8.zip
[netdevice] Kill off the various guess_boot_netdev() functions
Remove the assortment of miscellaneous hacks to guess the "network boot device", and replace them each with a call to last_opened_netdev(). It still isn't guaranteed correct, but it won't be any worse than before, and it will at least be consistent.
-rw-r--r--src/arch/i386/image/nbi.c19
-rw-r--r--src/arch/i386/image/pxe_image.c10
-rw-r--r--src/arch/i386/interface/pcbios/aoeboot.c19
-rw-r--r--src/arch/i386/interface/pcbios/iscsiboot.c19
4 files changed, 5 insertions, 62 deletions
diff --git a/src/arch/i386/image/nbi.c b/src/arch/i386/image/nbi.c
index ea8375cb..a4ee4420 100644
--- a/src/arch/i386/image/nbi.c
+++ b/src/arch/i386/image/nbi.c
@@ -367,23 +367,6 @@ static int nbi_boot32 ( struct image *image, struct imgheader *imgheader ) {
}
/**
- * Guess boot network device
- *
- * @ret netdev Boot network device
- */
-static struct net_device * guess_boot_netdev ( void ) {
- struct net_device *netdev;
-
- /* Just use the first network device */
- for_each_netdev ( netdev ) {
- if ( netdev->state & NETDEV_OPEN )
- return netdev;
- }
-
- return NULL;
-}
-
-/**
* Prepare DHCP parameter block for NBI image
*
* @v image NBI image
@@ -393,7 +376,7 @@ static int nbi_prepare_dhcp ( struct image *image ) {
struct net_device *boot_netdev;
int rc;
- boot_netdev = guess_boot_netdev();
+ boot_netdev = last_opened_netdev();
if ( ! boot_netdev ) {
DBGC ( image, "NBI %p could not identify a network device\n",
image );
diff --git a/src/arch/i386/image/pxe_image.c b/src/arch/i386/image/pxe_image.c
index 346d2048..3b5214d7 100644
--- a/src/arch/i386/image/pxe_image.c
+++ b/src/arch/i386/image/pxe_image.c
@@ -42,20 +42,14 @@ struct image_type pxe_image_type __image_type ( PROBE_PXE );
* @ret rc Return status code
*/
static int pxe_exec ( struct image *image ) {
- struct net_device *netdev;
int rc;
/* Ensure that PXE stack is ready to use */
pxe_init_structures();
pxe_hook_int1a();
- /* Arbitrarily pick the first open network device to use for PXE */
- for_each_netdev ( netdev ) {
- if ( netdev->state & NETDEV_OPEN ) {
- pxe_set_netdev ( netdev );
- break;
- }
- }
+ /* Arbitrarily pick the most recently opened network device */
+ pxe_set_netdev ( last_opened_netdev() );
/* Many things will break if pxe_netdev is NULL */
if ( ! pxe_netdev ) {
diff --git a/src/arch/i386/interface/pcbios/aoeboot.c b/src/arch/i386/interface/pcbios/aoeboot.c
index e977b10f..6e1e51cb 100644
--- a/src/arch/i386/interface/pcbios/aoeboot.c
+++ b/src/arch/i386/interface/pcbios/aoeboot.c
@@ -10,23 +10,6 @@
#include <gpxe/abft.h>
#include <int13.h>
-/**
- * Guess boot network device
- *
- * @ret netdev Boot network device
- */
-static struct net_device * guess_boot_netdev ( void ) {
- struct net_device *netdev;
-
- /* Just use the first network device */
- for_each_netdev ( netdev ) {
- if ( netdev->state & NETDEV_OPEN )
- return netdev;
- }
-
- return NULL;
-}
-
static int aoeboot ( const char *root_path ) {
struct ata_device ata;
struct int13_drive drive;
@@ -38,7 +21,7 @@ static int aoeboot ( const char *root_path ) {
printf ( "AoE booting from %s\n", root_path );
/* FIXME: ugly, ugly hack */
- struct net_device *netdev = guess_boot_netdev();
+ struct net_device *netdev = last_opened_netdev();
if ( ( rc = aoe_attach ( &ata, netdev, root_path ) ) != 0 ) {
printf ( "Could not attach AoE device: %s\n",
diff --git a/src/arch/i386/interface/pcbios/iscsiboot.c b/src/arch/i386/interface/pcbios/iscsiboot.c
index cdf7790b..02aec4ba 100644
--- a/src/arch/i386/interface/pcbios/iscsiboot.c
+++ b/src/arch/i386/interface/pcbios/iscsiboot.c
@@ -20,23 +20,6 @@ struct setting keep_san_setting __setting = {
.type = &setting_type_int8,
};
-/**
- * Guess boot network device
- *
- * @ret netdev Boot network device
- */
-static struct net_device * guess_boot_netdev ( void ) {
- struct net_device *netdev;
-
- /* Just use the first network device */
- for_each_netdev ( netdev ) {
- if ( netdev->state & NETDEV_OPEN )
- return netdev;
- }
-
- return NULL;
-}
-
static int iscsiboot ( const char *root_path ) {
struct scsi_device *scsi;
struct int13_drive *drive;
@@ -70,7 +53,7 @@ static int iscsiboot ( const char *root_path ) {
drive->blockdev = &scsi->blockdev;
/* FIXME: ugly, ugly hack */
- struct net_device *netdev = guess_boot_netdev();
+ struct net_device *netdev = last_opened_netdev();
struct iscsi_session *iscsi =
container_of ( scsi->backend, struct iscsi_session, refcnt );
ibft_fill_data ( netdev, iscsi );