summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorPaul Jensen <pauljensen@google.com>2014-04-10 14:16:37 -0400
committerLorenzo Colitti <lorenzo@google.com>2014-05-14 03:56:33 -0700
commit13e817df516a803fbedeacca2c802a9fc1c1370f (patch)
tree49984316d564e00c087fe54516751f0ea2d02049 /services
parente4bde7d475135252cfa799d337ebbb029ebaf937 (diff)
downloadframeworks_base-13e817df516a803fbedeacca2c802a9fc1c1370f.zip
frameworks_base-13e817df516a803fbedeacca2c802a9fc1c1370f.tar.gz
frameworks_base-13e817df516a803fbedeacca2c802a9fc1c1370f.tar.bz2
Use NetId instead of interface name when communicating DNS changes to netd.
Change-Id: Ic82b73de6f50d39d56c5e1a32f5b1f3ebb80bb7d
Diffstat (limited to 'services')
-rw-r--r--services/core/java/com/android/server/ConnectivityService.java66
-rw-r--r--services/core/java/com/android/server/NetworkManagementService.java87
2 files changed, 41 insertions, 112 deletions
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index 3e7d9cf..2603395 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -2620,20 +2620,20 @@ public class ConnectivityService extends IConnectivityManager.Stub {
}
}
}
- if (resetDns) {
- flushVmDnsCache();
- if (VDBG) log("resetting DNS cache for " + iface);
- try {
- mNetd.flushInterfaceDnsCache(iface);
- } catch (Exception e) {
- // never crash - catch them all
- if (DBG) loge("Exception resetting dns cache: " + e);
- }
- }
} else {
loge("Can't reset connection for type "+netType);
}
}
+ if (resetDns) {
+ flushVmDnsCache();
+ if (VDBG) log("resetting DNS cache for type " + netType);
+ try {
+ mNetd.flushNetworkDnsCache(mNetTrackers[netType].getNetwork().netId);
+ } catch (Exception e) {
+ // never crash - catch them all
+ if (DBG) loge("Exception resetting dns cache: " + e);
+ }
+ }
}
}
@@ -2834,7 +2834,8 @@ public class ConnectivityService extends IConnectivityManager.Stub {
if (p == null) continue;
if (mNetRequestersPids[i].contains(myPid)) {
try {
- mNetd.setDnsInterfaceForPid(p.getInterfaceName(), pid);
+ // TODO: Reimplement this via local variable in bionic.
+ // mNetd.setDnsNetworkForPid(nt.getNetwork().netId, pid);
} catch (Exception e) {
Slog.e(TAG, "exception reasseses pid dns: " + e);
}
@@ -2844,7 +2845,8 @@ public class ConnectivityService extends IConnectivityManager.Stub {
}
// nothing found - delete
try {
- mNetd.clearDnsInterfaceForPid(pid);
+ // TODO: Reimplement this via local variable in bionic.
+ // mNetd.clearDnsNetworkForPid(pid);
} catch (Exception e) {
Slog.e(TAG, "exception clear interface from pid: " + e);
}
@@ -2869,8 +2871,8 @@ public class ConnectivityService extends IConnectivityManager.Stub {
}
// Caller must grab mDnsLock.
- private void updateDnsLocked(String network, String iface,
- Collection<InetAddress> dnses, String domains, boolean defaultDns) {
+ private void updateDnsLocked(String network, int netId,
+ Collection<InetAddress> dnses, String domains) {
int last = 0;
if (dnses.size() == 0 && mDefaultDns != null) {
dnses = new ArrayList();
@@ -2881,10 +2883,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
}
try {
- mNetd.setDnsServersForInterface(iface, NetworkUtils.makeStrings(dnses), domains);
- if (defaultDns) {
- mNetd.setDefaultInterfaceForDns(iface);
- }
+ mNetd.setDnsServersForNetwork(netId, NetworkUtils.makeStrings(dnses), domains);
for (InetAddress dns : dnses) {
++last;
@@ -2909,14 +2908,15 @@ public class ConnectivityService extends IConnectivityManager.Stub {
LinkProperties p = nt.getLinkProperties();
if (p == null) return;
Collection<InetAddress> dnses = p.getDnses();
+ int netId = nt.getNetwork().netId;
if (mNetConfigs[netType].isDefault()) {
String network = nt.getNetworkInfo().getTypeName();
synchronized (mDnsLock) {
- updateDnsLocked(network, p.getInterfaceName(), dnses, p.getDomains(), true);
+ updateDnsLocked(network, netId, dnses, p.getDomains());
}
} else {
try {
- mNetd.setDnsServersForInterface(p.getInterfaceName(),
+ mNetd.setDnsServersForNetwork(netId,
NetworkUtils.makeStrings(dnses), p.getDomains());
} catch (Exception e) {
if (DBG) loge("exception setting dns servers: " + e);
@@ -2925,7 +2925,8 @@ public class ConnectivityService extends IConnectivityManager.Stub {
List<Integer> pids = mNetRequestersPids[netType];
for (Integer pid : pids) {
try {
- mNetd.setDnsInterfaceForPid(p.getInterfaceName(), pid);
+ // TODO: Reimplement this via local variable in bionic.
+ // mNetd.setDnsNetworkForPid(netId, pid);
} catch (Exception e) {
Slog.e(TAG, "exception setting interface for pid: " + e);
}
@@ -3878,7 +3879,8 @@ public class ConnectivityService extends IConnectivityManager.Stub {
// Apply DNS changes.
synchronized (mDnsLock) {
- updateDnsLocked("VPN", iface, addresses, domains, false);
+ // TODO: Re-enable this when the netId of the VPN is known.
+ // updateDnsLocked("VPN", netId, addresses, domains);
}
// Temporarily disable the default proxy (not global).
@@ -3946,21 +3948,21 @@ public class ConnectivityService extends IConnectivityManager.Stub {
public void addUidForwarding(String interfaze, int uidStart, int uidEnd,
boolean forwardDns) {
- try {
- mNetd.setUidRangeRoute(interfaze,uidStart, uidEnd);
- if (forwardDns) mNetd.setDnsInterfaceForUidRange(interfaze, uidStart, uidEnd);
- } catch (RemoteException e) {
- }
+ // TODO: Re-enable this when the netId of the VPN is known.
+ // try {
+ // mNetd.setUidRangeRoute(netId, uidStart, uidEnd, forwardDns);
+ // } catch (RemoteException e) {
+ // }
}
public void clearUidForwarding(String interfaze, int uidStart, int uidEnd,
boolean forwardDns) {
- try {
- mNetd.clearUidRangeRoute(interfaze, uidStart, uidEnd);
- if (forwardDns) mNetd.clearDnsInterfaceForUidRange(interfaze, uidStart, uidEnd);
- } catch (RemoteException e) {
- }
+ // TODO: Re-enable this when the netId of the VPN is known.
+ // try {
+ // mNetd.clearUidRangeRoute(interfaze, uidStart, uidEnd);
+ // } catch (RemoteException e) {
+ // }
}
}
diff --git a/services/core/java/com/android/server/NetworkManagementService.java b/services/core/java/com/android/server/NetworkManagementService.java
index fea1d3e..7a155a2 100644
--- a/services/core/java/com/android/server/NetworkManagementService.java
+++ b/services/core/java/com/android/server/NetworkManagementService.java
@@ -1616,20 +1616,10 @@ public class NetworkManagementService extends INetworkManagementService.Stub
}
@Override
- public void setDefaultInterfaceForDns(String iface) {
- mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
- try {
- mConnector.execute("resolver", "setdefaultif", iface);
- } catch (NativeDaemonConnectorException e) {
- throw e.rethrowAsParcelableException();
- }
- }
-
- @Override
- public void setDnsServersForInterface(String iface, String[] servers, String domains) {
+ public void setDnsServersForNetwork(int netId, String[] servers, String domains) {
mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
- final Command cmd = new Command("resolver", "setifdns", iface,
+ final Command cmd = new Command("resolver", "setnetdns", netId,
(domains == null ? "" : domains));
for (String s : servers) {
@@ -1647,11 +1637,11 @@ public class NetworkManagementService extends INetworkManagementService.Stub
}
@Override
- public void setUidRangeRoute(String iface, int uid_start, int uid_end) {
+ public void setUidRangeRoute(String iface, int uid_start, int uid_end, boolean forward_dns) {
mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
try {
mConnector.execute("interface", "fwmark",
- "uid", "add", iface, uid_start, uid_end);
+ "uid", "add", iface, uid_start, uid_end, forward_dns ? 1 : 0);
} catch (NativeDaemonConnectorException e) {
throw e.rethrowAsParcelableException();
}
@@ -1662,7 +1652,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub
mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
try {
mConnector.execute("interface", "fwmark",
- "uid", "remove", iface, uid_start, uid_end);
+ "uid", "remove", iface, uid_start, uid_end, 0);
} catch (NativeDaemonConnectorException e) {
throw e.rethrowAsParcelableException();
}
@@ -1759,51 +1749,10 @@ public class NetworkManagementService extends INetworkManagementService.Stub
}
@Override
- public void setDnsInterfaceForUidRange(String iface, int uid_start, int uid_end) {
- mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
- try {
- mConnector.execute("resolver", "setifaceforuidrange", iface, uid_start, uid_end);
- } catch (NativeDaemonConnectorException e) {
- throw e.rethrowAsParcelableException();
- }
- }
-
- @Override
- public void clearDnsInterfaceForUidRange(String iface, int uid_start, int uid_end) {
- mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
- try {
- mConnector.execute("resolver", "clearifaceforuidrange", iface, uid_start, uid_end);
- } catch (NativeDaemonConnectorException e) {
- throw e.rethrowAsParcelableException();
- }
- }
-
- @Override
- public void clearDnsInterfaceMaps() {
+ public void flushNetworkDnsCache(int netId) {
mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
try {
- mConnector.execute("resolver", "clearifacemapping");
- } catch (NativeDaemonConnectorException e) {
- throw e.rethrowAsParcelableException();
- }
- }
-
-
- @Override
- public void flushDefaultDnsCache() {
- mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
- try {
- mConnector.execute("resolver", "flushdefaultif");
- } catch (NativeDaemonConnectorException e) {
- throw e.rethrowAsParcelableException();
- }
- }
-
- @Override
- public void flushInterfaceDnsCache(String iface) {
- mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
- try {
- mConnector.execute("resolver", "flushif", iface);
+ mConnector.execute("resolver", "flushnet", netId);
} catch (NativeDaemonConnectorException e) {
throw e.rethrowAsParcelableException();
}
@@ -1882,28 +1831,6 @@ public class NetworkManagementService extends INetworkManagementService.Stub
}
@Override
- public void setDnsInterfaceForPid(String iface, int pid) throws IllegalStateException {
- mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
- try {
- mConnector.execute("resolver", "setifaceforpid", iface, pid);
- } catch (NativeDaemonConnectorException e) {
- throw new IllegalStateException(
- "Error communicating with native deamon to set interface for pid" + iface, e);
- }
- }
-
- @Override
- public void clearDnsInterfaceForPid(int pid) throws IllegalStateException {
- mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
- try {
- mConnector.execute("resolver", "clearifaceforpid", pid);
- } catch (NativeDaemonConnectorException e) {
- throw new IllegalStateException(
- "Error communicating with native deamon to clear interface for pid " + pid, e);
- }
- }
-
- @Override
public void startClatd(String interfaceName) throws IllegalStateException {
mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);