]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[hacks] Improve the guess_boot_netdev() logic
authorMichael Brown <mcb30@etherboot.org>
Fri, 31 Oct 2008 01:51:26 +0000 (01:51 +0000)
committerMichael Brown <mcb30@etherboot.org>
Fri, 31 Oct 2008 01:51:26 +0000 (01:51 +0000)
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.

src/arch/i386/image/nbi.c
src/usr/aoeboot.c
src/usr/iscsiboot.c

index e6a0ab0f34021b7915b461e94f679dba8fea5d55..ea8375cb5c0f0330b9e5d0d7380104807f690037 100644 (file)
@@ -372,11 +372,12 @@ static int nbi_boot32 ( struct image *image, struct imgheader *imgheader ) {
  * @ret netdev         Boot network device
  */
 static struct net_device * guess_boot_netdev ( void ) {
-       struct net_device *boot_netdev;
+       struct net_device *netdev;
 
        /* Just use the first network device */
-       for_each_netdev ( boot_netdev ) {
-               return boot_netdev;
+       for_each_netdev ( netdev ) {
+               if ( netdev->state & NETDEV_OPEN )
+                       return netdev;
        }
 
        return NULL;
index 08d21c4ecf603fb334dbb23e67707e68591b1792..e977b10fe74e87a388c9fb947ef11510307be8de 100644 (file)
  * @ret netdev         Boot network device
  */
 static struct net_device * guess_boot_netdev ( void ) {
-       struct net_device *boot_netdev;
+       struct net_device *netdev;
 
        /* Just use the first network device */
-       for_each_netdev ( boot_netdev ) {
-               return boot_netdev;
+       for_each_netdev ( netdev ) {
+               if ( netdev->state & NETDEV_OPEN )
+                       return netdev;
        }
 
        return NULL;
index e0098fd2cf84f1638c9deef9ba35a630829c46f1..cdf7790bb138584cb21b9bb054c935ca067073ad 100644 (file)
@@ -26,11 +26,12 @@ struct setting keep_san_setting __setting = {
  * @ret netdev         Boot network device
  */
 static struct net_device * guess_boot_netdev ( void ) {
-       struct net_device *boot_netdev;
+       struct net_device *netdev;
 
        /* Just use the first network device */
-       for_each_netdev ( boot_netdev ) {
-               return boot_netdev;
+       for_each_netdev ( netdev ) {
+               if ( netdev->state & NETDEV_OPEN )
+                       return netdev;
        }
 
        return NULL;