Skip to content

Commit

Permalink
[hacks] Improve the guess_boot_netdev() logic
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Michael Brown committed Oct 31, 2008
1 parent 0a6c66a commit 467c4f7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
7 changes: 4 additions & 3 deletions src/arch/i386/image/nbi.c
Expand Up @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions src/usr/aoeboot.c
Expand Up @@ -16,11 +16,12 @@
* @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;
Expand Down
7 changes: 4 additions & 3 deletions src/usr/iscsiboot.c
Expand Up @@ -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;
Expand Down

0 comments on commit 467c4f7

Please sign in to comment.