summaryrefslogtreecommitdiff
path: root/src/android/net/dhcp/DhcpClient.java
AgeCommit message (Collapse)Author
2020-06-23Injecting network ip provision stats into statsdlifr
1. Fill in each field of the NetworkIpProvisioningReported 2. Write the NetworkIpProvisioningReported into statsd Bug: 151796056 Test: atest NetworkStackIntegrationTests NetworkStackTests Test: atest FrameworksNetTests Test: Manual test with statsd_testdrive Original-Change: https://android-review.googlesource.com/1313574 Merged-In: If4bc6af1b794a8620a08858d6cfd85e661865bd7 Change-Id: If4bc6af1b794a8620a08858d6cfd85e661865bd7
2020-06-09Disable IPv6 stack when IPv6 provisioning is lost but IPv4 is still alive.Treehugger Robot
When IPv6 provisioning loss happens due to the default route has gone, however, if IPv4 network is still provisioned, we can consider to disable IPv6 stack and still keep the current connection without disconnecting from wifi, applications will be able to reconnect over IPv4 network. Bug: 131781810 Test: atest NetworkStackTests NetworkStackNextTests Test: atest NetworkStackIntegrationTests Merged-In: I8f56a05b38c8387c91306c0dc2bdf4430ec3bd00 Change-Id: I8f56a05b38c8387c91306c0dc2bdf4430ec3bd00
2020-06-04Merge "Shorten the timeout of DHCP INIT-REBOOT state." into rvc-devTreeHugger Robot
2020-06-04Merge "Adjust the timeout parameters in DHCP client." into rvc-devTreeHugger Robot
2020-06-03Shorten the timeout of DHCP INIT-REBOOT state.Xiao Ma
Currently the timeout in the INIT-REBOOT state is 18s which allows 4 retransmits. In the scenario where DHCP server fails to response due to certain reason, DhcpClient should go back to INIT state ASAP and do the regular DHCPDISCOVER. Shorten the timeout to 5s to speed up the fallback process. Bug: 157960451 Bug: 157603386 Test: atest NetworkStackIntegrationTests Test: manual test to verify that client goes back to INIT state and broadcasts DHCPDISCOVER after 2 retransmissions. Merged-In: I9d214e193a4f80a9512a3a6f385ca3554f050386 Change-Id: I9d214e193a4f80a9512a3a6f385ca3554f050386
2020-05-25Enable DHCP INIT-REBOOT state on R.Xiao Ma
Bug: 156575243 Test: atest NetworkStackTests NetworkStackIntegrationTests Test: atest NetworkStackNextIntegrationTests Test: manual test: 1. connect to AP successfully at the first time 2. disconnect wifi 3. reconnect to the same AP 4. checked client broadcasts REQUEST instead of DISCOVER 5. checked client broadcasts DISCOVER if lease has expired Merged-In: I62d1ab6b94be1ee95fbaa2ecce62eaba01e7892d Change-Id: I62d1ab6b94be1ee95fbaa2ecce62eaba01e7892d
2020-05-19Adjust the timeout parameters in DHCP client.Xiao Ma
MAX_TIMEOUT_MS: 128s -> 512s, battery drain for DHCP packet retransmit. FIRST_TIMEOUT_MS: 2s -> 1s, shorten DHCP packet retransmit interval. DEFAULT_TIMEOUT_MS: 36s -> 18s, quickly detect provisioning timeout. Bug: 131781810 Test: atest NetworkStackIntegrationTests NetworkStackTests Merged-In: Ie162b0d59da0082cd0c5ec02bb391c3d27f40607 Change-Id: Ie162b0d59da0082cd0c5ec02bb391c3d27f40607
2020-04-30Fix the potential double transition in DhcpState#enterXiao Ma
The double transition problem might happen when interface is gone by accident after starting DhcpClient. The StateMachine doesn’t allow to call transitionTo() in enter(). Use deferMessage() instead to avoid this crash. Bug: 145182281 Test: manual Merged-In: I03c4161a01861b47cf878945f7f5cc77c821cd57 Change-Id: I03c4161a01861b47cf878945f7f5cc77c821cd57
2020-04-17Merge "Fix the incorrect behaviour when receiving a mismatched renew lease." ↵TreeHugger Robot
into rvc-dev
2020-04-16Renew previous IP address when roaming happens in certain specific Wi-Fi ↵Xiao Ma
networks. Bug: 131797393 Test: atest NetworkStackTests NetworkStackIntegrationTests Test: atest FrameworksNetTests Merged-In: I65ebdd142a2bb402035c63cd282bc2574ddf3d8d Change-Id: I65ebdd142a2bb402035c63cd282bc2574ddf3d8d
2020-04-16Fix the incorrect behaviour when receiving a mismatched renew lease.Treehugger Robot
When the DHCP client is given a new IPv4 address which is not its previous network address to be extended durig RENEWING or REBINDING state, should roll back to INIT state and restart DHCP configuration. That's the intended behaviour with this fix (notify provisioning failure and then exit from receivePacket() immediately, DO NOT accept this renew lease). Otherwise, the new given network address will be accepted and noitfy IpClient to configure this new address on interface, which violates RFC2131#4.4.5. The incorect call graph will be: - receiving mismatched renew lease: - setDhcpLeaseExpiry - acceptDhcpResults - notifySuccess - transitionTo(mDhcpBoundState) - keep using this new address Bug: 131797393 Test: atest NetworkStackTests Merged-In: I6fd37e6af1f6bf3a8ce8de7b9a1ef4731de5db27 Change-Id: I6fd37e6af1f6bf3a8ce8de7b9a1ef4731de5db27
2020-02-19Add captive portal info to DhcpClient outputRemi NGUYEN VAN
Requesting the captive portal option is flagged off by default. The URL it provides will be used to support the captive portal API; see RFC7710bis. Bug: 139269711 Test: atest NetworkStackTests NetworkStackNextTests Test: atest NetworkStackIntegrationTests NetworkStackNextIntegrationTests Change-Id: I783466e0e60f364e79cd76af3fe43a7862d35cf2
2020-02-01Notify IpClient DHCP process success before configuring Interface.Xiao Ma
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
2020-01-20Return actual payload (DHCPDISCOVER) bytes array when starting FILS.Xiao Ma
Generally "ByteBuffer packet" has been allocated with a maximum length of 1500. Calling packet.array() is to return a byte array of length 1500 but the actual DHCPDISCOVER packet payload is much less. Return actual DHCP packet byte array instead in this patch, which allows caller use the payload byte array directly without extra operation (e.g. calling packet.remaining() to get the correct length of actual payload). Bug: 140223017 Test: atest NetworkStackTests NetworkStackIntegrationTests Change-Id: Ib08f2450fb649ea1ffcdbf8dedc829965f13da86
2019-12-27Merge "Provide RRO configuration to send DHCP client hostname option."Xiao Ma
2019-12-27Provide RRO configuration to send DHCP client hostname option.Xiao Ma
Add a configurable option in the RRO which controls whether or not to send the hostname set in the Settings->About phone->Device name. The option in RRO is false by default, that means DHCP Request still not include any hostname by default. Once the option is overlaid and enabled, the device name after transliteration will be wrote into hostname option. Bug: 131783527 Test: atest NetworkStackTests NetworkStackIntegrationTests Test: manual test, create empty APK to overlay the RRO configuration. Change-Id: I9af0b0d9e7bb526d3a3c1003bb99d0a3d69b1e9e
2019-12-27Read ARP timing properties from DeviceConfig appropriately.Xiao Ma
Overload NetworkStackUtils.getDeviceConfigPropertyInt API to check if the value of property read from DeviceConfig is valid, value in the range of mininum and maximum would be acceptable, otherwise, return the default value. Bug: 128639898 Test: atest NetworkStackTests NetworkStackIntegrationTests Change-Id: I07e3e9d1e1b7252d852d4665d2ea254f29a1c3eb
2019-12-20Add more integration test cases (timeout/abort/success) for DHCP FILS.Xiao Ma
- receiving CMD_TIMEOUT before aborting FILS process. - receiving CMD_TIMEOUT after aborting FILS process. - receiving CMD_TIMEOUT before success FILS process. - receiving CMD_TIMEOUT after success FILS process. Bug: 140223017 Test: atest NetworkStackTests NetworkStackIntegrationTests Change-Id: I519bf2fdda38cb9666f769868379a0c044356db0
2019-12-11Add Rapid Commit option support in DHCP Server side.Xiao Ma
Bug:136216415 Test: atest FrameworksNetTests NetworkStackTests Test: atest NetworkStackIntegrationTests Test: manual tethering Change-Id: I0f9483c72374bab271eb18549a1a41812f32f2dd
2019-12-09Implement IPv4 address conflict detection and DHCPDECLINE.Xiao Ma
Disable this behavior by default, we can enable it with flag rollout later. Bug: 128639898 Test: atest NetworkStackTests NetworkStackIntegrationTests Test: manual test Change-Id: Ie2133bc5faaba085147519cdb5c8277c563cfbd7
2019-12-04Add DHCP Rapid Commit FILS support.Xiao Ma
Bug: 140223017 Test: atest FrameworksNetTests NetworkStackTests Test: atest NetworkStackIntegrationTests Test: manual Change-Id: Ibf200891c9742825a599a21b43f02927869f98ab
2019-11-25Notify IpClient DHCP process success when entering DHCP Bound State.Xiao Ma
After introducing IP address conflict detection mechanism, we might get an duplicated IP address though the DHCP handshake, it's not appropriate to notify IpClient that DHCP success and configure interface with this IP address immediately. However, Bound State ensures that we have already done DAD (if enabled) and IP address has been configured on the interface. More reasonable to notify IpClient DHCP success when entering Bound state. This CL does not change the behaviour of a successful transaction. The call graph is: - notifySuccess - acceptDhcpResults - when receiving an ACK in DhcpReacquiringState - next action: transition to DhcpBoundState - called from confirmDhcpLease - when receiving a rapid commit ACK in DhcpInitState - next action: ConfiguringInterfaceState - next action: configure link address, then transition to DhcpBoundState - when receiving an ACK in DhcpRequestingState - next action: ConfiguringInterfaceState - next action: configure link address, then transition to DhcpBoundState This CL does change the behaviour of failed transactions. For example, if configuring the IP address or opening the UDP socket fails, after this CL, the client will no longer notify success. This is more correct. Bug: 130775067 Test: atest NetworkStackTests NetworkStackIntegrationTests Change-Id: Ie3b5edd8ddf04aac258b97ecaa291fcb25611bbd
2019-11-08Revert "Revert "Fix sll_protocol in DhcpClient packet socket""Remi NGUYEN VAN
Fix sll_protocol in DhcpClient packet socket The broadcast socket address was created with a deprecated API that does not set sll_protocol. This causes packets to be filtered incorrectly in packet capture, typically with tcpdump. This change only affects device with API > Q, since Q does not have the proper API to set the protocol. Also includes fixing the build path that was referencing apishim/current (which does not exist) instead of apishim/30 (the correct directory). SocketUtilsShim can be used on the system_current target with that fix. See change: I07887b82e0e32aadb0cbb9f930f2b2fa3e277ca9 Bug: 133196453 Test: manual; on AOSP with the new build, packet capture has the right protocol. When installed on a Q release build, behavior is unchanged. This reverts commit 5ad0944d24e8dabc7fa56c3325e9200669889641. Reason for revert: Roll forward the previous change, as the build breakage has been addressed. The stable build target is now used to build the NetworkStack mainline module, which allows this change to be merged. Change-Id: Ie933050ef269ce2159f3f44ac4db1f9aae134faf
2019-11-06Revert "Fix sll_protocol in DhcpClient packet socket"Remi NGUYEN VAN
This reverts commit 0c5e74000546a6c148e79985ee5fbf53dc454453. Reason for revert: Broke build in qt-qpr1-dev-plus-aosp Change-Id: I2e5738e776881f8c4f3cf459398a250560a43559
2019-11-06Fix sll_protocol in DhcpClient packet socketRemi NGUYEN VAN
The broadcast socket address was created with a deprecated API that does not set sll_protocol. This causes packets to be filtered incorrectly in packet capture, typically with tcpdump. This change only affects device with API > Q, since Q does not have the proper API to set the protocol. Also includes fixing the build path that was referencing apishim/current (which does not exist) instead of apishim/30 (the correct directory). SocketUtilsShim can be used on the system_current target with that fix. See change: I07887b82e0e32aadb0cbb9f930f2b2fa3e277ca9 Bug: 133196453 Test: manual; on AOSP with the new build, packet capture has the right protocol. When installed on a Q release build, behavior is unchanged. Change-Id: Iaafd0b3935473b1cfab61b49b2f107e71e01de2d
2019-10-31Merge "Remove hidden annotation usage from NetworkStack"Remi NGUYEN VAN
2019-10-30Separate the timeout behavior from PacketRetransmittingState class.Xiao Ma
The purpose is to make subclass that only requires timeout method could extend from TimeoutState instead of PacketRetransmittingState, avoiding the anti-pattern of using inheritance for code reuse only. After refactoring, class inheritance relationship looks like: LoggingState <-- TimeoutState <-- PacketRetransmittingState <-- DhcpInitState Bug: 140223017 Test: atest FrameworksNetTests NetworkStackTests Test: atest NetworkStackIntegrationTests Change-Id: I1fed3ff3ef8b0bdf3645188949e38c3a332f9d6e
2019-10-30Remove hidden annotation usage from NetworkStackRemi NGUYEN VAN
NetworkStack uses hidden android.annotation.* annotations by pulling the source files from frameworks/base. This should not be necessary, since androidx annotations can be used instead. Remove usage of such annotations and replace with androidx annotations. Test: m NetworkStack NetworkStackApiStable Test: builds, boots, WiFi working Bug: 139105333 Change-Id: I24e147ac4f01feaf53424430b4825b316ec154fe
2019-10-18Refactor the ReceiveThread with PacketReader in DhcpClient.Xiao Ma
To implement the IP address conflict detection, we need another ReceiveThread to listen ARP packets as well. Ideally, we should listen both of DHCP packets and ARP packets in the same thread with DhcpClient state machine handler. This CL replaces the ReceiveThread with PacketReader to listen DHCP packets. After refactoring, DHCP packets are read from the same handler thread instead of a separate receiving thread. Then we can also leverage the same handler thread to listen the ARP packets simultaneously via another raw socket. Bug: 130775067 Test: atest NetworkStackTests NetworkStackIntegrationTests Change-Id: I23e91a6c2d99cf8053e62f2ae9d78481ece6384d
2019-09-06Update connectivity namespace definitionChiachang Wang
Since DeviceConfig is available in aosp, update the definition reference from DeviceConfig instead of local definition. Bug: 120013793 Test: atest NetworkStackTests Change-Id: I3da82bd822ec340b98ad0b683478bd14ae94693c
2019-07-02Add DHCP Rapid Commit option(RFC4039) support in client side.Xiao Ma
Bug: 122710829 Bug: 136216415 Test: atest FrameworksNetTests NetworkStackTests Test: manual test Change-Id: I384282b7efd0df0c4a6de7bdc1957048303ad88b
2019-06-26Remove unnecessary castsNeil Fuller
makePacketSocketAddress() takes an int parameter. Bug: 130787951 Test: build Test: atest NetworkStackIntegrationTests Change-Id: Ied5df7955ba3598b6a8050854648fc5f354bd006
2019-06-11Add DHCP INIT-REBOOT state in DHCP client.Xiao Ma
Bug: 122710829 Test: atest FrameworksNetTests NetworkStackTests Change-Id: I4d7f2f5e7303f34b6364109a545f60fc25b88058
2019-04-17Move TrafficStats tags for the network stack constantsChalard Jean
As per API council feedback, these constants should live in a place that is private to the network stack, only with a range defined in system API. Bug: 129433383 Test: m Change-Id: I84a90f84a9af6fef4667ee4d512ebd0413222086 Merged-In: I4882686a86e7c6d42f4b0619b921d02619ed6d4c Merged-In: I9b648ed6c687d56db61a54570c7880c51c1bae51
2019-04-11provide a resource overlay to configure customized DNS Server.Xiao Ma
Bug: 122621524 Test: atest FrameworksNetTests NetworkStackTests Change-Id: I123b3d4516cc6ba6d17629eb74daf448ba7121eb
2019-04-03Move attach*Filter() and addArpEntry() methods to NetworkStackpaulhu
The SocketUtils.attach*Filter and SocketUtils.addArpEntry methods were added there because they could not be added as JNI inside the NetworkStack. This was not possible because on Go devices, the NetworkStack was a jar library. But now, Go also uses an APK. Hence, move these methods to the NetworkStack. Change-Id: I1d88a0f0be23f2b15d5103fa092b9bf982329d7c Fix: 129433183 Test: atest NetworkStackTests FrameworksNetTests
2019-03-28Merge "Fix message names in dumpsys network_stack"Remi NGUYEN VAN
2019-03-27Fix message names in dumpsys network_stackRemi NGUYEN VAN
Constants were stripped out by ProGuard, so MessageUtils.findMessageNames would fail to find them. Test: flashed, dumpsys network_stack shows message names Fixes: 124619824 Change-Id: I285ce2ab52cdff48f17b422285a635bd34243498
2019-03-26Enable more logs for networkingRuoyao Liu
Sometimes we would encounter problems that happen by chance and hard to reproduce. So we recommend to enable more logs in ENG and UESRDEBUG load by default. Bug: 123256412 Test: android.net.ip.IpClientTest can pass Change-Id: Ia3363de96966a4e86ab550c768fb70317da005ed
2019-03-06Fix SocketUtils APIRemi NGUYEN VAN
- connect, sendTo, bind were added as public API, so do not need to be maintained as SystemApi in SocketUtils. These APIs were added in Q timeframe. - Add @Nullable/@NonNull annotations. Bug: 126699304 Bug: 126477266 Test: booted, WiFi works Change-Id: I3f086ac8952cfd6a4d8f861d2e1c7aa1ca8be999
2019-01-30Remove last NetworkStack usage of hidden APIsRemi NGUYEN VAN
Includes various small changes to stop using hidden APIs Test: make NetworkStack Test: flashed, booted, WiFi and tethering working Bug: 112869080 Change-Id: Id2830795a444f484b377ed6437435a1cd833697a
2019-01-28Add hidden utils and constants to NetworkStackRemi NGUYEN VAN
Test: atest FrameworksNetTests NetworkStackTests Bug: 112869080 Change-Id: I1a803f7954ab760294436226d6c1cffb934e98f9
2019-01-23Move IpClient to NetworkStackRemi NGUYEN VAN
Test: atest FrameworksNetTests NetworkStackTests Bug: b/112869080 Change-Id: I7d00848c052382cd1b6ce458868bed6a1e9e8ec5