From 825101b48b230f3416b2beacd537a121f8aa9924 Mon Sep 17 00:00:00 2001 From: Steve Kondik Date: Tue, 25 Oct 2016 16:33:09 -0700 Subject: [PATCH] Revert "netd: Trap dns calls" This reverts commit 6139b8420b95000774eca78a30e1b1d75db8f68d. --- client/Android.mk | 5 ---- client/NetdClient.cpp | 30 +--------------------- server/Android.mk | 5 ---- server/DnsProxyListener.cpp | 41 ------------------------------- server/QtiConnectivityAdapter.cpp | 36 --------------------------- server/QtiConnectivityAdapter.h | 7 ------ 6 files changed, 1 insertion(+), 123 deletions(-) diff --git a/client/Android.mk b/client/Android.mk index f1c5d155..e2025348 100644 --- a/client/Android.mk +++ b/client/Android.mk @@ -19,11 +19,6 @@ include $(CLEAR_VARS) LOCAL_C_INCLUDES := bionic/libc/dns/include system/netd/include LOCAL_CLANG := true LOCAL_CPPFLAGS := -std=c++11 -Wall -Werror - -ifeq ($(BOARD_USES_LIBC_WRAPPER),true) -LOCAL_CPPFLAGS += -DUSE_WRAPPER -endif - LOCAL_MODULE := libnetd_client LOCAL_SRC_FILES := FwmarkClient.cpp NetdClient.cpp diff --git a/client/NetdClient.cpp b/client/NetdClient.cpp index cb51cd01..392b0af6 100644 --- a/client/NetdClient.cpp +++ b/client/NetdClient.cpp @@ -27,10 +27,6 @@ #include "FwmarkCommand.h" #include "resolv_netid.h" -#ifdef USE_WRAPPER -#include "codeaurora/PropClientDispatch.h" -#endif - namespace { std::atomic_uint netIdForProcess(NETID_UNSET); @@ -41,10 +37,6 @@ typedef int (*ConnectFunctionType)(int, const sockaddr*, socklen_t); typedef int (*SocketFunctionType)(int, int, int); typedef unsigned (*NetIdForResolvFunctionType)(unsigned); -#ifdef USE_WRAPPER -typedef void (*SetConnectFunc) (ConnectFunctionType*); -#endif - // These variables are only modified at startup (when libc.so is loaded) and never afterwards, so // it's okay that they are read later at runtime without a lock. Accept4FunctionType libcAccept4 = 0; @@ -88,31 +80,11 @@ int netdClientConnect(int sockfd, const sockaddr* addr, socklen_t addrlen) { return -1; } } - -#ifdef USE_WRAPPER - if ( FwmarkClient::shouldSetFwmark(addr->sa_family)) { - if( __propClientDispatch.propConnect ) { - return __propClientDispatch.propConnect(sockfd, addr, addrlen); - } else { - return libcConnect(sockfd, addr, addrlen); - } - } -#endif return libcConnect(sockfd, addr, addrlen); } int netdClientSocket(int domain, int type, int protocol) { - - int socketFd; -#ifndef USE_WRAPPER - socketFd = libcSocket(domain, type, protocol); -#else - if( __propClientDispatch.propSocket ) { - socketFd = __propClientDispatch.propSocket(domain, type, protocol); - } else { - socketFd = libcSocket(domain, type, protocol); - } -#endif + int socketFd = libcSocket(domain, type, protocol); if (socketFd == -1) { return -1; } diff --git a/server/Android.mk b/server/Android.mk index 54dfe94a..126eb4ec 100644 --- a/server/Android.mk +++ b/server/Android.mk @@ -47,11 +47,6 @@ LOCAL_C_INCLUDES := \ LOCAL_CLANG := true LOCAL_CPPFLAGS := -std=c++11 -Wall -Werror - -ifeq ($(BOARD_USES_LIBC_WRAPPER),true) -LOCAL_CPPFLAGS += -DUSE_WRAPPER -endif - LOCAL_MODULE := netd LOCAL_INIT_RC := netd.rc diff --git a/server/DnsProxyListener.cpp b/server/DnsProxyListener.cpp index 9048ddaa..641b8828 100644 --- a/server/DnsProxyListener.cpp +++ b/server/DnsProxyListener.cpp @@ -29,9 +29,6 @@ #include #include -#ifdef USE_WRAPPER -#include -#endif #define LOG_TAG "DnsProxyListener" #define DBG 0 #define VDBG 0 @@ -197,10 +194,6 @@ void DnsProxyListener::GetAddrInfoHandler::run() { mNetContext.uid); } -#ifdef USE_WRAPPER - int ret = connAdapterGetAddrInfo( mClient->getPid(), mClient->getUid(), mClient->getGid(), mHost, mHints); -#endif - struct addrinfo* result = NULL; Stopwatch s; uint32_t rv = android_getaddrinfofornetcontext(mHost, mService, mHints, &mNetContext, &result); @@ -209,12 +202,6 @@ void DnsProxyListener::GetAddrInfoHandler::run() { if (rv) { // getaddrinfo failed mClient->sendBinaryMsg(ResponseCode::DnsProxyOperationFailed, &rv, sizeof(rv)); - -#ifdef USE_WRAPPER - if(!ret && (rv == EAI_NODATA) ) { - connAdapterSendDnsReport( latencyMs ); - } -#endif } else { bool success = !mClient->sendCode(ResponseCode::DnsProxyQueryResult); struct addrinfo* ai = result; @@ -410,10 +397,6 @@ void DnsProxyListener::GetHostByNameHandler::run() { ALOGD("DnsProxyListener::GetHostByNameHandler::run\n"); } -#ifdef USE_WRAPPER - int ret = connAdapterGetHostByName( mClient->getPid(), mClient->getUid(), mClient->getGid(), mName ); -#endif - Stopwatch s; struct hostent* hp = android_gethostbynamefornet(mName, mAf, mNetId, mMark); const int latencyMs = lround(s.timeTaken()); @@ -430,11 +413,6 @@ void DnsProxyListener::GetHostByNameHandler::run() { success = mClient->sendCode(ResponseCode::DnsProxyQueryResult) == 0; success &= sendhostent(mClient, hp); } else { -#ifdef USE_WRAPPER - if( !ret ) { - connAdapterSendDnsReport( latencyMs ); - } -#endif success = mClient->sendBinaryMsg(ResponseCode::DnsProxyOperationFailed, NULL, 0) == 0; } @@ -549,24 +527,10 @@ void DnsProxyListener::GetHostByAddrHandler::run() { if (DBG) { ALOGD("DnsProxyListener::GetHostByAddrHandler::run\n"); } - -#ifdef USE_WRAPPER - int ret = connAdapterGetHostByAddr( mClient->getPid(), mClient->getUid(), mClient->getGid(), mAddress); -#endif - struct hostent* hp; -#ifdef USE_WRAPPER - Stopwatch s; -#endif // NOTE gethostbyaddr should take a void* but bionic thinks it should be char* hp = android_gethostbyaddrfornet((char*)mAddress, mAddressLen, mAddressFamily, mNetId, mMark); -#ifdef USE_WRAPPER - int latencyMs; - if(!ret) { - latencyMs = lround(s.timeTaken()); - } -#endif if (DBG) { ALOGD("GetHostByAddrHandler::run gethostbyaddr errno: %s hp->h_name = %s, name_len = %zu\n", @@ -580,11 +544,6 @@ void DnsProxyListener::GetHostByAddrHandler::run() { success = mClient->sendCode(ResponseCode::DnsProxyQueryResult) == 0; success &= sendhostent(mClient, hp); } else { -#ifdef USE_WRAPPER - if( !ret ) { - connAdapterSendDnsReport( latencyMs ); - } -#endif success = mClient->sendBinaryMsg(ResponseCode::DnsProxyOperationFailed, NULL, 0) == 0; } diff --git a/server/QtiConnectivityAdapter.cpp b/server/QtiConnectivityAdapter.cpp index e60fd62e..3ae8ff7f 100644 --- a/server/QtiConnectivityAdapter.cpp +++ b/server/QtiConnectivityAdapter.cpp @@ -42,10 +42,6 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "QtiConnectivityAdapter.h" #include "ResponseCode.h" -#ifdef USE_WRAPPER -#include "codeaurora/PropClientDispatch.h" -#endif - void *_libConnectivityHandle = NULL; void (*_initExtension) (SocketListener*) = NULL; int (*_runQtiConnectivityCmd) (SocketClient*, int, char**) = NULL; @@ -110,38 +106,6 @@ NetdCommand *QtiConnectivityCommand::asNetdCommand() { return static_cast(this); } -#ifdef USE_WRAPPER -int connAdapterGetHostByName(const pid_t pid, const uid_t uid, const gid_t gid, const char* name) { - if( __propClientDispatch.propGetHostByNameForNet ) { - return __propClientDispatch.propGetHostByNameForNet(pid, uid, gid, name); - } else { - return -1; - } -} - -int connAdapterGetHostByAddr(const pid_t pid, const uid_t uid, const gid_t gid, const void* addr) { - if( __propClientDispatch.propGetHostByAddrForNet ) { - return __propClientDispatch.propGetHostByAddrForNet(pid, uid, gid, addr); - } else { - return -1; - } -} - -int connAdapterGetAddrInfo( const pid_t pid, const uid_t uid, const gid_t gid, const char* hostname, const struct addrinfo* hints) { - if ( __propClientDispatch.propGetAddrInfoForNet ) { - return __propClientDispatch.propGetAddrInfoForNet(pid, uid, gid, hostname, hints); - } else { - return -1; - } -} - -void connAdapterSendDnsReport( const int latencyMs ) { - if( __propClientDispatch.propSendDnsReport ) { - __propClientDispatch.propSendDnsReport(latencyMs); - } -} -#endif - int QtiConnectivityCommand::runCommand ( SocketClient *cli, diff --git a/server/QtiConnectivityAdapter.h b/server/QtiConnectivityAdapter.h index b1b38ab2..67b4580d 100644 --- a/server/QtiConnectivityAdapter.h +++ b/server/QtiConnectivityAdapter.h @@ -45,13 +45,6 @@ void natStopped(const char* tetherIface, const char* upstreamIface); int getV6TetherStats(SocketClient *cli, const char* tetherIface, const char* upstreamIface, std::string &extraProcessingInfo); -#ifdef USE_WRAPPER -int connAdapterGetHostByName(const pid_t pid, const uid_t uid, const gid_t gid, const char* mName); -int connAdapterGetHostByAddr(const pid_t pid, const uid_t uid, const gid_t gid, const void* addr); -int connAdapterGetAddrInfo(const pid_t pid, const uid_t uid, const gid_t gid, const char* hostname, const struct addrinfo* hints); -void connAdapterSendDnsReport(const int latencyMs); -#endif - class QtiConnectivityCommand : NetdCommand { public: QtiConnectivityCommand() : NetdCommand("qticonnectivity") {}