Page MenuHomeFreeBSD

libc: make getaddrinfo(AI_ADDRCONFIG) more robust
Needs ReviewPublic

Authored by sobomax on Dec 22 2024, 1:42 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Oct 4, 3:02 AM
Unknown Object (File)
Thu, Oct 2, 2:09 PM
Unknown Object (File)
Sep 13 2025, 7:56 AM
Unknown Object (File)
Sep 12 2025, 5:07 PM
Unknown Object (File)
Sep 11 2025, 12:07 AM
Unknown Object (File)
Sep 10 2025, 5:04 PM
Unknown Object (File)
Sep 9 2025, 2:25 AM
Unknown Object (File)
Sep 8 2025, 9:32 AM
Subscribers
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Summary

The AI_ADDRCONFIG is not very well defined (and not even documented at the man page), and the way it's implemented involves invoking PF_ROUTE ioctl(2) to get list of interfaces with all addresses assigned to them. The problem is that if we run in a restricted or foreign environment, such as under user-space emulation or say something like Cloud ABI, capsicum etc, the ioctl(2) interface may be severely restricted or not available at all.

Also, conceptually, using this just to figure out which protocols are available is a bit of an overkill.

Own on itself this all would not be a huge problem (obscure flag etc), however the libfetch is requesting this flag, so anything that uses it would fail if the said ioctl() fails (pkg, fetch, etc). This patch addresses the issue by providing a simpler fallback routine that uses just a regular socket/bind to determine if any of the requested protocol families are active.

Test Plan

This patch should not change behavior in the "normal" FreeBSD environment.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped