Disable the IpManager timeout on Ethernet.
This fixes a longstanding bug where after a DHCP timeout, we
would never restart the DHCP client and get an IP address until
the link bounced.
Also, two minor improvements:
1. Dump IpManager info when dump() is called.
2. When onLinkPropertiesChange is called, also update
mLinkProperties. We were already sending the updated
LinkProperties to the NetworkAgent, so this is really only
useful for dump(), but it's just one line and safe because
onLinkPropertiesChange already grabs the lock.
Bug: 17733693
Change-Id: I42c3319cb4bc151c547ed721baf5e83f97e23862
diff --git a/java/com/android/server/ethernet/EthernetNetworkFactory.java b/java/com/android/server/ethernet/EthernetNetworkFactory.java
index 7186863..0b091f2 100644
--- a/java/com/android/server/ethernet/EthernetNetworkFactory.java
+++ b/java/com/android/server/ethernet/EthernetNetworkFactory.java
@@ -33,6 +33,7 @@
import android.net.NetworkInfo.DetailedState;
import android.net.StaticIpConfiguration;
import android.net.ip.IpManager;
+import android.net.ip.IpManager.ProvisioningConfiguration;
import android.net.ip.IpManager.WaitForProvisioningCallback;
import android.os.Handler;
import android.os.IBinder;
@@ -283,7 +284,6 @@
}
}
- // TODO: Handle DHCP renew.
final Thread ipProvisioningThread = new Thread(new Runnable() {
public void run() {
if (DBG) {
@@ -308,6 +308,7 @@
public void onLinkPropertiesChange(LinkProperties newLp) {
synchronized(EthernetNetworkFactory.this) {
if (mNetworkAgent != null && mNetworkInfo.isConnected()) {
+ mLinkProperties = newLp;
mNetworkAgent.sendLinkProperties(newLp);
}
}
@@ -329,7 +330,11 @@
mIpManager.setTcpBufferSizes(tcpBufferSizes);
}
- mIpManager.startProvisioning();
+ final ProvisioningConfiguration provisioningConfiguration =
+ mIpManager.buildProvisioningConfiguration()
+ .withProvisioningTimeoutMs(0)
+ .build();
+ mIpManager.startProvisioning(provisioningConfiguration);
}
linkProperties = ipmCallback.waitForProvisioning();
@@ -526,5 +531,11 @@
pw.println("NetworkInfo: " + mNetworkInfo);
pw.println("LinkProperties: " + mLinkProperties);
pw.println("NetworkAgent: " + mNetworkAgent);
+ if (mIpManager != null) {
+ pw.println("IpManager:");
+ pw.increaseIndent();
+ mIpManager.dump(fd, pw, args);
+ pw.decreaseIndent();
+ }
}
}