Skip to content

Commit

Permalink
[netdevice] Avoid using zero as a network device index
Browse files Browse the repository at this point in the history
Avoid using zero as a network device index, so that a zero
sin6_scope_id can be used to mean "unspecified" (rather than
unintentionally meaning "net0").

Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed Jul 28, 2015
1 parent 41670ca commit 9c185e2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/net/netdevice.c
Expand Up @@ -676,11 +676,11 @@ int register_netdev ( struct net_device *netdev ) {
}

/* Record device index and create device name */
netdev->index = netdev_index++;
if ( netdev->name[0] == '\0' ) {
snprintf ( netdev->name, sizeof ( netdev->name ), "net%d",
netdev->index );
netdev_index );
}
netdev->index = ++netdev_index;

/* Use least significant bits of the link-layer address to
* improve the randomness of the (non-cryptographic) random
Expand Down

0 comments on commit 9c185e2

Please sign in to comment.