am 1c99b23c
: am 172ab0f6
: Merge "Query libnetd_client for the appropriate netId for host resolution."
* commit '1c99b23cc1ff5f1de658d7377cedf6e43b20f39b': Query libnetd_client for the appropriate netId for host resolution.
This commit is contained in:
commit
f65c4db319
@ -43,6 +43,8 @@ static void netdClientInitImpl() {
|
|||||||
netdClientInitFunction(netdClientHandle, "netdClientInitAccept", &__netdClientDispatch.accept);
|
netdClientInitFunction(netdClientHandle, "netdClientInitAccept", &__netdClientDispatch.accept);
|
||||||
netdClientInitFunction(netdClientHandle, "netdClientInitConnect",
|
netdClientInitFunction(netdClientHandle, "netdClientInitConnect",
|
||||||
&__netdClientDispatch.connect);
|
&__netdClientDispatch.connect);
|
||||||
|
netdClientInitFunction(netdClientHandle, "netdClientInitNetIdForResolv",
|
||||||
|
&__netdClientDispatch.netIdForResolv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static pthread_once_t netdClientInitOnce = PTHREAD_ONCE_INIT;
|
static pthread_once_t netdClientInitOnce = PTHREAD_ONCE_INIT;
|
||||||
|
@ -25,9 +25,14 @@
|
|||||||
extern "C" __socketcall int __accept(int, sockaddr*, socklen_t*);
|
extern "C" __socketcall int __accept(int, sockaddr*, socklen_t*);
|
||||||
extern "C" __socketcall int __connect(int, const 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
|
// 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.
|
// afterwards, so it's okay that it's read later at runtime without a lock.
|
||||||
__LIBC_HIDDEN__ NetdClientDispatch __netdClientDispatch __attribute__((aligned(32))) = {
|
__LIBC_HIDDEN__ NetdClientDispatch __netdClientDispatch __attribute__((aligned(32))) = {
|
||||||
__accept,
|
__accept,
|
||||||
__connect,
|
__connect,
|
||||||
|
fallBackNetIdForResolv,
|
||||||
};
|
};
|
||||||
|
@ -60,6 +60,7 @@
|
|||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <arpa/nameser.h>
|
#include <arpa/nameser.h>
|
||||||
|
#include "NetdClientDispatch.h"
|
||||||
#include "resolv_netid.h"
|
#include "resolv_netid.h"
|
||||||
#include "resolv_private.h"
|
#include "resolv_private.h"
|
||||||
#include "resolv_cache.h"
|
#include "resolv_cache.h"
|
||||||
@ -760,6 +761,8 @@ gethostbyname_internal(const char *name, int af, res_state res, unsigned netid,
|
|||||||
proxy = android_open_proxy();
|
proxy = android_open_proxy();
|
||||||
if (proxy == NULL) goto exit;
|
if (proxy == NULL) goto exit;
|
||||||
|
|
||||||
|
netid = __netdClientDispatch.netIdForResolv(netid);
|
||||||
|
|
||||||
/* This is writing to system/netd/DnsProxyListener.cpp and changes
|
/* This is writing to system/netd/DnsProxyListener.cpp and changes
|
||||||
* here need to be matched there */
|
* here need to be matched there */
|
||||||
if (fprintf(proxy, "gethostbyname %u %s %d",
|
if (fprintf(proxy, "gethostbyname %u %s %d",
|
||||||
@ -796,6 +799,8 @@ android_gethostbyaddrfornet_proxy(const void *addr,
|
|||||||
const char * addrStr = inet_ntop(af, addr, buf, sizeof(buf));
|
const char * addrStr = inet_ntop(af, addr, buf, sizeof(buf));
|
||||||
if (addrStr == NULL) goto exit;
|
if (addrStr == NULL) goto exit;
|
||||||
|
|
||||||
|
netid = __netdClientDispatch.netIdForResolv(netid);
|
||||||
|
|
||||||
if (fprintf(proxy, "gethostbyaddr %s %d %d %u",
|
if (fprintf(proxy, "gethostbyaddr %s %d %d %u",
|
||||||
addrStr, len, af, netid) < 0) {
|
addrStr, len, af, netid) < 0) {
|
||||||
goto exit;
|
goto exit;
|
||||||
|
@ -92,6 +92,7 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
|
#include "NetdClientDispatch.h"
|
||||||
#include "resolv_cache.h"
|
#include "resolv_cache.h"
|
||||||
#include "resolv_netid.h"
|
#include "resolv_netid.h"
|
||||||
#include "resolv_private.h"
|
#include "resolv_private.h"
|
||||||
@ -449,6 +450,8 @@ android_getaddrinfo_proxy(
|
|||||||
return EAI_NODATA;
|
return EAI_NODATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
netid = __netdClientDispatch.netIdForResolv(netid);
|
||||||
|
|
||||||
// Send the request.
|
// Send the request.
|
||||||
proxy = fdopen(sock, "r+");
|
proxy = fdopen(sock, "r+");
|
||||||
if (fprintf(proxy, "getaddrinfo %s %s %d %d %d %d %u",
|
if (fprintf(proxy, "getaddrinfo %s %s %d %d %d %d %u",
|
||||||
|
@ -25,6 +25,7 @@ __BEGIN_DECLS
|
|||||||
struct NetdClientDispatch {
|
struct NetdClientDispatch {
|
||||||
int (*accept)(int, struct sockaddr*, socklen_t*);
|
int (*accept)(int, struct sockaddr*, socklen_t*);
|
||||||
int (*connect)(int, const struct sockaddr*, socklen_t);
|
int (*connect)(int, const struct sockaddr*, socklen_t);
|
||||||
|
unsigned (*netIdForResolv)(unsigned);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern __LIBC_HIDDEN__ struct NetdClientDispatch __netdClientDispatch;
|
extern __LIBC_HIDDEN__ struct NetdClientDispatch __netdClientDispatch;
|
||||||
|
Loading…
Reference in New Issue
Block a user