summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/os/INetworkManagementService.aidl4
-rw-r--r--services/java/com/android/server/ConnectivityService.java11
-rw-r--r--services/java/com/android/server/NetworkManagementService.java15
3 files changed, 15 insertions, 15 deletions
diff --git a/core/java/android/os/INetworkManagementService.aidl b/core/java/android/os/INetworkManagementService.aidl
index 3f02a6794315..1b51f346084b 100644
--- a/core/java/android/os/INetworkManagementService.aidl
+++ b/core/java/android/os/INetworkManagementService.aidl
@@ -235,12 +235,12 @@ interface INetworkManagementService
void setDnsServersForInterface(String iface, in String[] servers);
/**
- * Flush the DNS cache associated with the default interface
+ * Flush the DNS cache associated with the default interface.
*/
void flushDefaultDnsCache();
/**
- * Flush the DNS cache associated with the specified interface
+ * Flush the DNS cache associated with the specified interface.
*/
void flushInterfaceDnsCache(String iface);
}
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java
index 335d3fef1161..2f6bbeccbad3 100644
--- a/services/java/com/android/server/ConnectivityService.java
+++ b/services/java/com/android/server/ConnectivityService.java
@@ -1785,13 +1785,18 @@ public class ConnectivityService extends IConnectivityManager.Stub {
if (p == null) return;
Collection<InetAddress> dnses = p.getDnses();
try {
- mNetd.setDnsServersForInterface(Integer.toString(netType),
+ mNetd.setDnsServersForInterface(p.getInterfaceName(),
NetworkUtils.makeStrings(dnses));
} catch (Exception e) {
Slog.e(TAG, "exception setting dns servers: " + e);
}
boolean changed = false;
if (mNetConfigs[netType].isDefault()) {
+ try {
+ mNetd.setDefaultInterfaceForDns(p.getInterfaceName());
+ } catch (Exception e) {
+ Slog.e(TAG, "exception setting default dns interface: " + e);
+ }
int j = 1;
if (dnses.size() == 0 && mDefaultDns != null) {
String dnsString = mDefaultDns.getHostAddress();
@@ -1818,10 +1823,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
SystemProperties.set("net.dns" + j++, dnsString);
}
}
- try {
- mNetd.setDefaultInterfaceForDns(Integer.toString(netType));
- } catch (Exception e) {
- Slog.e(TAG, "exception setting default dns interface: " + e);}
for (int k=j ; k<mNumDnsEntries; k++) {
if (changed || !TextUtils.isEmpty(SystemProperties.get("net.dns" + k))) {
if (DBG) log("erasing net.dns" + k);
diff --git a/services/java/com/android/server/NetworkManagementService.java b/services/java/com/android/server/NetworkManagementService.java
index b34906fbda23..1c4f7807f797 100644
--- a/services/java/com/android/server/NetworkManagementService.java
+++ b/services/java/com/android/server/NetworkManagementService.java
@@ -970,18 +970,17 @@ class NetworkManagementService extends INetworkManagementService.Stub {
try {
String cmd = "resolver setifdns " + iface;
for (String s : servers) {
- if (s != null && !"0.0.0.0".equals(s) &&
- !"::".equals(s) && !"0:0:0:0:0:0:0:0".equals(s)) {
- cmd += " " + InetAddress.getByName(s).getHostAddress();
+ InetAddress a = NetworkUtils.numericToInetAddress(s);
+ if (a.isAnyLocalAddress() == false) {
+ cmd += " " + a.getHostAddress();
}
}
-
mConnector.doCommand(cmd);
- } catch (UnknownHostException e) {
- throw new IllegalStateException("failed to resolve dns address.", e);
+ } catch (IllegalArgumentException e) {
+ throw new IllegalStateException("Error setting dnsn for interface", e);
} catch (NativeDaemonConnectorException e) {
throw new IllegalStateException(
- "Error communicating with native deamon to set dns for interface", e);
+ "Error communicating with native daemon to set dns for interface", e);
}
}
@@ -1007,7 +1006,7 @@ class NetworkManagementService extends INetworkManagementService.Stub {
mConnector.doCommand(cmd);
} catch (NativeDaemonConnectorException e) {
throw new IllegalStateException(
- "Error communicating with native deamon to flush interface " + iface, e);
+ "Error communicating with native daemon to flush interface " + iface, e);
}
}
}