]> git.ipfire.org Git - thirdparty/ipxe.git/commit
[netdevice] Separate concept of scope ID from network device name index
authorMichael Brown <mcb30@ipxe.org>
Sat, 14 Jan 2023 00:09:20 +0000 (00:09 +0000)
committerMichael Brown <mcb30@ipxe.org>
Sat, 14 Jan 2023 00:09:20 +0000 (00:09 +0000)
commit47af48012e2afaaf56108466fb967009670660bb
tree6548d6bf0626faddf1a1aefdc080dbd7b9590626
parentab19546386b13d6c54aea1647fac06960c544efc
[netdevice] Separate concept of scope ID from network device name index

The network device index currently serves two purposes: acting as a
sequential index for network device names ("net0", "net1", etc), and
acting as an opaque unique integer identifier used in socket address
scope IDs.

There is no particular need for these usages to be linked, and it can
lead to situations in which devices are named unexpectedly.  For
example: if a system has two network devices "net0" and "net1", a VLAN
is created as "net1-42", and then a USB NIC is connected, then the USB
NIC will be named "net3" rather than the expected "net2" since the
VLAN device "net1-42" will have consumed an index.

Separate the usages: rename the "index" field to "scope_id" (matching
its one and only use case), and assign the name without reference to
the scope ID by finding the first unused name.  For consistency,
assign the scope ID by similarly finding the first unused scope ID.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/include/ipxe/netdevice.h
src/interface/efi/efi_pxe.c
src/interface/efi/efi_snp.c
src/net/ipv4.c
src/net/ipv6.c
src/net/ndp.c
src/net/netdevice.c
src/net/peerdisc.c
src/net/udp/dhcpv6.c
src/tests/ipv6_test.c