Don't update routes if Dhcp fails.
bug:8377625
Change-Id: I11d2c29728078813bfb1245cc46e8cce2b307a2c
diff --git a/core/java/android/net/DhcpStateMachine.java b/core/java/android/net/DhcpStateMachine.java
index 518dd4b..0906c81 100644
--- a/core/java/android/net/DhcpStateMachine.java
+++ b/core/java/android/net/DhcpStateMachine.java
@@ -359,7 +359,7 @@
} else if (dhcpAction == DhcpAction.RENEW) {
if (DBG) Log.d(TAG, "DHCP renewal on " + mInterfaceName);
success = NetworkUtils.runDhcpRenew(mInterfaceName, dhcpResults);
- dhcpResults.updateFromDhcpRequest(mDhcpResults);
+ if (success) dhcpResults.updateFromDhcpRequest(mDhcpResults);
}
if (success) {
if (DBG) Log.d(TAG, "DHCP succeeded on " + mInterfaceName);
diff --git a/core/jni/android_net_NetUtils.cpp b/core/jni/android_net_NetUtils.cpp
index f5f22b2..faae11e 100644
--- a/core/jni/android_net_NetUtils.cpp
+++ b/core/jni/android_net_NetUtils.cpp
@@ -136,6 +136,10 @@
result = ::dhcp_do_request(nameStr, ipaddr, gateway, &prefixLength,
dns, server, &lease, vendorInfo, domains);
}
+ if (result != 0) {
+ ALOGD("dhcp_do_request failed");
+ }
+
env->ReleaseStringUTFChars(ifname, nameStr);
if (result == 0) {
env->CallVoidMethod(dhcpResults, dhcpResultsFieldIds.clear);