From 0587321554850c1e9d0aab66116ec8a41b367647 Mon Sep 17 00:00:00 2001 From: Lorenzo Colitti Date: Thu, 28 Apr 2016 01:24:21 +0900 Subject: [PATCH] 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 --- .../server/ethernet/EthernetNetworkFactory.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java b/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java index 718686344d..0b091f26b1 100644 --- a/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java +++ b/service-t/src/com/android/server/ethernet/EthernetNetworkFactory.java @@ -33,6 +33,7 @@ import android.net.NetworkInfo; 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 @@ class EthernetNetworkFactory { } } - // TODO: Handle DHCP renew. final Thread ipProvisioningThread = new Thread(new Runnable() { public void run() { if (DBG) { @@ -308,6 +308,7 @@ class EthernetNetworkFactory { public void onLinkPropertiesChange(LinkProperties newLp) { synchronized(EthernetNetworkFactory.this) { if (mNetworkAgent != null && mNetworkInfo.isConnected()) { + mLinkProperties = newLp; mNetworkAgent.sendLinkProperties(newLp); } } @@ -329,7 +330,11 @@ class EthernetNetworkFactory { mIpManager.setTcpBufferSizes(tcpBufferSizes); } - mIpManager.startProvisioning(); + final ProvisioningConfiguration provisioningConfiguration = + mIpManager.buildProvisioningConfiguration() + .withProvisioningTimeoutMs(0) + .build(); + mIpManager.startProvisioning(provisioningConfiguration); } linkProperties = ipmCallback.waitForProvisioning(); @@ -526,5 +531,11 @@ class EthernetNetworkFactory { 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(); + } } }