Commit Graph
7 Commits
Author SHA1 Message Date
boykopovar f38d29fd08 refactor(sdk): add canonical headers for remaining libraries 2026-10-24 23:17:42 +03:00
mugurc 57e3e7c645 fix(libs): build getifaddrs and two tests on macOS hosts
Three recent changes use what only Linux has, so libc and two tests no
longer compile on macOS:

- The AF_LINK entries that getifaddrs lists on Linux use linux/if_link.h,
  netpacket/packet.h, sockaddr_ll and rtnl_link_stats, and were built on
  every host but Windows. They are now built on Linux only: macOS lists
  the IPv4 and IPv6 addresses as before, as Windows does, and the
  interface test checks the AF_LINK entries on Linux only.
- The NetCtlAp test loops over a braced list without including
  <initializer_list>, which libc++ does not pull in through the test's
  other headers.
- The import block test backs its 16 KiB views with memfd_create. The
  views case is now built on Linux only; macOS runs the case without
  views, as Windows does.
2026-10-20 10:29:01 +03:00
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 <[email protected]>
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