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>
Fix and use __RENAME (and lose ___RENAME --- two underscores should be
enough for anybody). This was the point of this change, because I want
to use __RENAME to support the two basename variants and the two
strerror_r variants.
Lose a bunch of macros that weren't being used.
Lose three dead files from the DNS code.
Bug: 17784968
(cherry picked from commit 2cfb4e8e2e)
Change-Id: I5e96146f92c0521248c78c0933bec5e9a9818222
Fix and use __RENAME (and lose ___RENAME --- two underscores should be
enough for anybody). This was the point of this change, because I want
to use __RENAME to support the two basename variants and the two
strerror_r variants.
Lose a bunch of macros that weren't being used.
Lose three dead files from the DNS code.
Change-Id: I3ef645c566b16a52217bc2e68c7d54b37c7c9522
This reverts most of commit 2582f02a01.
The DNS cache flushing code needs to be called when routes change.
Change-Id: I5b04121bc428cc6a2e136b6c3269c395bfb4981f
bug:16549455
The res_init.c changes bring us a bit closer to upstream too, though
there's still work to be done there. Some of the remaining differences
look like bugs we'd want to fix, so we should definitely try to come
back to that.
Change-Id: I50baa148e967c90d55d711e9904ad54c7d724d4d
These symbols should be public (and Firefox uses them), and we'd also probably
rather have the upstream thread-safe implementation.
Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1030899
Change-Id: I2a5888fbb3198546848398f576fd2195ff3fe00c
Occasionally file descriptors seem to be leaking across execs
from DNS related calls. Set close-on-execute for the various
sockets / file to prevent file descriptor leakage.
Change-Id: I4724b47bc7236f40c29518a6075598a9bba48b0a
Despite the name, most of resolv_private.h is actually in glibc; it's just
that there it's tucked away in libresolv whereas we have it in libc.
Change-Id: Ibcf6603f1141ffd2661cee0bffa83052d4f9e549
I couldn't work out where this went missing from "git log", but it became
important with the switch to hidden visibility.
Change-Id: I921f81e36642a2c65c3ec85dc9b5b87c5d977a5b
Calling connect() will erase the mark set by the host resolver code because the
explicitlySelected bit of the Fwmark isn't set. It's by design that the
explicitlySelected bit isn't set as this facilitates falling through to other
routing rules if the selected network doesn't provide a route to the DNS server
as may be the case with VPNs.
Change-Id: I60ba7c754194ead97df3ac6a6c5b3db1f446dac8
If libnetd_client can't be found, operate as before and use the default netId
potentially overriden by a more specific netId passed in to
android_get*fornet().
(cherry picked from commit 559c7842cc)
Change-Id: I42ef3293172651870fb46d2de22464c4f03e8e0b
If libnetd_client can't be found, operate as before and use the default netId
potentially overriden by a more specific netId passed in to
android_get*fornet().
Change-Id: I42ef3293172651870fb46d2de22464c4f03e8e0b
This is required when the possible range of NetIds is large to
prevent netd consuming excessive amounts of memory.
This required replacing the per-cache locks in favor of a single
global lock to prevent accesses to deleted caches.
Change-Id: I99d058bafea5de743e56075dbed74031da4df63f
Replace iface cache key with netid.
Replace _mark with netid.
Mark sockets used to test IPv4/IPv6 support as well as sockets
used to determine source address for rfc6724 sort.
Remove pid/uid mappings (functionality moved to system/netd).
Do not create resolv_cache when it does not exist, but rather only
when DNS configuration is supplied.
Clean up unused functions.
Change-Id: I9ccfda2902cc0943e87c9bc346ad9a2578accdab
There are only three users of bionic definition of ALIGN and keeping it
in sys/param.h polutes the namespace.
I inline the definition in the the three places that's used.
Bug: 13400663
Change-Id: I565008e8426c38ffb07422f42cd8e547d53044e9
The DNS copy of reentrant.h was unused, so remove it.
The strtod implementation can use the upstream-netbsd reentrant.h and
get a little closer to what was then upstream. (It's since been replaced
by gdtoa, and we'll have to follow at some point, but for now this doesn't
make anything any worse.)
ANDROID_CHANGES is (now) only used in the DNS code, so push the -D
down.
The <locale.h> change prevents an LP32 hack from leaking into LP64.
Change-Id: Idf30b98a59d7ca8f7c6cd6d07020b512057911ef
Also neuter __isthreaded.
We should come back to try to hide struct FILE's internals for LP64.
Bug: 3453512
Bug: 3453550
Change-Id: I7e115329fb4579246a72fea367b9fc8cb6055d18
Many compilers may optimize away the overflow check `msg + l < msg',
where `msg' is a pointer and `l' is an integer, because pointer
overflow is undefined behavior in C.
Use a safe precondition test `l >= eom - msg' instead.
Bug: 13219633
Change-Id: I3fca2125834073cc36d7e9c4e586e97842265a59
This is part of the upstream sync (Net/Open/Free BSDs expose the
nameser.h in their public headers).
Change-Id: Ib063d4e50586748cc70201a8296cd90d2e48bbcf