Repository navigation
feat(libc): implement getifaddrs and freeifaddrs - #1772
Conversation
|
Linux run (the description lists Windows and WSL2): CachyOS, kernel 7.2.9, GCC 16.2.1, Release with
AI-assisted: yes (Claude Code). |
|
Thanks for testing on a TUN host. That failure is fixed in the current head, 4f10bd0, pushed after your run. An address on a point-to-point interface without a peer of the same family now loses |
|
A title reaches
|
|
A title that stops first on this: PSBox Cloud Gaming (PPSA99810, v0.8.0 from the homebrew catalog), relinked for Linux and run on
|
|
Thanks @CouchRiv. It reproduces on Windows, and with this PR PSBox Cloud Gaming moves on to the next import. Version 0.7.0 is the catalog's and 0.8.0 is its newest release. Both, relinked with
The branch was conflicting in TechnicalDebt, so I merged |
|
Please rebase onto main and force-push instead of merging main into the branch (f4e507f); merge commits aren't taken here. |
List the host's IPv4 and IPv6 addresses in FreeBSD's struct ifaddrs layout, with FreeBSD sockaddrs and interface flags, from getifaddrs on Linux and GetAdaptersAddresses on Windows. The list is one allocation, so freeifaddrs is a single free.
… edge cases Return -1 with the FreeBSD errno for a null list and for expected host and allocation failures, as getcwd does. On Windows, give an unspecified prefix length a host mask, leave PPP and tunnel adapters without broadcast or point-to-point flags since their peer address is not reported, fall back to if<index> for long NDIS names, and bound the adapter query retries. Compare every entry with the host's own list in the test.
…Linux Drop IFF_POINTOPOINT from an address without a peer and compute an IPv4 broadcast address the host omits from the netmask, since FreeBSD always provides the address when the flag is set. Check zero port, flowinfo and padding in the test.
f4e507f to
dff45a0
Compare
|
Rebased onto current Checked on Linux: scoped build and ctest (58 tests) green, |
… from lines other pull requests change The guest_interfaces test now follows guest_thread_callback_abi instead of guest_errors, and the TechnicalDebt entry follows the libc SSE4a trap emulation entry instead of ending the Functional list, where other open pull requests add theirs.
dff45a0 to
63a20d6
Compare
|
Thanks for rebasing it. The replayed last commit added the The |
|
Independent validation on Windows Built and ran the PR head
Results:
Rigor check (is the test real, or a pass-through?): I deliberately broke the Windows flag translation — changed Honest limits of what I verified:
Written with AI assistance. |
|
Title check on current
Example lines for PS5MC: |
What
Implements
getifaddrs(NIDj-gWL6wDros) andfreeifaddrs(NIDN2OjwJJGjeQ) in libc. 16 of the homebrew titles in the #1578 audit import both from libSceLibcInternal, which resolves through libc.struct ifaddrswith FreeBSDsockaddr_in/sockaddr_in6(length byte,AF_INET2,AF_INET628). Every entry has a netmask. Broadcast interfaces get the IPv4 broadcast address, point-to-point interfaces the destination address. Flags use FreeBSD's values (IFF_MULTICASTis0x8000, not Linux's0x1000).getifaddrs. Windows readsGetAdaptersAddresses: names fromConvertInterfaceLuidToNameA(NDIS names such asloopback_0), netmask fromOnLinkPrefixLength, broadcast from the address and netmask.freeifaddrsis a singlefree.errno, asgetcwdhere does: a null list pointer givesEFAULT, and host or allocation failures giveENOMEM,ENOBUFS,EMFILEorENFILE. Any other host failure throws.IFF_POINTOPOINT, and an IPv4 broadcast address the host omits is computed from the netmask, so a flag always comes with its address, as on FreeBSD.IFF_UP,IFF_RUNNING,IFF_LOOPBACK,IFF_BROADCASTandIFF_MULTICAST, derived from the adapter.IFF_BROADCASTnorIFF_POINTOPOINT, since their peer address is not reported and FreeBSD always fillsifa_dstaddrwithIFF_POINTOPOINT.IFNAMSIZis 16) becomesif<index>.AF_LINKentries and theirif_dataare not produced, so interfaces without an address are omitted.Tested
guest_interfacestest, registered in ctest:getifaddrson Linux,GetAdaptersAddresseson Windows). Family, address, netmask and IPv6 scope id must match, with up to 3 attempts in case DHCP or a VPN changes an address between the two snapshots.127.0.0.1/8withIFF_UP | IFF_LOOPBACKand noIFF_BROADCAST.getifaddrs(nullptr)must return -1 withEFAULT, andfreeifaddrs(nullptr)must return.IFF_MULTICASTleaking through, the loopback flag dropped, loopback marked broadcast);errno.15.2.0posix-14.0.0-ucrt-r7), Release, onmainc963432:guest_interfacespasses (--repeat until-fail:3), and so does the full suite. The NID-patchedlibc.prxexports both NIDs.ANYPS5_ENABLE_SPIRV_TOOLS=ON, onmainc963432:guest_interfacespasses (--repeat until-fail:3), and so does the full suite.tools/check_test_registration.pyandtools/check_conventions.pypass.--windows(bundledlibc.prxunwrapped) and run on Windows 10:mainc963432:FAIL: unresolved ELF import j-gWL6wDros from libSceLibcInternal.prx(getifaddrs)mainc963432 + this PR: PSBoxFAIL: unresolved ELF import oxMp8uPqa+U from libkernel.prx(pthread_set_name_np), Cloud PlayFAIL: unresolved ELF import 04AjkP0jO9U from libkernel.prx(_umtx_op, feat(libkernel): implement _umtx_op wait and wake operations #1482)main197ffac, after fix(relinker): reject guest modules in SELF containers #2605, with each title's ownlibc.prxloaded, on Linux (Ubuntu 24.04) and Windows 11: four catalog titles stop at these functions, and all four get past them with this PR.mainj-gWL6wDros(getifaddrs)0NJDcQ2B8vE(execvp)j-gWL6wDros(getifaddrs)04AjkP0jO9U(_umtx_op, #1482)N2OjwJJGjeQ(freeifaddrs)5G2ONUzRgjY(memrchr)j-gWL6wDros(getifaddrs)oxMp8uPqa+U(pthread_set_name_np)Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)