From 16b21efcabb807cc00bc408b53f71a88e2d0744d Mon Sep 17 00:00:00 2001 From: Xiao Ma Date: Wed, 22 Jan 2020 17:51:26 +0900 Subject: Notify IpClient DHCP process success before configuring Interface. This patch fixes the bug introduced by aosp/1169224 which moves notifySuccess function to DhcpBoundState#enter. This behavior is correct for DHCP reacquiring process (e.g. when client renews or rebinds the previous leased IPv4 address, then enters Bound state after receiving DHCPACK packet). However, this is incorrect for DHCP solicit at the first time, since notifying IpClient DHCP success after configuring interface causes mDhcpResult member is still empty when handleLinkPropertiesUpdate is triggered by netd completes configuring interface with new IPv4 address. Hence, new Link Properties passed to wifi state machine doesn't contain the available DNS servers received from DHCPACK. Moving notifySuccess before sending CMD_CONFIGURE_LINKADDRESS cmd to IpClient ensures mDhcpResult member has been initialize correctly before assembling new LinkProperties. Bug:146850745 Test: atest NetworkStackIntegrationTests NetworkStackTests Change-Id: Ifb990ccc06c1374e616f71038b1811640821e954 --- src/android/net/dhcp/DhcpClient.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/android/net/dhcp/DhcpClient.java b/src/android/net/dhcp/DhcpClient.java index b429923..fbcd0f6 100644 --- a/src/android/net/dhcp/DhcpClient.java +++ b/src/android/net/dhcp/DhcpClient.java @@ -1348,6 +1348,11 @@ public class DhcpClient extends StateMachine { @Override public void enter() { super.enter(); + // We must call notifySuccess to apply the rest of the DHCP configuration (e.g., DNS + // servers) before adding the IP address to the interface. Otherwise, as soon as + // IpClient sees the IP address appear, it will enter provisioned state without any + // configuration information from DHCP. http://b/146850745. + notifySuccess(); mController.sendMessage(CMD_CONFIGURE_LINKADDRESS, mDhcpLease.ipAddress); } @@ -1632,7 +1637,6 @@ public class DhcpClient extends StateMachine { transitionTo(mStoppedState); } - notifySuccess(); scheduleLeaseTimers(); logTimeToBoundState(); } @@ -1701,6 +1705,7 @@ public class DhcpClient extends StateMachine { // the registered IpManager.Callback. IP address changes // are not supported here. acceptDhcpResults(results, mLeaseMsg); + notifySuccess(); transitionTo(mDhcpBoundState); } } else if (packet instanceof DhcpNakPacket) { -- cgit v1.2.3