Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_host_by_name: Clarify behavior w/rt AI_V4MAPPED and AI_ADDRCONFIG #90

Open
chrysn opened this issue Sep 20, 2023 · 0 comments
Open

Comments

@chrysn
Copy link
Contributor

chrysn commented Sep 20, 2023

There are some features in name resolution that are quite useful on large systems. I'll refer to them by their POSIX names for lack of better terminology:

  • AI_V4MAPPED: When using an IPv6 stack that can do IPv4 but hides that from the application (using the dual stack features of IPv6), a stack could return Ok(IpAddr::V6("::ffff:10.0.0.1")) to a request.
  • AI_ADDRCONFIG: When a stack knows that it has no addresses of a given family, it can suppress sending requests for the corresponding kind of DNS records. Thus, unusable results are filtered out in some situations.
  • AI_ADDRCONFIG-done-right1: Even when some addresses of a family are available and the host needs to send A and AAAA requests, it may turn out that it has no route to the addresses indicated. With AI_ADDRCONFIG-done-right, the lookup would filter those out (because the stack is in a way better position to do that than the recipient, who would effectively do trial-and-error, espeically with our APIs).

To me, from the docs, it is unclear from the documentation whether or not these are supposed to be done by get_host_by_name / whether support is optional or mandatory / how optional support is signaled.

My suggestions are those:

  • AI_V4MAPPED is behavior a stack may have. It is recommended that stacks be consistent, i.e. that they only work with ::ffff:v4 addresses, but that's hard to enforce.
  • AI_ADDRCONFIG and -done-right should IMO be recommended: the stack has the information, the user doesn't need it, and if a user does need to know the answers to DNS requests without the need to interact with them, chances are they're building some DNS program, and want to access a bunch of other details that this API doesn't expose either.
    If a stack can not determine whether or not they're routable at all, it may violate that recommendation, but then users of that stack need to be aware that once such software is deployed on v4-only clients that talk to v4+v6 servers, they'll be on their own handling resulting errors. (They can recover by using something like Retrieve multiple IP addresses when resolving a hostname. #58, or by retrying and hoping that the one address they get is selected randomly).
    Making it mandatory may be the better choice even.

Is that a line you could get behind, and could implement on your implementations of embedded-nal? If so, I can build all of this into a PR on the documentation.

Footnotes

  1. I'm aware that (modulo bugs in implementations), ADDRCONFIG is doing what it is supposed to do, but right now I don't have a better name for what I think it should do.

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

No branches or pull requests

1 participant