Browse Source

[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.
tags/v0.9.6
Michael Brown 16 years ago
parent
commit
e78bcb6175

+ 1
- 18
src/arch/i386/image/nbi.c View File

@@ -366,23 +366,6 @@ static int nbi_boot32 ( struct image *image, struct imgheader *imgheader ) {
366 366
 	return rc;
367 367
 }
368 368
 
369
-/**
370
- * Guess boot network device
371
- *
372
- * @ret netdev		Boot network device
373
- */
374
-static struct net_device * guess_boot_netdev ( void ) {
375
-	struct net_device *netdev;
376
-
377
-	/* Just use the first network device */
378
-	for_each_netdev ( netdev ) {
379
-		if ( netdev->state & NETDEV_OPEN )
380
-			return netdev;
381
-	}
382
-
383
-	return NULL;
384
-}
385
-
386 369
 /**
387 370
  * Prepare DHCP parameter block for NBI image
388 371
  *
@@ -393,7 +376,7 @@ static int nbi_prepare_dhcp ( struct image *image ) {
393 376
 	struct net_device *boot_netdev;
394 377
 	int rc;
395 378
 
396
-	boot_netdev = guess_boot_netdev();
379
+	boot_netdev = last_opened_netdev();
397 380
 	if ( ! boot_netdev ) {
398 381
 		DBGC ( image, "NBI %p could not identify a network device\n",
399 382
 		       image );

+ 2
- 8
src/arch/i386/image/pxe_image.c View File

@@ -42,20 +42,14 @@ struct image_type pxe_image_type __image_type ( PROBE_PXE );
42 42
  * @ret rc		Return status code
43 43
  */
44 44
 static int pxe_exec ( struct image *image ) {
45
-	struct net_device *netdev;
46 45
 	int rc;
47 46
 
48 47
 	/* Ensure that PXE stack is ready to use */
49 48
 	pxe_init_structures();
50 49
 	pxe_hook_int1a();
51 50
 
52
-	/* Arbitrarily pick the first open network device to use for PXE */
53
-	for_each_netdev ( netdev ) {
54
-		if ( netdev->state & NETDEV_OPEN ) {
55
-			pxe_set_netdev ( netdev );
56
-			break;
57
-		}
58
-	}
51
+	/* Arbitrarily pick the most recently opened network device */
52
+	pxe_set_netdev ( last_opened_netdev() );
59 53
 
60 54
 	/* Many things will break if pxe_netdev is NULL */
61 55
 	if ( ! pxe_netdev ) {

+ 1
- 18
src/arch/i386/interface/pcbios/aoeboot.c View File

@@ -10,23 +10,6 @@
10 10
 #include <gpxe/abft.h>
11 11
 #include <int13.h>
12 12
 
13
-/**
14
- * Guess boot network device
15
- *
16
- * @ret netdev		Boot network device
17
- */
18
-static struct net_device * guess_boot_netdev ( void ) {
19
-	struct net_device *netdev;
20
-
21
-	/* Just use the first network device */
22
-	for_each_netdev ( netdev ) {
23
-		if ( netdev->state & NETDEV_OPEN )
24
-			return netdev;
25
-	}
26
-
27
-	return NULL;
28
-}
29
-
30 13
 static int aoeboot ( const char *root_path ) {
31 14
 	struct ata_device ata;
32 15
 	struct int13_drive drive;
@@ -38,7 +21,7 @@ static int aoeboot ( const char *root_path ) {
38 21
 	printf ( "AoE booting from %s\n", root_path );
39 22
 
40 23
 	/* FIXME: ugly, ugly hack */
41
-	struct net_device *netdev = guess_boot_netdev();
24
+	struct net_device *netdev = last_opened_netdev();
42 25
 
43 26
 	if ( ( rc = aoe_attach ( &ata, netdev, root_path ) ) != 0 ) {
44 27
 		printf ( "Could not attach AoE device: %s\n",

+ 1
- 18
src/arch/i386/interface/pcbios/iscsiboot.c View File

@@ -20,23 +20,6 @@ struct setting keep_san_setting __setting = {
20 20
 	.type = &setting_type_int8,
21 21
 };
22 22
 
23
-/**
24
- * Guess boot network device
25
- *
26
- * @ret netdev		Boot network device
27
- */
28
-static struct net_device * guess_boot_netdev ( void ) {
29
-	struct net_device *netdev;
30
-
31
-	/* Just use the first network device */
32
-	for_each_netdev ( netdev ) {
33
-		if ( netdev->state & NETDEV_OPEN )
34
-			return netdev;
35
-	}
36
-
37
-	return NULL;
38
-}
39
-
40 23
 static int iscsiboot ( const char *root_path ) {
41 24
 	struct scsi_device *scsi;
42 25
 	struct int13_drive *drive;
@@ -70,7 +53,7 @@ static int iscsiboot ( const char *root_path ) {
70 53
 	drive->blockdev = &scsi->blockdev;
71 54
 
72 55
 	/* FIXME: ugly, ugly hack */
73
-	struct net_device *netdev = guess_boot_netdev();
56
+	struct net_device *netdev = last_opened_netdev();
74 57
 	struct iscsi_session *iscsi =
75 58
 		container_of ( scsi->backend, struct iscsi_session, refcnt );
76 59
 	ibft_fill_data ( netdev, iscsi );

Loading…
Cancel
Save