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

FS#2786 - libubox: usock: usock_inet_timeout() does not try all servers it should and hides DNS errors #6240

Open
openwrt-bot opened this issue Jan 30, 2020 · 0 comments
Labels

Comments

@openwrt-bot
Copy link

hmh:

usock_inet_timeout() does not try all possible ipv6 and ipv4 server addresses if getaddrinfo() returns multiple records on the same family.

Also, it does not allow one to easily differentiate server-not-found (or other getaddrinfo() issue) from connect timeout, from connect refused.

To try all possible servers, one can either attempt to connect() to all of them in parallel (which seems too aggressive), or try to keep one connect() in progress for each family, replacing it with the next possibility should it return ECONNREFUSED, until the timeout expires.

Defining the use of errno should not be a problem, since it was undefined before so it is backwards-compatible:

If getaddrinfo() returns an error, it would be best to return -1, errno=ENOENT.
If none of the servers connect, return ECONNREFUSED if at least one of them returned ECONNREFUSED, or ETIMEDOUT otherwise (i.e. all timed out).

If timeout is zero, we return a socket that is likely to be in-progress and might fail to connect. That's fine, just try IPv6 first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant