feat(libc): enumerate interface link addresses and MTU #4967

Closed
Dripl1x wants to merge 1 commit from upstream-pr/4967 into main
Dripl1x commented 2026-10-13 06:42:23 +00:00 (Migrated from github.com)

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:

ctest --test-dir build-validate --output-on-failure --no-tests=error -R '^guest_interface(s|_link_fixture)$'

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.

  • Title evidence (static, no title run): 29 of the 63 catalog executables import getifaddrs and freeifaddrs; whether one of them reads the AF_LINK records is not established. Details in this comment.

Checklist

  • Based on current main; no open PR implements these AF_LINK entries
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; unavailable host fields are documented in the library's technical debt file
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source; none added here
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes (OpenAI Codex)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4839429829 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4967). Originally posted by [Dripl1x](https://github.com/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](https://github.com/freebsd/freebsd-src/blob/releng/11.4/sys/net/if.h) and [if_dl.h](https://github.com/freebsd/freebsd-src/blob/releng/11.4/sys/net/if_dl.h). Windows enumeration follows [GetAdaptersAddresses](https://learn.microsoft.com/en-us/windows/win32/api/iphlpapi/nf-iphlpapi-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: ```sh ctest --test-dir build-validate --output-on-failure --no-tests=error -R '^guest_interface(s|_link_fixture)$' ``` 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. - Title evidence (static, no title run): 29 of the 63 catalog executables import `getifaddrs` and `freeifaddrs`; whether one of them reads the `AF_LINK` records is not established. Details in [this comment](https://github.com/boykopovar/AnyPS5/pull/4967#issuecomment-6157624667). ### Checklist - [x] Based on current main; no open PR implements these AF_LINK entries - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw; unavailable host fields are documented in the library's technical debt file - [x] No notes, investigation .md files or images added to the repository - [x] New third-party code is a submodule built from source; none added here - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes (OpenAI Codex)
xXPBSXx commented 2026-10-13 08:20:59 +00:00 (Migrated from github.com)

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-cmake from a local checkout. Built from main c2565f014 with 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).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6141391185 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4967#issuecomment-6141391185). Originally posted by [xXPBSXx](https://github.com/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-cmake` from a local checkout. Built from `main` `c2565f014` with 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).
Dripl1x commented 2026-10-13 23:48:53 +00:00 (Migrated from github.com)

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):

  • 29 of the 63 executables import getifaddrs and freeifaddrs: PPSA17641, PPSA19111, PPSA69421, PPSA74126, PPSA85300, PPSA97358, PPSA97510, PPSA98510 and 21 more.
  • What they read from the list was not recovered: the loop over the records is ordinary code, not a call argument. So this shows the function is called, not that a title needs the AF_LINK records.

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 from relinker --registry and tools/import_audit.py on main bfc10637d. 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).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6157624667 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4967#issuecomment-6157624667). Originally posted by [Dripl1x](https://github.com/Dripl1x) on 2026-10-13T23:48:53Z. --- Which titles reach this function, from a static survey of the homebrew catalog (no title was run): - 29 of the 63 executables import `getifaddrs` and `freeifaddrs`: PPSA17641, PPSA19111, PPSA69421, PPSA74126, PPSA85300, PPSA97358, PPSA97510, PPSA98510 and 21 more. - What they read from the list was not recovered: the loop over the records is ordinary code, not a call argument. So this shows the function is called, not that a title needs the `AF_LINK` records. Method: the 65 release archives listed in [ps5-homebrew-catalog](https://github.com/blackbearreloaded/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 from `relinker --registry` and `tools/import_audit.py` on `main` `bfc10637d`. 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).
CnRJay commented 2026-10-14 01:29:54 +00:00 (Migrated from github.com)

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_lastchange unions at 128 and 136), and throwing on unrepresentable indices fits the repository's rules.

One thing to decide explicitly: the AF_LINK records carry the host's real MAC addresses to guest code, for every adapter (with GAA_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 through getifaddrs as 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:

  • report a stable, locally generated MAC per interface (derived from a per-installation random seed, with the locally administered bit set), the way VMs and many emulators do. The bytes are then well-formed and stable across runs without exposing hardware identifiers;
  • list only the interfaces that carry the addresses the guest already sees, rather than every NDIS interface. A title rarely needs more, and it also avoids exposing the names of virtual adapters;
  • at least record it in the debt entry and make it a switch (APS5_REAL_LINK_ADDRESSES=1) for the cases that need the real values.

Which title needs the AF_LINK records? If it only needs the MTU or interface presence, the first option gives it the same answers.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5512020654 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4967#pullrequestreview-5512020654). Originally posted by [CnRJay](https://github.com/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_lastchange` unions at 128 and 136), and throwing on unrepresentable indices fits the repository's rules. One thing to decide explicitly: the `AF_LINK` records carry the **host's real MAC addresses** to guest code, for every adapter (with `GAA_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 through `getifaddrs` as 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: - report a stable, locally generated MAC per interface (derived from a per-installation random seed, with the locally administered bit set), the way VMs and many emulators do. The bytes are then well-formed and stable across runs without exposing hardware identifiers; - list only the interfaces that carry the addresses the guest already sees, rather than every NDIS interface. A title rarely needs more, and it also avoids exposing the names of virtual adapters; - at least record it in the debt entry and make it a switch (`APS5_REAL_LINK_ADDRESSES=1`) for the cases that need the real values. Which title needs the `AF_LINK` records? If it only needs the MTU or interface presence, the first option gives it the same answers.
oneandonlydean commented 2026-10-14 02:34:04 +00:00 (Migrated from github.com)

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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6159600845 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4967#issuecomment-6159600845). Originally posted by [oneandonlydean](https://github.com/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

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!4967
No description provided.