OSDN Git Service

Don't vpn dns if the vpn didn't provide servers
authorRobert Greenwalt <rgreenwalt@google.com>
Tue, 24 Sep 2013 23:44:22 +0000 (16:44 -0700)
committerRobert Greenwalt <rgreenwalt@google.com>
Tue, 24 Sep 2013 23:44:22 +0000 (16:44 -0700)
A split-tunnel vpn shouldn't snarf all dns queries if it's not
going to provide dns servers to service them.

bug:10115444
Change-Id: I4f8de66b75a04ca0e274edb92ace7acee762bca2

DnsProxyListener.cpp

index a025828..eb02f01 100644 (file)
@@ -129,15 +129,17 @@ void DnsProxyListener::GetAddrInfoHandler::run() {
     }
 
     char tmp[IF_NAMESIZE + 1];
+    int mark = mMark;
     if (mIface == NULL) {
         //fall back to the per uid interface if no per pid interface exists
         if(!_resolv_get_pids_associated_interface(mPid, tmp, sizeof(tmp)))
-            _resolv_get_uids_associated_interface(mUid, tmp, sizeof(tmp));
+            if(!_resolv_get_uids_associated_interface(mUid, tmp, sizeof(tmp)))
+                mark = -1; // if we don't have a targeted iface don't use a mark
     }
 
     struct addrinfo* result = NULL;
     uint32_t rv = android_getaddrinfoforiface(mHost, mService, mHints, mIface ? mIface : tmp,
-            mMark, &result);
+            mark, &result);
     if (rv) {
         // getaddrinfo failed
         mClient->sendBinaryMsg(ResponseCode::DnsProxyOperationFailed, &rv, sizeof(rv));
@@ -467,16 +469,18 @@ void DnsProxyListener::GetHostByAddrHandler::run() {
     }
 
     char tmp[IF_NAMESIZE + 1];
+    int mark = mMark;
     if (mIface == NULL) {
         //fall back to the per uid interface if no per pid interface exists
         if(!_resolv_get_pids_associated_interface(mPid, tmp, sizeof(tmp)))
-            _resolv_get_uids_associated_interface(mUid, tmp, sizeof(tmp));
+            if(!_resolv_get_uids_associated_interface(mUid, tmp, sizeof(tmp)))
+                mark = -1;
     }
     struct hostent* hp;
 
     // NOTE gethostbyaddr should take a void* but bionic thinks it should be char*
     hp = android_gethostbyaddrforiface((char*)mAddress, mAddressLen, mAddressFamily,
-            mIface ? mIface : tmp, mMark);
+            mIface ? mIface : tmp, mark);
 
     if (DBG) {
         ALOGD("GetHostByAddrHandler::run gethostbyaddr errno: %s hp->h_name = %s, name_len = %d\n",