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.
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.
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]>
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.
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.
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.