summaryrefslogtreecommitdiff
path: root/java/com/android/server/ethernet/EthernetNetworkFactory.java
AgeCommit message (Collapse)Author
2021-08-20prevent nullptr dereference when calling unwantedPatrick Rohr
When the EthernetNetworkAgent has already been stopped, a call to unwanted will cause a crash due to a nullptr derefernce. Bug: 197279734 Test: atest EthernetNetworkFactoryTest Change-Id: Ice39c603bdd3e3139aa8ece7fb897bf7b567e74b
2021-07-28Remove Unused Code From EthernetNetworkFactoryPatrick Rohr
Test: atest EthernetNetworkFactoryTest Change-Id: Ibe0190b3108dca644da2d67bd107954cb26f41ce
2021-07-28Add Tests for EthernetNetworkFactoryPatrick Rohr
Test: atest EthernetNetworkFactoryTest Bug: 191635995 Change-Id: I1c07bb6d30706c4e13002eb402fadfecb97b36d1
2021-06-12Stop using LinkPropertiesParcelableUtil.Lorenzo Colitti
Its methods are all no-ops. Stop using them. Test: m Bug: 151052811 Change-Id: Iace3ba898bec2940ec3c3323c5bf8a13627d545f
2021-05-14Replace clearAll with withoutDefaultCapabilities in NC#Builderandroid-s-beta-2android-s-beta-1Chiachang Wang
Update the naming and usgae according to API review feedback. Bug: 184735772 Test: atest EthernetTrackerTest Change-Id: Ie8dc0bcdf46ceebda5d6062231b48c1f63b250f6 Merged-In: Ie8dc0bcdf46ceebda5d6062231b48c1f63b250f6
2021-05-05Add transport type in capabilities filter of EthernetNetworkFacotrylucaslin
Bug: 167544279 Test: atest EthernetServiceTests Change-Id: Ie64e3cff0ace413f14682736de7a1b65fa93e705 Merged-In: Ie64e3cff0ace413f14682736de7a1b65fa93e705 (Cherry-picked from ag/14031548)
2021-03-19Replace reference of NetworkAgent#setLegacyExtraInfojunyulai
Bug: 182963415 Test: m ethernet-service Test: atest EthernetServiceTests Change-Id: I4a66f34daa129b3158e4dd2fb720c175611eaf69
2021-03-19Replace references of request.networkCapabiliesjunyulai
Replaced by request.canBesatisfiedBy() to avoid direct reference of hidden member. Bug: 182963415 Test: m ethernet-service Test: atest EthernetServiceTests Change-Id: I2a27410a6148c525e17a11cb1ba3570f04e60b5d
2021-03-18Use clearAll() of NetworkCapabilities.Builder insteadlucaslin
NetworkCapabilities#clearAll() is a hidden API, use clearAll() of NetworkCapabilities.Builder instead. Bug: 182963415 Test: m ethernet-service Test: atest EthernetServiceTests Change-Id: I87745b5f7a5817f95cdbc623b2313c181ff48f19
2021-03-11Merge "Rename StringNetworkSpecifier to Ethernet"Remi NGUYEN VAN
2021-03-11[CS09]Remove hidden API usage of NetworkRequestlifr
The connection service will become the mainline module. So, need to remove the hidden API usage of NetworkRequest. The NetworkRequest.type(TRACK_DEFAULT) is no longer sent to the factories. So, remove the (TRACK_DEFAULT) check to avoid using hidden API. Bug: 170598012 Test: atest EthernetServiceTests Change-Id: I5b5fed864318e9ac7e190c40d4f52076ab0eece8
2021-03-10Rename StringNetworkSpecifier to EthernetRemi NGUYEN VAN
The new specifier represents ethernet interfaces more specifically and is part of the public API. Bug: 179329291 Test: atest CtsNetTestCases Merged-In: I6cba1709b3007a22d95849a1281237c77e1464a4 Change-Id: I6cba1709b3007a22d95849a1281237c77e1464a4
2021-02-09[CS02]Remove hidden API usage of NetworkCapabilitieslifr
The connection service will become the mainline module. The mutable NetworkCapabilities is deprecated, and the NetworkCapabilities should be built through their Builder instead. Bug: 170598012 Test: atest EthernetServiceTests Change-Id: I31f12a39a924302beca980b8d920e3c5c18816d4
2021-01-12[NS01.eth] Remove a useless argumentChalard Jean
Test: FrameworksNetTests Change-Id: Ib262871e4909ae65b5e6b2e52d2f25bf5a653f34
2020-03-27Merge "Address further API council comments." into rvc-devChalard Jean
2020-03-27Fix querying Ethernet availability for unprivileged callers.Lorenzo Colitti
Both EthernetManager#getAvailableInterfaces() and the no-arg version of EthernetManager#isAvailable() end up calling EthernetServiceImpl#getAvailableInterfaces. This method attempts to filter out restricted interfaces if the caller does not have the CONNECTIVITY_USE_RESTRICTED_NETWORKS permission. Unfortunately EthernetNetworkFactory's notion of a restricted interface is the opposite of what it should be. This means that while privileged callers can see all interfaces, unprivileged callers can only see restricted interfaces which they cannot use. Fix this by correcting NetworkInterfaceState#isRestricted(), so that unprivileged callers can see only unrestricted interfaces. Privileged callers are unaffected. This bug probably went unnoticed because restricted Ethernet interfaces are rare (likely used only on auto devices) and because the callers that care about those restricted interfaces are generally privileged. Bug: 148824036 Test: atest android.net.EthernetTetheringTest#testPhysicalEthernet Merged-In: Idff3b05a193a80c581d80d0e4fe9c2d3fc0d8a25 Change-Id: Idff3b05a193a80c581d80d0e4fe9c2d3fc0d8a25
2020-03-27Address further API council comments.Chalard Jean
Test: FrameworksNetTests NetworkStackTests Bug: 152238712 Change-Id: I7c27f76c54a76abeae46dcdcddaeb3ca48afa358
2020-02-28Revert part of 223eace8e925de053e12141a771bdac8a06abfc3Chalard Jean
This reverts the parts of the above commit that have to do with NetworkScore. The parts that convert the factory to the new NetworkAgent API are conserved. Bug: 113554781 Test: FrameworksNetTests Change-Id: If2c368e084e29f9f358f43dcd547d42e8c7c4846
2020-01-30Make NetworkScore system APIChalard Jean
Bug: 146583853 Test: FrameworksNetTests Change-Id: Ie7b70750ef0e17141080f4266dea6155c3601569
2020-01-09Merge "Avoid creating IpClient if ethernet cable is unplugged."Lorenzo Colitti
2019-12-17Fix refCount check at releaseNetworkForJunaid Babu
When releaseNetworkFor is called, refCount should be equal to 1 for network.stop() to be called. This is the same logic that is followed by WifiNetworkFactory also. In the current code, when refCount is 2 and releaseNetworkFor() is called, network.stop() will be executed and will stop Ethernet Bug: 146089778 Test: build and boot OK Change-Id: Ib7d1b488a2943364a8ba4a89eec5de4c33cf1d5a
2019-10-31Avoid creating IpClient if ethernet cable is unplugged.kevinwk_lee
This change avoids calling start() on needNetworkFor() if ethernet cable is unplugged. Fixed by adding isLinkUp validation. Test: ./cts-tradefed run cts-dev -d -m CtsSecurityTestCases -t \ android.security.cts.ListeningPortsTest#testNoRemotelyAccessibleListeningUdpPorts adb shell netstat -lnup Change-Id: I2debd7367a20b665249f9c19d2d8a61737435803
2019-09-09Update Ethernet code for the NetworkFactory serial number.Chalard Jean
See aosp/708790 Bug: 18637384 Bug: 29030667 Test: manual cts runtest framework-net atest frameworks/opt/net/ethernet/tests Change-Id: I5caa4cb89ca1441f3c84b5675ceede6ecacfd132
2019-05-29Fixed fatal exception in EthernetServiceThreadandroid-o-mr1-iot-release-1.0.14android-o-mr1-iot-release-1.0.13Wally Yau
When this.mIpConfig is not initialized, it will cause a java.lang.NullPointerException and put the device in a boot loop with the following error: FATAL EXCEPTION IN SYSTEM PROCESS: EthernetServiceThread Test: passed pre-submit boot test. Change-Id: I47df68071b4c07a4136c0abcbe69ee7ada7090e0
2019-05-14Add reconnect flow when updateIPConfigurationtank.hung
Bug: 119085164 Test: manual, test with AndroidTV device Partner gerrit review CL: https://partner-android-review.googlesource.com/c/platform/frameworks/opt/net/ethernet/+/1215654 [Analysis] APP called EthernetManager.setConfiguration API for switch DHCP to Static, setConfiguration’s flow just only update IpConfig finally but have not trigger EthernetNetworkFactory.start(). So Static IP Setting just only take effect when unplug/plug Ethernet Cable or AC Off&On. [Repeat Steps] 1. Connect Ethernet with DHCP and Network access is normal 2. Change IP settings from DHCP to Static and set Static IP. 3. After setting, you can not automatically obtain Static IP. [Recovery Method] Unplug the Ethernet and insert it or AC OFF / ON Change-Id: Idbb6a24ccfa360582f48e4f9369def7fc729fb9f Bug: 112171349
2019-03-25Update comments and documentation in net type prop changeandroid-q-preview-6android-q-preview-5android-q-preview-4android-q-preview-2.5android-o-mr1-iot-release-1.0.12oreo-mr1-iot-releaseSal Savage
Bug: b/112588045 Test: atest EthernetServiceTests --verbose Test: kitchensink, dumpsys ethernet, with RPi devices and USB to ethernet adapters. Change-Id: Iaa260aabbbd7aa4b7864eba32ecff7e3f84123c3
2019-01-25Migrate EthernetNetworkFactory to IIpClientRemi NGUYEN VAN
Test: atest EthernetServiceTests Bug: b/112869080 Change-Id: I54f32d3031e63c7dea78936b6fe5e83e5b293c33
2019-01-15Allow network transport type overrideSal Savage
Bug: b/112588045 Test: atest EthernetServiceTests --verbose Test: kitchensink with RPi devices connected by USB -> Ethernet adapters. Edit config.xml to try different tranport overrides manually. Use dumpsys ethernet to show final final network scores. Change-Id: I482e78a76d06c9c090aa6816db14bb346eb6528b
2018-10-16Don't consider TRACK_DEFAULT requests in EthernetNetworkFactory.Lorenzo Colitti
These should not affect network refcount and thus should not be passed to the network transport. Bug: 116034205 Test: successfully established a VPN when connected to USB ethernet Change-Id: I66517d86f35b8cfc1e211cb189127187d2744b60
2018-08-22Strategic fix for infinite loopandroid-o-mr1-iot-release-smart-display-r3android-o-mr1-iot-release-1.0.5android-o-mr1-iot-release-1.0.4oreo-mr1-1.2-iot-releasemaster-cuttlefish-testing-releaseChalard Jean
Bug: 111326363 Test: Manual + atest frameworks-net Change-Id: Id262df4e41de5c74784637ae4a5459c3fab9fb74
2018-08-21Tiny tiny style fixChalard Jean
Test: none needed Change-Id: Ic6cfedf9cfe60984ce7fbd59bdaec55b0bba3001
2018-05-08Fix NPE during dumpsys ethernetPavel Maltsev
Handle the case when IpClient wasn't created for network interface which may happen for virtual device Bug: 78482534 Test: dumpsys ethernet Merged-In: I374a91265660e814b4f0f033b3970fd98921ca84 Merged-In: Id4ab7c9a8a5238491c8405ae260862e76a7671c1 Change-Id: I3405dd4f72d4a6444448f0d6ec0497aead07bade (cherry picked from commit 2c002de63839a7ce1ed334af2c75176c00e1e248)
2018-02-21Wait for IpClient to shutdownandroid-wear-p-preview-2android-p-preview-3android-p-preview-2android-p-preview-1android-o-mr1-iot-release-1.0.0android-o-mr1-iot-preview-8android-o-mr1-iot-preview-7android-n-iot-release-lg-thinq-wk7o-mr1-iot-preview-8o-mr1-iot-preview-7Erik Kline
This makes sure that we never accidentally have two IpClients vying for control of the same interface. Test: as follows - built - flashed - booted Bug: 62476366 Change-Id: Iab4ca7c2445e70b6f8beaf5dc6921cb0c6cd56ed
2018-02-21Avoid re-creating an IpClient if the network has already startedLuis Hector Chavez
This change avoids calling start() on needNetworkFor() if an IpClient object has already been created. This is the case when the interface is connected from boot, as is the case in Chrome OS. Bug: 73396557 Test: Networking is 100% stable in Chrome OS Change-Id: Iaa073d6477aadca2e4e5233b333d717ad82c1f3d
2018-01-25Enable multiple active Ethernet interfacesPavel Maltsev
- reworked EthernetNetworkFactory to support multiple active Ethernet interfaces - allow vendors to specify network capabilities + ip config through XML config overlay Test: manual using hikey960 + multiple usb->eth adapters Change-Id: Ie39bcb0d2a3f960f497222159c7bd5797accaa68
2018-01-17Add "not congested" network capability.Jeff Sharkey
Can be used by a network to indicate when it's congested, meaning that apps should defer network traffic that could be done at a later time. Test: bit FrameworksNetTests:android.net.,com.android.server.net.,com.android.server.connectivity.VpnTest,com.android.server.ConnectivityServiceTest Bug: 64133169 Change-Id: I97664d041920c8d6e3f9fb7c9e8638925b15c30e
2017-10-30Define NOT_ROAMING network capability.android-o-mr1-iot-preview-6o-mr1-iot-preview-6Jeff Sharkey
The "roaming" state of a network really belongs on NetworkCapabilities instead of being published through NetworkInfo.isRoaming(). One major reason is to support developers creating NetworkRequests for a non-roaming network. Test: bit FrameworksNetTests:android.net.,com.android.server.net.,com.android.server.connectivity. Bug: 68397798, 16207332 Change-Id: I0722d7b38d0478de3834b869552f48403af9d553
2017-10-19ethernet: Fix the connect fail issue when switch DHCP to Static config at ↵Elvis Chien
Ethernet interface. add different logic to handle static ip configuration. Bug: b/64914694 <http://b/issue?id=64914694&query=64914694> Test: follow the following steps to switch ethernet config 1.Plug Ethernet cable ,Ethernet succeed to access internet with DHCP mode 2.Change Ethernet IP settings to Static 3.Input correct ip , gateway, prefix length, DNS 4.UI show Connected, but failed to access Internet. Change-Id: I223bca85814e94745fbb8b50ca677eb7032e9bb3 (cherry picked from commit 44a107bc8f058c6ac1aab6fbfbf60bf8f3474711)
2017-06-23Don't crash if the interface disappears just after appearing.android-o-preview-4android-o-iot-preview-5o-iot-preview-5Lorenzo Colitti
If the interface disappears between interfaceAdded() and setInterfaceUp, we'll crash with an IllegalStateException in NetworkManagementService#setInterfaceConfig. Ignore the error instead. This should be safe because we don't modify any state unless our calls succeed. Bug: 62870779 Test: builds aosp_bullhead-eng Change-Id: If8c2375f7fffe25a9fa79dc4f1981c745384a276
2017-06-19Make Ethernet more robust.Lorenzo Colitti
1. Remove the IP provisioning thread and just attempt provisioning indefinitely whenever we have an interface. 2. Make all methods run on the passed-in handler thread. This makes it easier to verify correctness by code inspection. 3. Remove the code that changes the factory score depending on whether we're tracking an interface and have link. This is unnecessary complexity, as there is no penalty to accepting a request even if we don't have an interface. 4. Remove code duplication and only have one codepath for stopping layer 3. Tested the following are tested with this CL: - Booting with an interface connected. - Disconnecting/reconnecting the Ethernet cable repeatedly, particularly at inconvenient times (e.g., during provisioning). - Similarly, disconnecting/reconnecting USB Ethernet interfaces. - Falling back to another Ethernet interface if the currently tracked Ethernet interface is unplugged. - Disconnecting and restarting provisioning when provisioning is lost (e.g., if the default route is deleted). - Crashing the system server causes Ethernet to reconnect on restart. - The above while running watch -n 0.1 adb shell dumpsys ethernet (cherry picked from commit 3c1204c1f3f0ee4e4e530772053f4003b7d58e99) Bug: 62308954 Test: tested on marlin with USB ethernet adapters, as described Test: smoketested on aosp_bullhead Change-Id: Ie3041f1d453d15c81eee81adfc8593269c499d79
2016-04-29Disable the IpManager timeout on Ethernet.nougat-devLorenzo Colitti
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
2016-02-22Use more IpManager featuresErik Kline
- WaitForProvisioningCallback - setHttpProxy - setTcpBufferSizes Bug: 26991160 Change-Id: I5e02039a35006f0466fb40c43805f0443cd758c2
2016-02-17Use IpManager on EthernetErik Kline
Bug: 17733693 Bug: 26991160 Change-Id: Idaee8c64bf452e58b93031d8d7ad666edb0c82ae
2015-09-08Don't crash on startup if we can't fetch the interface list.android-6.0.0_r26android-6.0.0_r25android-6.0.0_r24android-6.0.0_r23android-6.0.0_r13android-6.0.0_r12android-6.0.0_r11marshmallow-dr-releasemarshmallow-dr-devLorenzo Colitti
The intent of the code was to catch exceptions, but it wasn't actually doing that because when a netd command fails we get an IllegalStateException, not a RemoteException. Bug: 23581852 Change-Id: I66c7c33bdc7b0d0de4fa5cd92dff054797cf860f
2015-08-04Stop DHCP if it times out.Lorenzo Colitti
This was not necessary in L, but it is necessary after https://partner-android-review.googlesource.com/#/c/205415/ . Bug: 22936203 Change-Id: I24a96c33e5bb375f36217a1c2cec2076eb5ac8b4
2015-02-16am ef8e0b94: eth: make sure dhcp is stopped before bringing up interface.Pierre Couillaud
* commit 'ef8e0b9491467cf8d49fa3af7d43f12e3bd524e4': eth: make sure dhcp is stopped before bringing up interface.
2015-02-11eth: make sure dhcp is stopped before bringing up interface.Pierre Couillaud
Signed-off-by: Pierre Couillaud <pierre@broadcom.com> Signed-off-by: Blair Prescott <blairp@broadcom.com>
2014-11-19Add an API to check availability of Ethernet interface.android-cts-5.1_r9android-cts-5.1_r8android-cts-5.1_r7android-cts-5.1_r6android-cts-5.1_r5android-cts-5.1_r4android-cts-5.1_r3android-cts-5.1_r28android-cts-5.1_r27android-cts-5.1_r26android-cts-5.1_r25android-cts-5.1_r24android-cts-5.1_r23android-cts-5.1_r22android-cts-5.1_r21android-cts-5.1_r20android-cts-5.1_r2android-cts-5.1_r19android-cts-5.1_r18android-cts-5.1_r17android-cts-5.1_r16android-cts-5.1_r15android-cts-5.1_r14android-cts-5.1_r13android-cts-5.1_r10android-cts-5.1_r1android-5.1.1_r9android-5.1.1_r8android-5.1.1_r7android-5.1.1_r6android-5.1.1_r5android-5.1.1_r4android-5.1.1_r38android-5.1.1_r37android-5.1.1_r36android-5.1.1_r35android-5.1.1_r34android-5.1.1_r33android-5.1.1_r30android-5.1.1_r3android-5.1.1_r29android-5.1.1_r28android-5.1.1_r26android-5.1.1_r25android-5.1.1_r24android-5.1.1_r23android-5.1.1_r22android-5.1.1_r20android-5.1.1_r2android-5.1.1_r19android-5.1.1_r18android-5.1.1_r17android-5.1.1_r16android-5.1.1_r15android-5.1.1_r14android-5.1.1_r13android-5.1.1_r12android-5.1.1_r10android-5.1.1_r1android-5.1.0_r5android-5.1.0_r4android-5.1.0_r3android-5.1.0_r1lollipop-mr1-wfc-releaselollipop-mr1-releaselollipop-mr1-fi-releaselollipop-mr1-devlollipop-mr1-cts-releaseJaewan Kim
Bug: 18045481 Change-Id: I3fb517c3e7fa807e2937fda92026301e312be986
2014-10-01Clear all Ethernet state when our interface goes away.android-wear-5.0.0_r1android-cts-5.0_r9android-cts-5.0_r8android-cts-5.0_r7android-cts-5.0_r6android-cts-5.0_r5android-cts-5.0_r4android-cts-5.0_r3android-5.0.2_r3android-5.0.2_r1android-5.0.1_r1android-5.0.0_r7android-5.0.0_r6android-5.0.0_r5.1android-5.0.0_r5android-5.0.0_r4android-5.0.0_r3android-5.0.0_r2android-5.0.0_r1lollipop-wear-releaselollipop-releaselollipop-devlollipop-cts-releaseLorenzo Colitti
Previously we did not stop DHCP or try to force a disconnect. This made it impossible to reconnect by unplugging and replugging an USB Ethernet adapter. Bug: 17736828 Change-Id: Idd8576a96b063b5ca726ee9149800bdcb0f62bd1
2014-09-10Don't accept score below 0.Robert Greenwalt
Network Factories are allowed to go below, but networks need to be constrained. Allowing the network to go below 0 meant that -1 could sometimes leak through and foul the logic. bug:17361330 Change-Id: Ife34ca0f9c233dd3c3df80f6fea580af43afcdeb