Commit Graph
5 Commits
Author SHA1 Message Date
Federico Marras 792fb27631 feat(libc): list each interface's AF_LINK entry in getifaddrs on Linux
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.
2026-10-19 18:57:12 +02:00
milescovielloandClaude Opus 5.5 18cf27aaba fix(libc): allocate the getifaddrs list on the application heap
FreeBSD's freeifaddrs is a plain free of the list, and Doom 3 BFG
(PPSA99313) releases the list with free. The list came from host malloc,
so the guest free stopped on an unregistered allocation; it now comes
from the application heap, and freeifaddrs returns it there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 18:31:36 +00:00
LuisBiceps 5c0610f334 feat(libc): keep getifaddrs flags consistent with their addresses on 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.
2026-10-10 10:23:55 +02:00
LuisBiceps a09b67b142 feat(libc): report getifaddrs errors through errno and handle Windows 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.
2026-10-10 10:23:55 +02:00
LuisBiceps 7cd185ec79 feat(libc): implement getifaddrs and freeifaddrs
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.
2026-10-10 10:23:55 +02:00