summaryrefslogtreecommitdiff
path: root/src/android/net/ip
AgeCommit message (Collapse)Author
2020-06-24Get link state with same lock as LinkPropertiesRemi NGUYEN VAN
The previous IpClientLinkObserver code could in theory call mCallback.update with a linkState that came from another update; for example: 1. onInterfaceAddressUpdated - mLinkProperties.addLinkAddress 2. onInterfaceLinkStateChanged - setInterfaceLinkState(false) 1. mCallback.update(false) <- should be true ? 2. mCallback.update(false) In practice this would not happen because the onFoo methods are all called in order (same binder token from netd), but IpClientLinkObserver should not need to make such assumptions. Bug: 151796056 Test: atest NetworkStackIntegrationTests (see also test-only change) Change-Id: I60f5a319519069070eb5a07643686bf5ec937665
2020-06-24Send normal termination metrics on wifi offRemi NGUYEN VAN
When turning wifi off, the interface gets torn down and empty LinkProperties are received before wifi calls stop(). This causes a loss of provisioning to be logged, instead of normal termination. Watch interface link status up/down events, and when provisioning is lost when the interface is down, consider it a normal termination. Bug: 151796056 Test: manual: turn wifi off, observe events Test: atest NetworkStackIntegrationTests (see also test-only change) Original-Change: https://android-review.googlesource.com/1343236 Merged-In: I9d086a199de0017aa425219d20882211423925e0 Change-Id: I9d086a199de0017aa425219d20882211423925e0
2020-06-23Fix the mStopTimeNs not be reset in Stopwatch#RestartFrank Li
Bug: 151796056 Test: atest NetworkStackIntegrationTests NetworkStackTests Test: atest FrameworksNetTests Test: Manual test with statsd_testdrive Original-Change: https://android-review.googlesource.com/1343438 Merged-In: Ib83ceb70af3491dacbb4a45f65ef38661ae75e32 Change-Id: Ib83ceb70af3491dacbb4a45f65ef38661ae75e32
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-18Transition to appropriate state after all left addresses have been cleared.Treehugger Robot
State machine will transit to RunningState directly after clearing all left addresses even if the preconnection flag is enabled, that seems incorrect to skip PreconnectingState. Rely on the preconnection flag to determine which correct state should transit to. Bug: 159109671 Test: atest NetworkStackIntegrationTests NetworkStackTests Merged-In: I3d520a50f26ba7fac804c85c968013b2cb7cab91 Change-Id: I3d520a50f26ba7fac804c85c968013b2cb7cab91
2020-06-11Remove DhcpResults from NetworkStack shared libRemi NGUYEN VAN
Remove the dependency on DhcpResults in moduleutils by moving toStableParcelable to NetworkStack main code, and fromStableParcelable to the test only. Only NetworkStack should be generating DhcpResultsParcelables, and only the NetworkStack should be using DhcpResults at this point (eventually the class would move from frameworks/base/core to NetworkStack). Test: built, flashed, WiFi working Bug: 149403767 Original-Change: https://android-review.googlesource.com/1277444 Merged-In: I093fa48967a48f594b242b1e05e7d481fa9ee529 Change-Id: I093fa48967a48f594b242b1e05e7d481fa9ee529
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-01Allow localhost HTTP URLs for the capport APIRemi NGUYEN VAN
Allowing the capport API to be hosted on localhost makes it easy to write fast, stable tests for the feature. This was not possible because: - Pre-validation of the URL used Patterns.WEB_URL, which is over-restrictive and excludes domain names without TLD - NetworkMonitor needs the API to be hosted via HTTPS which is working as intended, however relaxing this requirement only for localhost (for testing) seems reasonable. Bug: 156062304 Test: atest CaptivePortalApiTest in associated change Original-Change: https://android-review.googlesource.com/1309235 Merged-In: I5f2cdd02376785b152e5b9a6e798d797894ea45b Change-Id: I5f2cdd02376785b152e5b9a6e798d797894ea45b
2020-05-29Rename groupHint to cluster.Chalard Jean
Bug: 146460486 Test: atest android.net.IpMemoryStoreTest Test: atest com.android.server.connectivity.ipmemorystore.IpMemoryStoreServiceTest Change-Id: I493472cb65262b04769192b702178351416c9869 Merged-In: I805733e201aa1286477cfac589cdf4ac18bb7e2b (cherry-picked from aosp/1311636)
2020-05-25Mock IpConnectivityLog in IpClientTestmarkchien
IpConnectivityLog which is used to send metrics need NETWORK_STACK permission. Mock IpConnectivityLog to avoid sending metrics from tests. Also remove platform cert from the network stack unit test because it is not necessary for any signature permission anymore. Bug: 156866746 Test: NetworkStackNextTests, NetworkStackCoverageTests, TetheringTests, TetheringCoverageTests Change-Id: Ibff052b30e000de3c5a08d7265c7642d67d9b0d0
2020-05-15Move common apishim classes to apishim.common pkgRemi NGUYEN VAN
This provides a better separation of the classes based on their role (an actual shim, or an interface or utility common to all shims), and forces the apishim package to import the common classes, which makes it easier at SDK bump time since the imports do not need to be added at that point. Bug: 143586229 Test: atest NetworkStackTests Original-Change: https://android-review.googlesource.com/1310517 Merged-In: Ie77c17a96a67016f35890afa065bea0a07b09504 Change-Id: Ie77c17a96a67016f35890afa065bea0a07b09504
2020-05-04Don't crash if the PREF64 expires when IpClient is stopped.Lorenzo Colitti
Currently the code does not cancel the PREF64 alarm when IpClient is stopped. If the alarm fires when IpClient has disconnected, it will call updatePref64 with a null prefix, which will crash. Ensure that the alarm is cancelled when IpClient is stopped. Bug: 153694684 Bug: 155559286 Test: new unit tests Change-Id: I397eb36c1a8ecf1324de33e720577fe2e4e07056
2020-05-01Do not stop FdEventsReader on handlePacket errorTreehugger Robot
Previously if handlePacket threw an exception, FdEventsReader would stop reading and close the file descriptor. This is not helpful as users of this class may encounter errors processing a particular packet (typically), but they generally should not stop completely for that reason. Also address comments from previous change (Exception instead of Throwable: Throwable should not be caught in general; event -> events). Bug: 152842850 Test: atest NetworkStackTests Original-Change: https://android-review.googlesource.com/1295503 Merged-In: I14abe8163ecdfd5251731915f10ea374bfa38b70 Change-Id: I14abe8163ecdfd5251731915f10ea374bfa38b70
2020-05-01Fix potential exceptions in FdEventReader usersRemi NGUYEN VAN
In particular, - Fix a possible NPE In IpNeighborMonitor, if a NUD_FAILED is received for some neighbor before all other neighbors have received RTM_NEWNEIGH. - Add try / catch in IpNeighborMonitor, DhcpPacketListener, ConnectivityPacketTracker in case some unexpected exception is thrown while processing packets. - Add Log.wtf logging in FdEventsReader in case any such exception is missed. Bug: 152842850 Test: atest NetworkStackTests Original-Change: https://android-review.googlesource.com/1274609 Merged-In: Ia03fec358e98b3f218220e70fc3265e14ca15f78 Change-Id: Ia03fec358e98b3f218220e70fc3265e14ca15f78
2020-04-30Merge changes I9d38c696,I8da6a8f4 into rvc-devRemi NGUYEN VAN
* changes: Fix IpReachabilityMonitorTest flakes/Q failures Add tests for IpReachabilityMonitor
2020-04-30Fix IpReachabilityMonitorTest flakes/Q failuresRemi NGUYEN VAN
IpReachabilityMonitor was failing on Q because of: - Usage of HexEncoding.encodeToString(byte[], boolean) that did not exist in Q - Flakes/failures caused by missing permissions when calling IpConnectivityLog - Flakes caused by mocking FileDescriptor#valid() while it could be accessed from another thread Bug: 152723363 Test: atest IpReachabilityMonitorTest --rerun-until-failure 500 Merged-In: I9d38c696bf1b3b63be3b9df3161168ee291e7beb Change-Id: I9d38c696bf1b3b63be3b9df3161168ee291e7beb (cherry picked from commit 162c7ee3601b49f55b7a72597067bc93836dbb96)
2020-04-28Merge "Remove Preconditions usage from moduleutils and IpClient" into rvc-devMark Chien
2020-04-27Don't crash or wtf if the interface doesn't exist.Lorenzo Colitti
This prevents the code from issuing a Log.wtf due to calling transitionTo in ClearingIpAddressesState#enter if the interface does not exist when IpClient starts provisioning is called. This prevents IpClientIntegrationTest from crashing on eng builds due to the Log.wtf being unhandled. Bug: 155005801 Bug: 152723363 Test: atest NetworkStackNextIntegrationTests:IpClientIntegrationTest#testRestoreInitialInterfaceMtu_NotFoundInterfaceWhenStartingProvisioning Original-Change: http://aosp/1290575 Merged-In: I4f34343816202c996f9227b72d453ea4a464f4b8 Change-Id: I4f34343816202c996f9227b72d453ea4a464f4b8
2020-04-27Remove Preconditions usage from moduleutils and IpClientMark Chien
moduleutils is a shared utility to be used by multiple network modules. Stop depending on a framework private class usage. Then all of its users can stop depending on the statically linked and jarjared private framework class. Bug: 148636687 Test: atest TetheringTests NetworkStackNextTests Merged-In: I693d0318fa4f1afbc220aa7c43e614ab5714a984 Change-Id: I693d0318fa4f1afbc220aa7c43e614ab5714a984
2020-04-24Merge "Address comments on ag/11204387." into rvc-devTreeHugger Robot
2020-04-24Address comments on ag/11204387.Lorenzo Colitti
Add comments and slightly increase test coverage. Bug: 153694684 Test: new test coverage in IpClientIntegrationTest Change-Id: I160a0801449cbe9e66976eaacdd3a914adc3d341
2020-04-23Merge "Ensure that the NAT64 prefix is removed when its lifetime expires." ↵Lorenzo Colitti
into rvc-dev
2020-04-23Ensure that the NAT64 prefix is removed when its lifetime expires.Lorenzo Colitti
Bug: 153694684 Test: new test coverage in IpClientIntegrationTest Change-Id: Ie207940d79abbc0d92dd15becee867e72f171786
2020-04-20Get the l2key and grouphint from the initial provisioning configuration.Xiao Ma
The purpose of processing CMD_UPDATE_L2INFO command in the Stopped State is just to update the initial l2key and grouphint which are used when starting DhcpClient (e.g. for INIT-REBOOT). We can get both of l2key and groupHint from the initial prov configuration parcelable instead, then be able to delete CMD_UPDATE_L2INFO from the StoppedState. Bug: 154441742 Test: atest FrameworksNetTests NetworkStackTests Test: atest NetworkStackIntegrationTests Change-Id: I760957017b18975be969a2f519ec09ee4495ebad
2020-04-20Listen for pref64 RA attributes in IpClientLinkObserver.Lorenzo Colitti
This allows IpClient to parse the pref64 RA option and put it in the LinkProperties to be sent to ConnectivityService. IpClientLinkObserver is a natural place for this because it is the part of IpClient that is already tasked with receiving netlink events and storing the results in IpClient's LinkProperties. Instead of using the path used by most attributes, which are parsed by NetlinkHandler, converted to a string array, then re-parsed and sent over binder call to the networkstack, simply open a netlink socket in the networkstack process and read the netlink messages from there. In the future, we can build on this to parse other netlink messages (e.g., IP addresses, routes, RDNSS, etc.) in the networkstack and entirely remove the dependency on netd's NetlinkHandler, which is crufty, hard to extend, and does not support interface indices. This means that the pref64 attribute will not be ordered with respect to other netlink events. This is acceptable because the pref64 attribute does not need to be ordered with any other information and its presence or absence does not cause provisioning to succeed or fail. Today the pref64 is learned through an entirely different codepath (DNS lookups) and that is not ordered in any way either. This CL does not change the threading model: the netlink updates are processed on the handler thread like all the other updates seen by IpClientLinkObserver, and all access to mLinkProperties is synchronized (this). This synchronization is no longer necessary because everything is on the handler thread anyway, but that will be cleaned up in a future CL. Because netlink events contain interface indices, but IpClient and netd deal with interface names, IpClientLinkObserver must be told what the interface index is. This is done when startProvisioning is called, because that is when IpClient fetches the interface parameters including the MAC address and interface index. It cannot be done when IpClientLinkObserver is started, because at that time the interface might not exist, or might exist with a previous interface index. The interface index is cleared when IpClient enters the stopped state and the LinkProperties are cleared. Bug: 153694684 Test: atest NetworkStackNextIntegrationTests:IpClientIntegrationTest#testPref64Option --iterations 100 Change-Id: I3f8d2fbf2e203c6f90029947fa55b5e0b3b06d94
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-07Add tests for IpReachabilityMonitorRemi NGUYEN VAN
The first tests just verify that provisioning is lost if all IPv4/6 DNS servers or gateways are lost. Test: atest NetworkStackTests Bug: 152819907 Merged-In: I8da6a8f4f237ce963c0a1610432d310160fd3f20 Change-Id: I8da6a8f4f237ce963c0a1610432d310160fd3f20
2020-04-03Merge "Add new method to update Layer2 information when L2 roaming happens." ↵Xiao Ma
into rvc-dev
2020-04-03Getting interface params in ClearingIpAddressState#enter.Xiao Ma
In case of wifi might stop IpClient and then restart prov immediately to avoid wifi disconnection especially when roaming happens, this might cause getting interface params with incorrect interface mtu when starting provisioning again before interface mtu hasn't been restored. Moving getting interface params to ClearingIpAddressState#enter ensures that interface parameters are fetched on the handler thread so they are properly ordered with other events, such as restoring the interface MTU on teardown. Bug: 152169857 Test: atest NetworkStackIntegrationTests NetworkStackTests Merged-In: Ifd06b8d18ce570b1aa424ad215111c80f094ca97 (cherry picked from commit a6aba532103a3258d09e6931106d6fb05368c130) Change-Id: I0c8c1ed1646ab12bc30da2b7f8e5819d2d9495ba
2020-04-02Add new method to update Layer2 information when L2 roaming happens.Xiao Ma
This change adds an new method updateLayer2Information in IIpClient.aidl to update layer2 info (e.g. bssid, l2key and grouphint) to detect whether L2 roaming happens or not. Bug: 131797393 Test: atest NetworkStackTests FrameworksNetTests Merged-In: I85eabccb6f5d5f322c8e3df556ceef6647616f5a (cherry picked from commit 3168e392320087c51a677b4d14e783c853ac652d) Change-Id: Ife93fd162803ae89fa85905b45a4bb1cfb5e7e43
2020-03-19Merge "Detect upstream hotspot device type by checking the vendor specific ↵TreeHugger Robot
IE." into rvc-dev
2020-03-18Detect upstream hotspot device type by checking the vendor specific IE.Xiao Ma
Checking a particular IE (vendor specific) in the wifi scan results to identify upstream hotspot device type, meanwhile also checking if the ssid matches with the network which the downstream device is attaching to. Bug: 137835398 Test: atest FrameworksNetTests NetworkStackTests NetworkStackIntegrationTests Test: 1.attach to upstream hotspot device by selecting the sanned ssid from wifi settings, then check the OUI, vendor specific type fileds of IEs from the logcat. 2. build network stack module and install on Q device, verify wifi works normally. Merged-In: I8a3212fa066bdc8bf889768f92569891a3cb2408 Merged-In: I57c709c5da984accbbb389ab8d1295eae01328c6 Change-Id: I8b0ea9542775aecc13ed8ceede80abd693002825
2020-03-17Provide RRO to configure neighbor unreachable probes parameters.Automerger Merge Worker
Bug: 130871097 Test: atest FrameworksNetTests NetworkStackTests Merged-In: Idc2c4303640d4fd3fc29dd0957771088820030ff (cherry picked from commit f540206076ca0e55d685ef81e3e04da3e9a654cf) Change-Id: Icd69008635461aa24d976f9b9d2d0ef1d60e23d5
2020-03-11Make IpClient populate the DHCP server address in LinkPropertiesAutomerger Merge Worker
Bug: 134098566 Test: lunch arm_aosp-userdebug make -j32 Change-Id: Ide9610f9b17992eef83e1c42ac71b1b79c179f44 Merged-In: If86a6303671b03bb2ccf98de7e9d77020b013d2f (cherry picked from commit 10d243214ae933d063affdd2b4f6c1f837279586)
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-18Send the capport fields to the system server.Chalard Jean
The fields are behind a protection method to avoid inadvertently sending private data to apps. This is going to the system server which needs those fields. Test: NetworkStackTests Change-Id: I7c9a7a82efa364835164622d2e93977e0bcd3d8c
2020-02-18Allow tethering to use IpNeighborMonitor.Lorenzo Colitti
Test: m Change-Id: I4ca0c47d62ea90c30f88278b3ebf766be2c5a2e9
2020-01-29Add implementation of getInterfaceHash()Paul Trautrim
Exempt-From-Owner-Approval: cherry-pick from internal Bug: 136065010 Test: m Change-Id: Iaf682c850b7cf22980d6fb88d3d60e24c189b74c Merged-In: Iaf682c850b7cf22980d6fb88d3d60e24c189b74c
2020-01-06Add rate-limiting to reduce CPU loading of IpClientjohnson.yeh
Bug: b/144826001 Test: Build Pass: OK Test: Power ON/OFF: OK Test: Verify CPU loading improvement: OK Change-Id: I412f3db7071672ebc3213dc128bbfc8f8bd2abcc
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-04Add DHCP Rapid Commit FILS support.Xiao Ma
Bug: 140223017 Test: atest FrameworksNetTests NetworkStackTests Test: atest NetworkStackIntegrationTests Test: manual Change-Id: Ibf200891c9742825a599a21b43f02927869f98ab
2019-12-02Add a ClearingIpAddressesState.Lorenzo Colitti
This simplifies StartedState a bit, and should have no impact on behaviour. Test: atest IpClientIntegrationTest Change-Id: Ie897307925a9af571a622c823d4c641956e607f3
2019-11-06Support dropping RDNSS options with a low lifetime.Lorenzo Colitti
Some routers have been known to use RDNSS lifetimes of 10 seconds(!). This causes APF filters to be set to very low lifetimes, which substantially impacts battery life. There are two parts to this: 1. Ignore low RDNSS option lifetimes for the purpose of calculating APF filter lifetimes. 2. Do not add DNS servers to the repository if their lifetimes are too low. If we do #1 without #2, the servers will expire because APF will drop the RAs that refresh them, potentially causing outages or disconnections. The behaviour is enabled by default starting from R and can be enabled on all builds using a flag. Bug: 66928272 Test: New unit test passes Change-Id: Ib2e2555026da3e81ea3d50767a30092413b4e4f5
2019-11-04Merge changes Icf6893ef,I7d788724Lorenzo Colitti
* changes: Always expire servers when receiving a zero-lifetime RDNSS option Add a test for IPv6 provisioning and RDNSS.
2019-11-04Always expire servers when receiving a zero-lifetime RDNSS optionLorenzo Colitti
When receiving a zero-lifetime RDNSS option for DNS servers that is already configured, the code first sets the lifetime of the servers to zero, and then runs code that prunes expired servers. Because expired servers are pruned only if "expiry < now", if the pruning happens in the same millisecond as the update, the servers aren't actually pruned. This can happen multiple times, so if the code runs fast enough, the server will never expire. Fix this by using <= instead of <. Fix: 143806550 Test: makes the new IpClientIntegrationTest#testRaRdnss not flaky Change-Id: Icf6893efdc028859b178eb234f6f1a42b24e2936
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-09-25Add tests to verify whether IpClient crashes when wlan interface doesn't exist.Xiao Ma
Bug: 113350007 Test: atest NetworkStackIntegrationTests Change-Id: I60ba097997193d9150567dca7156750004425602
2019-09-03Refactor NetworkStackService for testabilityRemi NGUYEN VAN
Refactor some methods to allow integration testing between ConnectivityService and NetworkStack. The integration tests override some NetworkStack methods to mock permission checks or NetworkMonitor network requests. Test: atest NetworkStackTests Change-Id: Ib5b4458f0b4d1423759e1e4016ab961d3ced7b48
2019-08-18Restore the default interface MTU when disconnecting from Wi-Fi AP.Xiao Ma
Bug: 113350007 Test: atest FrameworksNetTests NetworkStackTests Test: atest NetworkStackIntegrationTests Test: manual test Change-Id: I709a504885033a330b946de402a261d341f78117
2019-08-13Fix avoidBadWifi behavior with IPv6 provisioningRemi NGUYEN VAN
IPv6 provisioning loss should be ignored when avoidBadWifi is false, not true. Bug: 139023420 Test: with avoidBadWifi=false, when connected to a mobile hotspot that loses connectivity, WiFi does not disconnect anymore Change-Id: I534df1595a123866df9ba9f6429331e7fb1c5251