Преглед изворни кода

[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 пре 15 година
родитељ
комит
e78bcb6175

+ 1
- 18
src/arch/i386/image/nbi.c Прегледај датотеку

366
 	return rc;
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
  * Prepare DHCP parameter block for NBI image
370
  * Prepare DHCP parameter block for NBI image
388
  *
371
  *
393
 	struct net_device *boot_netdev;
376
 	struct net_device *boot_netdev;
394
 	int rc;
377
 	int rc;
395
 
378
 
396
-	boot_netdev = guess_boot_netdev();
379
+	boot_netdev = last_opened_netdev();
397
 	if ( ! boot_netdev ) {
380
 	if ( ! boot_netdev ) {
398
 		DBGC ( image, "NBI %p could not identify a network device\n",
381
 		DBGC ( image, "NBI %p could not identify a network device\n",
399
 		       image );
382
 		       image );

+ 2
- 8
src/arch/i386/image/pxe_image.c Прегледај датотеку

42
  * @ret rc		Return status code
42
  * @ret rc		Return status code
43
  */
43
  */
44
 static int pxe_exec ( struct image *image ) {
44
 static int pxe_exec ( struct image *image ) {
45
-	struct net_device *netdev;
46
 	int rc;
45
 	int rc;
47
 
46
 
48
 	/* Ensure that PXE stack is ready to use */
47
 	/* Ensure that PXE stack is ready to use */
49
 	pxe_init_structures();
48
 	pxe_init_structures();
50
 	pxe_hook_int1a();
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
 	/* Many things will break if pxe_netdev is NULL */
54
 	/* Many things will break if pxe_netdev is NULL */
61
 	if ( ! pxe_netdev ) {
55
 	if ( ! pxe_netdev ) {

+ 1
- 18
src/arch/i386/interface/pcbios/aoeboot.c Прегледај датотеку

10
 #include <gpxe/abft.h>
10
 #include <gpxe/abft.h>
11
 #include <int13.h>
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
 static int aoeboot ( const char *root_path ) {
13
 static int aoeboot ( const char *root_path ) {
31
 	struct ata_device ata;
14
 	struct ata_device ata;
32
 	struct int13_drive drive;
15
 	struct int13_drive drive;
38
 	printf ( "AoE booting from %s\n", root_path );
21
 	printf ( "AoE booting from %s\n", root_path );
39
 
22
 
40
 	/* FIXME: ugly, ugly hack */
23
 	/* FIXME: ugly, ugly hack */
41
-	struct net_device *netdev = guess_boot_netdev();
24
+	struct net_device *netdev = last_opened_netdev();
42
 
25
 
43
 	if ( ( rc = aoe_attach ( &ata, netdev, root_path ) ) != 0 ) {
26
 	if ( ( rc = aoe_attach ( &ata, netdev, root_path ) ) != 0 ) {
44
 		printf ( "Could not attach AoE device: %s\n",
27
 		printf ( "Could not attach AoE device: %s\n",

+ 1
- 18
src/arch/i386/interface/pcbios/iscsiboot.c Прегледај датотеку

20
 	.type = &setting_type_int8,
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
 static int iscsiboot ( const char *root_path ) {
23
 static int iscsiboot ( const char *root_path ) {
41
 	struct scsi_device *scsi;
24
 	struct scsi_device *scsi;
42
 	struct int13_drive *drive;
25
 	struct int13_drive *drive;
70
 	drive->blockdev = &scsi->blockdev;
53
 	drive->blockdev = &scsi->blockdev;
71
 
54
 
72
 	/* FIXME: ugly, ugly hack */
55
 	/* FIXME: ugly, ugly hack */
73
-	struct net_device *netdev = guess_boot_netdev();
56
+	struct net_device *netdev = last_opened_netdev();
74
 	struct iscsi_session *iscsi =
57
 	struct iscsi_session *iscsi =
75
 		container_of ( scsi->backend, struct iscsi_session, refcnt );
58
 		container_of ( scsi->backend, struct iscsi_session, refcnt );
76
 	ibft_fill_data ( netdev, iscsi );
59
 	ibft_fill_data ( netdev, iscsi );

Loading…
Откажи
Сачувај