Browse Source

[hacks] Improve the guess_boot_netdev() logic

This function is a major kludge, but can be made slightly more
accurate by ignoring net devices that aren't open.  Eventually it
needs to be removed entirely.
tags/v0.9.6
Michael Brown 16 years ago
parent
commit
467c4f77c3
3 changed files with 12 additions and 9 deletions
  1. 4
    3
      src/arch/i386/image/nbi.c
  2. 4
    3
      src/usr/aoeboot.c
  3. 4
    3
      src/usr/iscsiboot.c

+ 4
- 3
src/arch/i386/image/nbi.c View File

372
  * @ret netdev		Boot network device
372
  * @ret netdev		Boot network device
373
  */
373
  */
374
 static struct net_device * guess_boot_netdev ( void ) {
374
 static struct net_device * guess_boot_netdev ( void ) {
375
-	struct net_device *boot_netdev;
375
+	struct net_device *netdev;
376
 
376
 
377
 	/* Just use the first network device */
377
 	/* Just use the first network device */
378
-	for_each_netdev ( boot_netdev ) {
379
-		return boot_netdev;
378
+	for_each_netdev ( netdev ) {
379
+		if ( netdev->state & NETDEV_OPEN )
380
+			return netdev;
380
 	}
381
 	}
381
 
382
 
382
 	return NULL;
383
 	return NULL;

+ 4
- 3
src/usr/aoeboot.c View File

16
  * @ret netdev		Boot network device
16
  * @ret netdev		Boot network device
17
  */
17
  */
18
 static struct net_device * guess_boot_netdev ( void ) {
18
 static struct net_device * guess_boot_netdev ( void ) {
19
-	struct net_device *boot_netdev;
19
+	struct net_device *netdev;
20
 
20
 
21
 	/* Just use the first network device */
21
 	/* Just use the first network device */
22
-	for_each_netdev ( boot_netdev ) {
23
-		return boot_netdev;
22
+	for_each_netdev ( netdev ) {
23
+		if ( netdev->state & NETDEV_OPEN )
24
+			return netdev;
24
 	}
25
 	}
25
 
26
 
26
 	return NULL;
27
 	return NULL;

+ 4
- 3
src/usr/iscsiboot.c View File

26
  * @ret netdev		Boot network device
26
  * @ret netdev		Boot network device
27
  */
27
  */
28
 static struct net_device * guess_boot_netdev ( void ) {
28
 static struct net_device * guess_boot_netdev ( void ) {
29
-	struct net_device *boot_netdev;
29
+	struct net_device *netdev;
30
 
30
 
31
 	/* Just use the first network device */
31
 	/* Just use the first network device */
32
-	for_each_netdev ( boot_netdev ) {
33
-		return boot_netdev;
32
+	for_each_netdev ( netdev ) {
33
+		if ( netdev->state & NETDEV_OPEN )
34
+			return netdev;
34
 	}
35
 	}
35
 
36
 
36
 	return NULL;
37
 	return NULL;

Loading…
Cancel
Save