Page MenuHomeFreeBSD

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

Authored by glebius on Tue, Mar 18, 11:51 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Mar 24, 10:36 AM
Unknown Object (File)
Mon, Mar 24, 10:36 AM
Unknown Object (File)
Mon, Mar 24, 10:36 AM
Unknown Object (File)
Mon, Mar 24, 10:36 AM
Unknown Object (File)
Mon, Mar 24, 10:36 AM
Unknown Object (File)
Sun, Mar 23, 12:58 PM
Unknown Object (File)
Sun, Mar 23, 12:58 PM
Unknown Object (File)
Sun, Mar 23, 12:58 PM
Subscribers

Details

Reviewers
kib
bz
ume
rmacklem
hrs
Group Reviewers
network
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 Skipped
Unit
Tests Skipped
Build Status
Buildable 62984
Build 59868: arc lint + arc unit

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.Mon, Mar 24, 11:09 AM