Page MenuHomeFreeBSD

libc/getaddrinfo(2): return EAI_AGAIN on nameserver timeout
ClosedPublic

Authored by glebius on Mar 18 2025, 11:51 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Nov 5, 12:55 PM
Unknown Object (File)
Wed, Oct 29, 2:16 PM
Unknown Object (File)
Wed, Oct 29, 2:16 PM
Unknown Object (File)
Wed, Oct 29, 2:16 PM
Unknown Object (File)
Wed, Oct 29, 2:15 PM
Unknown Object (File)
Wed, Oct 29, 2:15 PM
Unknown Object (File)
Mon, Oct 27, 10:05 PM
Unknown Object (File)
Fri, Oct 24, 7:25 PM
Subscribers

Details

Summary

A nameserver timeout is a soft failure, future attempts may succeed.
Returning EAI_AGAIN is crucial for API users to tell a soft name
resolution failure from negative resolution result.

Before the change we would return EAI_ADDRFAMILY, which I believe, is a
regression from 144361386696, and before that revision we used to return
EAI_NONAME in most of the cases.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

lib/libc/net/getaddrinfo.c
2721

include/arpa/nameser.h:

/* The following are TSIG errors */
ns_r_badsig = 16,
ns_r_badkey = 17,
ns_r_badtime = 18

See include/arpa/nameser_compat.h for the mappings:
For exmale FORMERR:
#define FORMERR ns_r_formerr

We just don't implement the three above yet.

lib/libc/net/getaddrinfo.c
2721

Thanks! Will fix this.

Use larger values for function scope rcode extension. Write longer comment.

Test is rebased, no changes to the main diff.

lib/libc/net/getaddrinfo.c
2806

Please add break; after this line.

2965

Why is this statement moved?

lib/libc/net/getaddrinfo.c
2965

Now it is definitely possible to get TRY_AGAIN without rcode == SERVFAIL. It seems previously it was not, but I didn't do a thorough check. We don't want to make got_servfail true when we actually did not receive SERVFAIL. With current state of code the got_servfail seems superfluous to me, and the move of the statement could be omitted, but I don't want to leave a landmine for the future.

kib added inline comments.
lib/libc/net/getaddrinfo.c
2965

I think you need to somehow explain this chunk in the commit message.

This revision is now accepted and ready to land.Mar 24 2025, 11:09 AM