Kaynağa Gözat

[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>
tags/v1.20.1
Michael Brown 8 yıl önce
ebeveyn
işleme
9c185e2eac
1 değiştirilmiş dosya ile 2 ekleme ve 2 silme
  1. 2
    2
      src/net/netdevice.c

+ 2
- 2
src/net/netdevice.c Dosyayı Görüntüle

676
 	}
676
 	}
677
 
677
 
678
 	/* Record device index and create device name */
678
 	/* Record device index and create device name */
679
-	netdev->index = netdev_index++;
680
 	if ( netdev->name[0] == '\0' ) {
679
 	if ( netdev->name[0] == '\0' ) {
681
 		snprintf ( netdev->name, sizeof ( netdev->name ), "net%d",
680
 		snprintf ( netdev->name, sizeof ( netdev->name ), "net%d",
682
-			   netdev->index );
681
+			   netdev_index );
683
 	}
682
 	}
683
+	netdev->index = ++netdev_index;
684
 
684
 
685
 	/* Use least significant bits of the link-layer address to
685
 	/* Use least significant bits of the link-layer address to
686
 	 * improve the randomness of the (non-cryptographic) random
686
 	 * improve the randomness of the (non-cryptographic) random

Loading…
İptal
Kaydet