feat(libc): enumerate interface link addresses and MTU #4967
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4967"
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 Dripl1x on 2026-10-13T06:42:23Z.
What
getifaddrs currently returns only host IPv4/IPv6 addresses and omits interfaces without an IP address. Add one FreeBSD AF_LINK record per host interface, with its name, link address, index and aligned if_data containing MTU and available host statistics. Preserve the existing IPv4/IPv6 records and the single-allocation/freeifaddrs ownership model.
Windows includes unbound NDIS interfaces with GAA_FLAG_INCLUDE_ALL_INTERFACES and uses GetIfEntry2 for the L2 index, MAC and MTU, so an adapter with no IP index is still represented. Linux translates AF_PACKET records and queries MTU without changing the interface. The BSD host path translates native AF_LINK records.
The guest layouts follow FreeBSD if.h and if_dl.h. Windows enumeration follows GetAdaptersAddresses. Unrepresentable indices or link-address lengths throw instead of truncating.
Tested
Windows, supported WinLibs MinGW-w64 GCC 15.2.0; Linux, Ubuntu 26.04 under WSL, GCC 15.2.0. Release, BUILD_TESTING=ON, ordinary root configuration with bundled submodules. Windows CMake 3.28 validation used CMAKE_CXX_SCAN_FOR_MODULES=OFF for its existing MinGW module-mapper probe issue.
Built guest_interface_tests and guest_interface_link_fixture_tests, then ran:
Windows: 2/2 passed on final rebased head (0.31 s total). Linux: 2/2 passed before the latest rebase (1.02 s total); the subsequent main changes do not touch Interfaces.cpp or these tests. Based on main
ea2bbefb2.The real-host test compares every link's index, MAC and MTU with host API results, validates sockaddr/if_data lengths and alignment, and separately checks all IPv4/IPv6 records. The injected host fixture contains one interface with no unicast addresses, MAC 02:03:04:05:06:07, index 7, MTU 9000 and known counters. On Windows its IP index is zero while the L2 index is 7. The test requires exactly one usable AF_LINK record and releases it through freeifaddrs. Host network settings were not changed.
git diff --check and the repository conventions checker passed. No game or console run; macOS/BSD execution and the full test suite were not run. The FreeBSD 11 layout has not been validated against an original console library. Fields unavailable from host APIs and Linux's 32-bit statistics limitation are recorded in docs/dev/debt/libc.md. Full upstream PR builds require a collaborator's manual Build workflow.
getifaddrsandfreeifaddrs; whether one of them reads theAF_LINKrecords is not established. Details in this comment.Checklist
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T08:20:59Z.
Windows test of this PR.
Environment: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release,
BUILD_TESTING=ON,-j2,libusb-cmakefrom a local checkout. Built frommainc2565f014with this PR and ten other open PRs (#4972, #4967, #4966, #4945, #4938, #4936, #4933, #4898, #4896, #4888) merged together; the merges had no conflict.Result: guest_interfaces and guest_interface_link_fixture (2 of 2) pass.
Not checked: whether the test fails without the change in the library code; the PR was not tested alone, only in the combined merge; no title run; Linux not tested.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by Dripl1x on 2026-10-13T23:48:53Z.
Which titles reach this function, from a static survey of the homebrew catalog (no title was run):
getifaddrsandfreeifaddrs: PPSA17641, PPSA19111, PPSA69421, PPSA74126, PPSA85300, PPSA97358, PPSA97510, PPSA98510 and 21 more.AF_LINKrecords.Method: the 65 release archives listed in ps5-homebrew-catalog were downloaded (SHA-256 equal to the catalog records), 63 of them hold an
eboot.bin, which was unwrapped from its fake-signed container. Nothing was run. Imports come fromrelinker --registryandtools/import_audit.pyonmainbfc10637d. Call arguments are read from the instructions before each call site (objdump), which recovers a value only where the compiler loads a constant right before the call, so every count below is a lower bound.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-14T01:29:54Z.
Review: COMMENTED
The layouts match FreeBSD 11's
struct if_data(152 bytes, with the__ifi_epoch/__ifi_lastchangeunions at 128 and 136), and throwing on unrepresentable indices fits the repository's rules.One thing to decide explicitly: the
AF_LINKrecords carry the host's real MAC addresses to guest code, for every adapter (withGAA_FLAG_INCLUDE_ALL_INTERFACES, including the unbound and virtual ones: VPN, Hyper-V and WSL adapters, Bluetooth). Titles with network access commonly read the MAC throughgetifaddrsas a device identifier for analytics, anti-cheat or licence binding, and can send it to their servers. On the console that identifies the console. Here it identifies the user's PC and its other network hardware, which is a privacy change the user doesn't see.Some options:
APS5_REAL_LINK_ADDRESSES=1) for the cases that need the real values.Which title needs the
AF_LINKrecords? If it only needs the MTU or interface presence, the first option gives it the same answers.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T02:34:04Z.
Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.
Pull request closed