Skip to content

sockets: skip NULL ifa_addr entries in get_interfaces instead of stopping - #56

Merged
RedFox20 merged 1 commit into
masterfrom
fix/null-ifa-addr
Aug 11, 2026
Merged

sockets: skip NULL ifa_addr entries in get_interfaces instead of stopping #56
RedFox20 merged 1 commit into
masterfrom
fix/null-ifa-addr

Conversation

@a-rank

@a-rank a-rank commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

getifaddrs may return entries with ifa_addr==NULL, for example a MAC-less TUN like tailscale0 or wireguard. The loop used ifa->ifa_addr as its continuation condition, so enumeration stopped at the first such entry returning an empty list.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_addr NULL 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.

@RedFox20
RedFox20 merged commit 4af04f8 into master Aug 11, 2026
13 of 22 checks passed
@RedFox20
RedFox20 deleted the fix/null-ifa-addr branch August 11, 2026 19:04
@RedFox20

Copy link
Copy Markdown
Owner

Should notify about PR next time, this was hanging for a while 😄

RedFox20 added a commit that referenced this pull request Aug 12, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants