feat(libc): list each interface's AF_LINK entry in getifaddrs on Linux #7988
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7988"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by MarrasFederico on 2026-10-19T17:06:25Z.
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 #7987).tools/check_conventions.py --base origin/mainpasses with zero findings.tools/pr_overlap.pylists only PR #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)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T17:33:26Z.
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.
docs/dev/debt/libc.mddocs/dev/debt/libc.mdcore/libs/tests/GuestInterfaces.cppdocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.mddocs/dev/debt/libc.md