Query libnetd_client for the appropriate netId for host resolution.
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 559c7842cc6862568d9b5799fc0bcf74d58b596b)
Change-Id: I42ef3293172651870fb46d2de22464c4f03e8e0b
diff --git a/libc/bionic/NetdClientDispatch.cpp b/libc/bionic/NetdClientDispatch.cpp
index 6bd2357..17bbd9d 100644
--- a/libc/bionic/NetdClientDispatch.cpp
+++ b/libc/bionic/NetdClientDispatch.cpp
@@ -25,9 +25,14 @@
extern "C" __socketcall int __accept(int, sockaddr*, socklen_t*);
extern "C" __socketcall int __connect(int, const sockaddr*, socklen_t);
+static unsigned fallBackNetIdForResolv(unsigned netId) {
+ return netId;
+}
+
// This structure is modified only at startup (when libc.so is loaded) and never
// afterwards, so it's okay that it's read later at runtime without a lock.
__LIBC_HIDDEN__ NetdClientDispatch __netdClientDispatch __attribute__((aligned(32))) = {
__accept,
__connect,
+ fallBackNetIdForResolv,
};