diff options
author | Michael Brown <mcb30@ipxe.org> | 2015-07-21 14:51:16 +0100 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2015-07-28 13:48:29 +0100 |
commit | 9c185e2eac39561c2e9847c355c5b710c3e557b5 (patch) | |
tree | a423a7f2e1af836bf61e1ef42b31e9aa5b1eef53 /src | |
parent | 41670ca2fe6990b115ab717bcfd4af1e1e44c419 (diff) | |
download | ipxe-9c185e2eac39561c2e9847c355c5b710c3e557b5.zip ipxe-9c185e2eac39561c2e9847c355c5b710c3e557b5.tar.gz ipxe-9c185e2eac39561c2e9847c355c5b710c3e557b5.tar.bz2 |
[netdevice] Avoid using zero as a network device index
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/net/netdevice.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/net/netdevice.c b/src/net/netdevice.c index 889b00c..7c40a2a 100644 --- a/src/net/netdevice.c +++ b/src/net/netdevice.c @@ -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 |