summaryrefslogtreecommitdiff
path: root/libc/inet/resolv.c
AgeCommit message (Collapse)Author
2013-03-29inet: fix getting the nameserver from _res state after res_init.Felix Fietkau
Fixes displaying the nameserver in busybox nslookup. Signed-off-by: Felix Fietkau <nbd@openwrt.org> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2013-03-20inet: do not filter responses in res_queryTimo Teräs
Fixes bug #5342 res_query was silently rejecting responses against T_ANY DNS questions. Remove the type-filtering from res_query altogether. __dns_lookup is supposed to return the proper stuff that you asked for (and only that). Signed-off-by: Timo Teräs <timo.teras@iki.fi> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2013-03-20inet: Fix LT{.old,} compilation due to res_icloseBernhard Reutner-Fischer
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2013-03-14inet: res_nclose: free user-buffer, not global _resBernhard Reutner-Fischer
In res_iclose we were operating on the global _res even if called via res_nclose where we are supposed to operate on the user provided res_state. Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2013-02-20inet: remove noreturn attribute from res_ncloseBernhard Reutner-Fischer
Partially revert e9af4dfbd328e9f3bba235fdb2d1027dd2dbbcde Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-08-04libc/inet/resolv.c: Use IE model for TLS data.Will Newton
All other TLS data in uClibc is explicitly using the IE model, so use it for __resp too. This generates smaller and faster code. Signed-off-by: Will Newton <will.newton@imgtec.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-08-04libc/inet/resolv.c: Remove obsolete comment.Will Newton
The definition of __resp has been hidden for some years (commit 22de495d). Remove the comment suggesting that it is not. Signed-off-by: Will Newton <will.newton@imgtec.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-06-15resolv.c: shrink code a bit in getnameinfo.Peter S. Mazinger
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-06-15fix a bunch of build warningsPeter S. Mazinger
Added attribute_noreturn even if it has return at the end of function Signed-off-by: Peter S. Mazinger <ps.m@gmx.net> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-06-15resolv.c,time.c,_atexit.c: hide 3 locksPeter S. Mazinger
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-06-15resolv.c: include param.h and use MIN instead of minPeter S. Mazinger
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-06-15resolv.c: remove duplicated attribute_hiddenPeter S. Mazinger
while there add one for future (currently in unused code) Signed-off-by: Peter S. Mazinger <ps.m@gmx.net> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-06-15remove __FORCE_GLIBCPeter S. Mazinger
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-04-17resolv: tiny shrinkage in /etc/hosts handlingBernhard Reutner-Fischer
-4b Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-04-17resolv: remove unused variablesBernhard Reutner-Fischer
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-04-17resolv: Fix /etc/hosts for more than MAXALIASES aliasesBernhard Reutner-Fischer
PR networking/4916 Reserve space for the terminating 0 alias and zero out the scratch-buffer so the last entry of the alias list is empty. Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2011-11-27make ARRAY_SIZE commonly available internallyMike Frysinger
Some places have opencoded the ARRAY_SIZE macro, so move it to a global internal location so other places can leverage it. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-11-17resolv: hide relocationsBernhard Reutner-Fischer
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2011-10-21resolv: fix memory leakBernhard Reutner-Fischer
Timothy Holdener writes: small memory leak in __dns_lookup() when the A record in the DNS answer is preceded by one or more CNAME records. Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2011-10-20resolv: commentary typo fixBernhard Reutner-Fischer
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2011-10-20gethostbyname_r: set correct h_errno upon failureBernhard Reutner-Fischer
previously gethostbyname_r(ipv6.google.com);herror("ERROR:") gave Answer name = |ipv6.google.com| Answer type = |5| herrno=1 h_errno=0 ERROR:: Error 0 herrno=1 h_errno=1 ERROR:: Unknown host Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2011-10-20resolv: fix compilationBernhard Reutner-Fischer
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2011-09-10resolv: simple optimizations and style/readability fixesDenys Vlasenko
text data bss dec hex filename - 2915 0 0 2915 b63 libc/inet/ns_name_old.o + 2656 0 0 2656 a60 libc/inet/ns_name.o - 958 0 0 958 3be libc/inet/ns_parse_old.o + 898 0 0 898 382 libc/inet/ns_parse.o Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-08-26inet/resolv: add res_ninit and res_ncloseDaniel Mack
Some reordering of existing functions was necessary in order to provide this functionality. Signed-off-by: Daniel Mack <zonque@gmail.com>
2011-08-26inet/resolv: add res_mkqueryDaniel Mack
Signed-off-by: Daniel Mack <zonque@gmail.com>
2011-08-26inet/resolv: add ns_initparse, ns_parserr, ns_skiprr and ns_msg_getflagDaniel Mack
There are build 'ifdef L_ns_parse'. Signed-off-by: Daniel Mack <zonque@gmail.com>
2011-08-26inet/resolv: add dn_skipname and ns_name_skipDaniel Mack
One uses the other, so add them in one go. Signed-off-by: Daniel Mack <zonque@gmail.com>
2011-08-26inet/resolv: Add dn_compDaniel Mack
Signed-off-by: Daniel Mack <zonque@gmail.com>
2011-08-26inet/resolv: add ns_name_pton, ns_name_pack and ns_name_compressDaniel Mack
These are built '#ifdef L_ns_name' Signed-off-by: Daniel Mack <zonque@gmail.com>
2011-08-26inet/resolv: add ns_{put,get}{16,32}Daniel Mack
This patch introduces a new config directive 'UCLIBC_HAS_RESOLVER_SUPPORT' and adds the new symbols conditionally. Signed-off-by: Daniel Mack <zonque@gmail.com>
2011-08-26libc/inet/resolv.c: comment on #endif linesDaniel Mack
While reading this file, I found it rather confusing to relate the "endif" lines to their opening counter-part. This patch adds comments to most of these lines to denote what the actually do. Signed-off-by: Daniel Mack <zonque@gmail.com>
2011-06-17resolv: fix bug in res_init with ipv6 nameserversBernhard Reutner-Fischer
Thanks to Christian Krause <chkr plauener.de> for finding and fixing this! Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2011-06-14resolv: try next server on SERVFAILBernhard Reutner-Fischer
in bug 3637 Andrey Kovalev aka pxe.ru writes: getaddrinfo does NOT add domain to query when receive SERVFAIL RFC1035 7.2 suggests that - If a resolver gets a server error or other bizarre response from a name server, it should remove it from SLIST, and may wish to schedule an immediate transmission to the next candidate server address. So let's try the next server upon SERVFAIL even if it's not strictly required. Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2011-04-13resolv: really fix res_close not to hang with ipv6Bernhard Reutner-Fischer
Fix goof in previous commit. Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2011-04-12resolv: fix res_close not to hang with ipv6Bernhard Reutner-Fischer
Timo Teräs writes: The memory release loop is missing an obvious counter increment. Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2010-11-23resolv.c fails for /etc/hosts lookupsPhilip Nye
Patch attached: Fix a bug in offset calculations when parsing /etc/hosts in resolv.c. Formerly a miscalculation meant that having found the correct line, the code was trashing its own result data. Signed-off-by: Philip Nye <philipn@engarts.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2010-08-28Fix resolver broken in NPTL buildTimo Teräs
The combination of commit aab4df0fb51660300559f5f29290709db2f7bfee resolv.c: add support for per thread res_state commit cca45baf8353d1e338d232f5bdb2d1d6b357f1da /etc/resolv.conf: support "timeout:n" and "attempts:n" options .. and NPTL results in broken resolver in very annoying ways. Now, it seems that most of the uclibc code does not work well if res_state is TLS variable. Technically, this is the correct thing to do since this gives proper per-thread resolving behavior, and it also makes the config options overridable per thread. This probably what apps expect as glibc does it too. But alas, most places use _res to sync up static global variables which results in breakage. It gets more or less randomly selected which threads options get applied. Also in case of multiple servers it looks like the retry logic is shared between all threads, e.g. two concurrent resolutions can make other resolvers skip nameservers due to shared "last_ns_num". And finally the timeout/attempts commit breaks the accumulated stuff horribly. What happens is: 1. multithreaded application startups, initializes resolver, resolves things just fine 2. resolv.conf gets changed, application calls res_init after res_init uclibc will call res_sync on all resolver functions to refresh globals from the TLS variable _res 3. res_init was called only in one thread, so other thread's _res contains all zeroes (yes, this is correct app usage: res_init should be called only from one thread) 4. threads not calling res_init get broken resolver due to timeout being set to zero Now, one proper solution would be to: 1. make __open_nameservers return the configuration options 2. pass the config options struct to res_sync_func so it can do the proper overrides from per-thread _res 3. remove the related globals and use locally config options from __open_nameservers But technically, the correct thing (as in glibc does this) is: - res_init increases global "res_init timestamp" - use _res (or pointer within there) for resolver retries etc. get proper per-thread behavior - resolvers functions call "maybe_init" which reinitialize the TLS'ed resolver state (e.g. reload resolv.conf) if their res_init timestamp is out dated As an immediate emergency kludge fix, the following might do: resolv: fix options handling for TLS _res If _res is in TLS (NPTL), it might not get initialized. Assume zeroes mean default values. Signed-off-by: Timo Teräs <timo.teras@iki.fi> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-08-19resolv: simplify MAXALIAS handlingBernhard Reutner-Fischer
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2010-08-05resolver: switch to config parserBernhard Reutner-Fischer
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2010-07-28Immediately try next nameserver on recv() failureIngo van Lil
If there is a problem communicating with a nameserver the __dns_lookup() function will not immediately advance to the next nameserver but instead continue waiting until the timeout expires. This will cause a 30 second delay even if no nameserver is configured in resolv.conf and no DNS is running on localhost. Signed-off-by: Ingo van Lil <inguin@gmx.de> Acked-by: Roman I Khimov <khimov@altell.ru> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2010-05-07resolv: various memory corruption and off by one fixesTimo Teras
Fixes resolution of names with AAAA entries and gethostbyaddr issues. Signed-off-by: Timo Teras <timo.teras@iki.fi> Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
2010-04-09resolv: tentatively fix usage of uninitialized DNS parametersDenys Vlasenko
See "Possible regression from timeout commit for resolv.conf" thread. Also remove superfluous NULL check. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-04-06Fix use-after-free bug in __dns_lookupGabor Juhos
If the type of the first answer does not match with the requested type, then the dotted name was freed. If there are no further answers in the DNS reply, this pointer was used later on in the same function. Additionally it is passed to the caller, and caused strange behaviour. Signed-off-by: Gabor Juhos <juhosg@openwrt.org> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2010-03-30resolv: DEBUG-print nameserver we talk toBernhard Reutner-Fischer
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2010-02-03/etc/resolv.conf: support "timeout:n" and "attempts:n" optionsDenys Vlasenko
text data bss dec hex filename - 1745 2 4 1751 6d7 libc/inet/dnslookup.o + 1760 2 4 1766 6e6 libc/inet/dnslookup.o - 962 0 4 966 3c6 libc/inet/opennameservers.o + 1099 0 4 1103 44f libc/inet/opennameservers.o - 462 4 472 938 3aa libc/inet/res_init.o + 454 4 468 926 39e libc/inet/res_init.o - 870 0 0 870 366 libc/inet/res_query.o + 867 0 0 867 363 libc/inet/res_query.o Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-02-01errno: hide __libc_resp, __libc_errno, and __libc_h_errnoKhem Raj
Signed-off-by: Khem Raj <raj.khem@gmail.com>
2010-01-23libc/inet: mark other odd /etc/conf/ spotBernhard Reutner-Fischer
and wrap it in FALLBACK_TO_CONFIG_RESOLVCONF too. -24b Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2009-10-14check stat("/etc/resolv.conf") for errorsDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-13libc/inet/resolv.c: reread resolv.conf if its mtime was changedBernhard Reutner-Fischer
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-08link-time warning for obsolescent/removed network funcsBernhard Reutner-Fischer
Signed-off-by: aldot <rep.dot.nop@gmail.com>