sockets: skip NULL ifa_addr entries in get_interfaces instead of stopping - #56
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in the Unix implementation of rpp::ipinterface::get_interfaces where network interface enumeration would stop prematurely. The previous code used ifa->ifa_addr as part of the for loop continuation condition, meaning that as soon as getifaddrs returned an entry with ifa_addr == NULL (common for MAC-less TUN interfaces such as tailscale0 or wireguard), the loop terminated. This could result in an empty interface list. Since get_interfaces is a public API that also feeds get_ip_interface, get_system_ip, and get_broadcast_ip, this fix improves reliability of interface discovery on Linux/Unix systems that use such interfaces.
Changes:
- Moved the
ifa->ifa_addrNULL check out of the loop-continuation condition and into the loop body in both the counting and populating loops, so NULL entries are skipped instead of stopping enumeration. - Kept the counting loop and populating loop guards identical, ensuring the reserved capacity matches the number of emitted interfaces.
- Removed a trailing blank line at the end of the file.
|
Should notify about PR next time, this was hanging for a while 😄 |
mama install-clang-21 runs apt-get install clang-21, and the CI image has no such package, so five jobs failed before they built anything: E: Package 'clang-21' has no installation candidate The matrix now uses clang-20 for the header builds, and the clang-21 modules job is gone. CMakeLists.txt requires Clang 21 for modules, so clang-20 falls back to headers on its own and prints the reason. gcc-14 still carries the modules job, and it moves from tsan to asan. BUGS.md gains B0, a triage against PR #56. Four TSAN jobs were already red on master before this branch, which is B1 reproducing in CI. Three other jobs regressed here and their logs are not reachable from this machine.
getifaddrs may return entries with ifa_addr==NULL, for example a MAC-less TUN like tailscale0 or wireguard. The loop used
ifa->ifa_addras its continuation condition, so enumeration stopped at the first such entry returning an empty list.