Repository navigation
feat(libc): list each interface's AF_LINK entry in getifaddrs on Linux - #7988
Merged
oneandonlydean merged 1 commit intoOct 20, 2026
Merged
oneandonlydean merged 1 commit into
oneandonlydean merged 1 commit into
Conversation
getifaddrs listed only the host's IPv4 and IPv6 addresses, so the per-interface AF_LINK entries FreeBSD's getifaddrs puts first were missing, and with them the interface index, hardware address, MTU and counters and every interface without an address. On Linux each interface now starts with an AF_LINK entry, followed by its addresses, as FreeBSD 11.4's getifaddrs orders them. Its address is a sockaddr_dl with the host index, type, name and hardware address (none for a loopback), sized as FreeBSD's if_attach sizes it. Its ifa_data is a 152-byte FreeBSD if_data filled as if_data_copy fills it: type, address and header length, link state, MTU, speed and the host's packet, byte, error, drop and multicast counters from sysfs, or the host list's 32-bit counters when sysfs cannot be read. Fields with no host equivalent are 0 and listed in the debt entry. Windows is unchanged.
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
12 tasks done
12 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
getifaddrson Linux listed only the host's IPv4 and IPv6 addresses, omitting the per-interfaceAF_LINKentries that FreeBSD 11.4'sgetifaddrs.cplaces before each interface's addresses, and with them the interface index, hardware address, MTU, counters and any interface without an IP address.AF_LINK(18) entry followed by its IPv4 and IPv6 addresses, matching the ordering of FreeBSD 11.4getifaddrs.c.ifa_addris a FreeBSD 11.4sockaddr_dlwith the host interface index, type (IFT_ETHER0x6,IFT_LOOP0x18,IFT_PPP0x17, orIFT_OTHER0x1), interface name and hardware address (0 bytes on loopback), sized to at least 54 bytes (8-byte aligned) as FreeBSD 11.4'sif_attach_internalinsys/net/if.csizes it.ifa_datais a 152-byte FreeBSD 11.4if_datafilled asif_data_copyinsys/net/if.cfills it:ifi_type,ifi_addrlen,ifi_hdrlen(14 for Ethernet, 0 otherwise),ifi_link_state(LINK_STATE_UP2 orLINK_STATE_DOWN1),ifi_datalen(152),ifi_mtu(SIOCGIFMTU),ifi_baudrate(from/sys/class/net/<name>/speedin Mb/s when positive) and the 64-bit packet, error, collision, byte, multicast and drop counters from/sys/class/net/<name>/statistics/*, falling back to the 32-bitrtnl_link_statscounters fromgetifaddrswhen sysfs cannot be read.ifi_omcasts,ifi_noproto,ifi_hwassist,ifi_metric,ifi_epoch,ifi_lastchange) are 0 and recorded indocs/dev/debt/libc.md.Tested
Ubuntu 26.04.1, kernel 7.0.0-38, GCC 15.2.0, Release, full build with
BUILD_TESTING=ON. Windows was not compiled (Windows code is unchanged). No title was run.guest_interfaces: checks that each interface'sAF_LINKentry precedes its IPv4/IPv6 addresses, verifiessockaddr_dllayout (sdl_len,sdl_family18,sdl_indexagainstif_nametoindex,sdl_type,sdl_nlen,sdl_alen,sdl_slen, name and hardware address bytes) andif_datalayout (ifi_datalen152,ifi_type,ifi_addrlen,ifi_hdrlen,ifi_link_state,ifi_mtuagainstSIOCGIFMTU, and nonzero loopback packet/byte counters bounded by sysfs after sending a loopback datagram).unshare -rn) with an unaddressed interface and with thertnl_link_statscounter fallback.ifi_datalen, swappedAF_LINKordering, wrongsdl_indexoffset) each makeguest_interfacesfail.ctest --test-dir build -E '^agc' -j16 --timeout 300run passes (exceptguest_sce_net, which aborts on this host as described in test(libSceNet): accept every unusable IPv6 loopback error in guest_sce_net #7987).tools/check_conventions.py --base origin/mainpasses with zero findings.tools/pr_overlap.pylists only PR test: organize library tests and label CTest suites #6044 onGuestInterfaces.cpp(which moves test files to subdirectories) and open PRs touching unrelated lines ofdocs/dev/debt/libc.md.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)