浏览代码

[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 17 年前
父节点
当前提交
467c4f77c3
共有 3 个文件被更改,包括 12 次插入9 次删除
  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 查看文件

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 查看文件

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 查看文件

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;

正在加载...
取消
保存