OSDN Git Service

Revert "netd: Trap dns calls"
authorSteve Kondik <steve@cyngn.com>
Tue, 25 Oct 2016 23:33:09 +0000 (16:33 -0700)
committerMichael Bestas <mikeioannina@gmail.com>
Fri, 6 Jan 2017 23:15:14 +0000 (01:15 +0200)
This reverts commit 6139b8420b95000774eca78a30e1b1d75db8f68d.

client/Android.mk
client/NetdClient.cpp
server/Android.mk
server/DnsProxyListener.cpp
server/QtiConnectivityAdapter.cpp
server/QtiConnectivityAdapter.h

index f1c5d15..e202534 100644 (file)
@@ -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
 
index cb51cd0..392b0af 100644 (file)
 #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;
     }
index a465211..e70ad95 100644 (file)
@@ -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
index 9048dda..641b882 100644 (file)
@@ -29,9 +29,6 @@
 #include <resolv_netid.h>
 #include <net/if.h>
 
-#ifdef USE_WRAPPER
-#include <QtiConnectivityAdapter.h>
-#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;
     }
 
index e60fd62..3ae8ff7 100644 (file)
@@ -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<NetdCommand*>(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,
index b1b38ab..67b4580 100644 (file)
@@ -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") {}