The near duplicate in gethnamaddr.c was already doing so (this fix
is basically copy and pasted from there, but with both copies modified
to avoid skirting undefined behavior).
Bug: http://b/32322088
Test: browser still works
Change-Id: Ied6662be567fb1bddc7ceb138cae1da77fb57976
(cherry picked from commit 27a4459d94)
_resolv_set_nameservers_for_net() so far did not update the search
paths, unless the servers changed as well.
BUG: 28437641
Change-Id: Id31f2d97c173e00357fb2ba95908afb4572c0fc1
(cherry picked from commit 06e2202a4c)
Also only record samples on the first try for a server.
BUG: 25731675
Change-Id: I10a68813c6636874e63aca1db661e63e1af72a2d
(cherry picked from commit 8b8611a0e6)
Fix the resolver information returned by
android_net_res_stats_get_info_for_net,
erroneously included MAXDNSRCH empty results if no search path was set.
BUG: 25731675
Change-Id: I97ef5d2d47dc62ca403a3323c7f14902e47b29b6
(cherry picked from commit 1b069a990a)
android_net_res_stats_get_info_for_net returns the current name servers, search
domains, parameters and stats for the given network ID.
android_net_res_stats_aggregate provides statistics such as errors counts from
the raw stats data reported by android_net_res_stats_get_info_for_net.
android_net_res_stats_get_usable_servers uses the data returned by
android_net_res_stats_aggregate to determine which of the servers are
considered valid or broken by the resolver.
BUG: 25731675
Change-Id: I6059b68e5e8b809027a4d3135f6081588bee8a7d
Instead of keeping a sentinel after nameservers[], nsaddrinfo[] and
nstats[], store the server count in the structure, freeing up memory and
eliminating the need to enumerate the server count every time
_resolv_is_nameservers_equal_locked() is invoked.
Also increase MAXNS from 3 to 4.
BUG: 28153323
Change-Id: I11a7257af695157c9e32019cd00c67b535b63c75
(cherry picked from commit fff356786f)
Collect statistics about DNS query success state and delay. Ignore
servers that have been tried at least five times and have a success rate
of < 0.25. Retry these servers once every 180s.
Bug: 25731675
(cherry picked from commit 6b3f0d65f2)
Change-Id: Id989404b14fd885fb31a5a4de36a4186be1c9ad1
The DNS search string contains zeros as domain separator. The resolver
code erroneously used strlcpy(), which resulted in only the first domain
to be copied. The code uses pointers into this string to access the
individual domains. Since the structure is zero-initialized, this bug only
resulted in zero-length domains instead of accessing unitialized memory.
BUG: 27312811
Change-Id: Ia9d066c405dfcc5e82d6766d93ead2ce574e7b0d
(cherry picked from commit 0967fc7e59)
In the serialized output from netd, the strings come first. Some code
assumes -- reasonably enough -- that it can do unaligned reads of pointers,
so we need to ensure alignment after all the strings.
(cherrypick of 65dd858239c4e32a5a1afbc14ac30dbcdd2a50a3.)
Bug: http://b/21192318
Change-Id: I456639127db9a2583f7f738e6b8103375d9387fd
In the serialized output from netd, the strings come first. Some code
assumes -- reasonably enough -- that it can do unaligned reads of pointers,
so we need to ensure alignment after all the strings.
Bug: http://b/21192318
Change-Id: I456639127db9a2583f7f738e6b8103375d9387fd
Group network context elements in to a single struct and
add a version of android_getaddrinfofornet() that accepts it.
The introduction of UID-based routing means that the UID is an
integral part of the network context when evaluating connectivity,
sorting addresses, etc.
Also, introduce a distinction between DNS netids/marks and those
expected to be used by the application. This can be important
when the network an application is using is not the same as the
network on which DNS queries will be issued.
Additionally, de-duplicate the UDP connect logic (collapse both
_test_connect() and _find_src_addr() into just the latter).
Bug: 19470192
Bug: 20733156
Bug: 21832279
Change-Id: If16c2f4744695f507993afdac078ca105eb5d3e4
(cherry picked from commit 01e37c9665)
Group network context elements in to a single struct and
add a version of android_getaddrinfofornet() that accepts it.
The introduction of UID-based routing means that the UID is an
integral part of the network context when evaluating connectivity,
sorting addresses, etc.
Also, introduce a distinction between DNS netids/marks and those
expected to be used by the application. This can be important
when the network an application is using is not the same as the
network on which DNS queries will be issued.
Additionally, de-duplicate the UDP connect logic (collapse both
_test_connect() and _find_src_addr() into just the latter).
Bug: 19470192
Bug: 20733156
Bug: 21832279
Change-Id: If16c2f4744695f507993afdac078ca105eb5d3e4
Interestingly, this mostly involves cleaning up our implementation of
various <string.h> functions.
Change-Id: Ifaef49b5cb997134f7bc0cc31bdac844bdb9e089
The code now compiles with all combinations of DEBUG and
DEBUG_DATA except DEBUG_DATA=1, DEBUG=0, which is unsupported.
Change-Id: I9035a65c649df73092f1fc0864ae1cdd9a14aa3b
(cherrypick of 79a49c9857f3949fc13373eeb179f27b6ecdca81.)
Change-Id: I7bb44fd1fe3ef2ddfc115247f328eccfceeb5352
Signed-off-by: Patrick Tjin <pattjin@google.com>
Remove code duplication and fall back to trying directly if the proxy
isn't available. With this, tests still work if netd is dead (perhaps
because you've run "adb shell stop", or because you're running on the host).
Bug: 18547878
Change-Id: Ia4a9aa18b1fc79e09735107246989fa7fc6c8455
When no DNS servers are configured (and thus there is no chance
that the DNS query will suceed), res_nsend returns early, but
it does not tell the cache that the query has failed.
Therefore, if the caller retries the query, it will block for
PENDING_REQUEST_TIMEOUT (= 20 seconds) waiting for the "existing
query" (which isn't actually doing anything) to complete.
Bug: 18240188
Bug: 18327075
Change-Id: I0df13ff4a17ee65e640be96695a3af31b020963a
The call to fdopen can fail in several ways.
The fprintf on the next line will then dereference a
NULL-pointer FILE*.
Added a NULL-check, closed the socket, returned system error
and added a comment about it.
Change-Id: I7a6b26aa3c79452b1fdd76af12dfa75da88cbad7
This change is to migrate the getaddrinfo tests defined in the old file
system/extras/tests/bionic/libc/common/test_getaddrinfo.c
to the new place bionic/tests/netdb_test.cpp.
The test here is more thorough, and catches a bug in getservbyname(3)
that was breaking getaddrinfo(3)'s ability to look up services by name
without a hint that would cause it to ask for a specific protocol.
Change-Id: Ief5ebd0869496d1bc6a97861dfefa04bdf24bab1
Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>