summaryrefslogtreecommitdiffstats
path: root/src/net/netdevice.c
diff options
context:
space:
mode:
authorMichael Brown2013-08-29 15:10:16 +0200
committerMichael Brown2013-09-03 02:24:15 +0200
commitd5f69e93887cb9ad505b7ed6394891652f393885 (patch)
treee2d499055f10b9536db2a544eea626e722d26679 /src/net/netdevice.c
parent[netdevice] Increase maximum network-layer address length (diff)
downloadipxe-d5f69e93887cb9ad505b7ed6394891652f393885.tar.gz
ipxe-d5f69e93887cb9ad505b7ed6394891652f393885.tar.xz
ipxe-d5f69e93887cb9ad505b7ed6394891652f393885.zip
[netdevice] Add concept of a network device index
IPv6 link-local socket addresses require some way to specify a local network device. We cannot simply use a pointer to the network device, since a struct sockaddr_in6 may be long-lived and has no way to hold a reference to the network device. Using a network device index allows a socket address to cleanly refer to a network device without worrying about whether or not that device continues to exist. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/net/netdevice.c')
-rw-r--r--src/net/netdevice.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/net/netdevice.c b/src/net/netdevice.c
index 5af9c6dc..283632f6 100644
--- a/src/net/netdevice.c
+++ b/src/net/netdevice.c
@@ -498,10 +498,11 @@ int register_netdev ( struct net_device *netdev ) {
uint32_t seed;
int rc;
- /* Create device name */
+ /* Record device index and create device name */
+ netdev->index = ifindex++;
if ( netdev->name[0] == '\0' ) {
snprintf ( netdev->name, sizeof ( netdev->name ), "net%d",
- ifindex++ );
+ netdev->index );
}
/* Set initial link-layer address, if not already set */