summaryrefslogtreecommitdiff
path: root/src/network/res_msend.c
AgeCommit message (Collapse)AuthorLines
2017-03-14fix possible fd leak, unrestored cancellation state on dns socket failRich Felker-1/+5
2016-04-18remove dead store in res_msendPetr Vaněk-1/+0
The variable nss is set to zero in following line.
2016-01-28reuse parsed resolv.conf in dns core to avoid re-reading/re-parsingRich Felker-11/+16
2016-01-28factor resolv.conf parsing out of res_msend to its own fileRich Felker-60/+22
this change is made in preparation for adding search domains, for which higher-level code will need to parse resolv.conf. simply parsing it twice for each lookup would be one reasonable option, but the existing parser code was buggy anyway, which suggested to me that it's a bad idea to have two variants of this code in two different places. the old code in res_msend potentially misinterpreted overly long lines in resolv.conf, and stopped parsing after it found 3 nameservers, even if there were relevant options left to be parsed later in the file.
2015-10-26safely handle failure to open hosts, services, resolv.conf filesRich Felker-2/+11
previously, transient failures like fd exhaustion or other resource-related errors were treated the same as non-existence of these files, leading to fallbacks or false-negative results. in particular: - failure to open hosts resulted in fallback to dns, possibly yielding EAI_NONAME for a hostname that should be defined locally, or an unwanted result from dns that the hosts file was intended to replace. - failure to open services resulted in EAI_SERVICE. - failure to open resolv.conf resulted in querying localhost rather than the configured nameservers. now, only permanent errors trigger the fallback behaviors above; all other errors are reportable to the caller as EAI_SYSTEM.
2014-06-07avoid spurious lookup failures from badly-behaved nameserversRich Felker-5/+22
the results of a dns query, whether it's performed as part of one of the standard name-resolving functions or directly by res_send, should be a function of the query, not of the particular nameserver that responds to it. thus, all responses which indicate a failure or refusal by the nameserver, as opposed to a positive or negative result for the query, should be ignored. the strategy used is to re-issue the query immediately (but with a limit on the number of retries, in case the server is really broken) when a response code of 2 (server failure, typically transient) is seen, and otherwise take no action on bad responses (which generally indicate a misconfigured nameserver or one which the client does not have permission to use), allowing the normal retry interval to apply and of course accepting responses from other nameservers queried in parallel. empirically this matches the traditional resolver behavior for nameservers that respond with a code of 2 in the case where there is just a single nameserver configured. the behavior diverges when multiple nameservers are available, since musl is querying them in parallel. in this case we are mildly more aggressive at retrying.
2014-06-04add support for reverse name lookups from hosts file to getnameinfoRich Felker-7/+14
this also affects the legacy gethostbyaddr family, which uses getnameinfo as its backend. some other minor changes associated with the refactoring of source files are also made; in particular, the resolv.conf parser now uses the same code that's used elsewhere to handle ip literals, so as a side effect it can now accept a scope id for nameserver addressed with link-local scope.
2014-06-02fix uninitialized variable in new __res_msend dns functionRich Felker-0/+1
2014-06-02implement new dns backend, res_send and other legacy resolver functionsRich Felker-0/+184
this is the second phase of the "resolver overhaul" project. the key additions in this commit are the __res_msend and __res_mkquery functions, which have been factored so as to provide a backend for both the legacy res_* functions and the standard getaddrinfo and getnameinfo functions. the latter however are still using the old backend code; there is code duplication which still needs to be removed, and this will be the next phase of the resolver overhaul. __res_msend is derived from the old __dns_doqueries function, but generalized to send arbitrary caller-provided packets in parallel rather than producing the parallel queries itself. this allows it to be used (completely trivially) as a backend for res_send. the factored-out query generation code, with slightly more generality, is now part of __res_mkquery.