Skip to content

Commit

Permalink
Revert "netd: Trap dns calls"
Browse files Browse the repository at this point in the history
This reverts commit 6139b84.
  • Loading branch information
Steve Kondik committed Oct 25, 2016
1 parent 801fe7c commit 825101b
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 123 deletions.
5 changes: 0 additions & 5 deletions client/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
30 changes: 1 addition & 29 deletions client/NetdClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
5 changes: 0 additions & 5 deletions server/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 0 additions & 41 deletions server/DnsProxyListener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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());
Expand All @@ -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;
}

Expand Down Expand Up @@ -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",
Expand All @@ -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;
}

Expand Down
36 changes: 0 additions & 36 deletions server/QtiConnectivityAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 0 additions & 7 deletions server/QtiConnectivityAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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") {}
Expand Down

0 comments on commit 825101b

Please sign in to comment.