Commit Graph

75 Commits

Author SHA1 Message Date
Chiachang Wang
b846759154 Merge "Fix a bug where private DNS to v4-only servers don't validate." 2019-05-15 09:52:50 +00:00
Chiachang Wang
0f449289da Fix a bug where private DNS to v4-only servers don't validate.
Bug: 132670008
Test: Manual
Test: atest NetworkStackTests
Change-Id: I8ae6fa6f3800f5f6c9ee88ffe3b8ada34b96dee6
(cherry picked from commit aea0808d3b26dab24005afc39eb7ec4f4f333bae)
2019-05-15 16:18:56 +08:00
Aaron Huang
d287837d98 apf: Remove IPv6 NAT-T keepalive related codes and ApfTest improvement
Remove IPv6 related codes since we don't support IPv6 NAT-T keepalive
as the kernel doesn't support IPv6 UDP encapsulation.

Renaming keepaliveAck to keepaliveResponce since NAT-T keeaplive
response is not an ack. Also, add generateV4NattKeepaliveFilters()
if multicast filter is disabled.

Verify incoming packet contains 1 byte payload but it is not 0xff will
pass NAT-T keepalive filter.

Bug: 33530442
Test: atest FrameworksNetTests
      atest NetworkStackTests

Change-Id: Ifb9e088c0c8d71c763ebd9ad122103d0f97ca278
2019-05-14 19:58:16 +08:00
Aaron Huang
a746964854 Dropping NAT-T keepalive packet from APF
Add NAT Traversal keepalive filter to APF program to
drop NAT-T keepalive packets when NAT-T keepalive
offload is starting.

Bug: 33530442
Test: - atest NetworkStackTests
      - atest FrameworksNetTests

Change-Id: I1c537485e11b31e5a6e0d8b7b6a1f396f9441746
2019-05-10 22:41:48 +08:00
Chiachang Wang
e37f8729d1 Use async dns query to resolve all addresses
Currently, it looks like private DNS server resolution uses
OneAddressPerFamilyNetwork and only returns one server address.
It should return all addresses. Use async dns api for this.

Bug: 123435238
Test: atest NetworkStacktests
Change-Id: I9f50da3c8c2e3b12b29bc8844291e4bf1559cd1f
2019-05-09 21:28:47 +08:00
Lorenzo Colitti
ac12b84ef0 Switch to positive naming for NetworkMonitor's Networks.
"mNonPrivateDnsBypassNetwork" is not very easy to understand.

Bug: 122652057
Test: atest FrameworksNetTests NetworkStackTests
Change-Id: If5801c81c6ef222b46f631bd6570dcd0fea465bd
2019-05-09 17:58:49 +09:00
Lorenzo Colitti
62f3e53f68 Add tests for strict mode private DNS validation.
Test successful and failed validation, and updating the config.
In order to do this, add a FakeDns class so we can change DNS
responses dynamically while the test is running.

Also a couple of minor fixes:
1. Make sure the DNS timeout is set. Before this CL, it was
   always 0. Not sure why. It does seem to be set to the default
   value (12500) when actually running on device. We didn't
   catch this because the only tests that use the timeout set it
   explicitly.
2. Make runNetworkTest a bit more realistic: always send
   NetworkCapabilities *before* calling notifyNetworkConnected.
   This is what ConnectivityService does.

Bug: 122652057
Test: atest FrameworksNetTests NetworkStackTests
Test: atest --generate-new-metrics 50 NetworkStackTests:com.android.server.connectivity.NetworkMonitorTest
Change-Id: Ifd6694262501874f3261c864a049cb35c6afb9c8
2019-05-09 17:58:48 +09:00
Lorenzo Colitti
c73cc60d57 Make NetworkStack actually build in an unbundled setup.
The Java code was already using sdk_version: "current", but the
JNI library did not have an sdk_version attribute, and had
forbidden dependencies on internal libraries such as libcutils,
liblog and libnativehelper.

This CL fixes things as follows:
- Use the NDK log functions, and switch to the NDK liblog.
- Switch to the NDK libnativehelper.
- Drop the dependencies on libcutils and libpcap, which were
  unused.
- Use the libc++ STL, and set the sdk_version of the library to
  current.

Bug: 131703417
Test: m
Test: installed NetworkStack APK via "adb install --staged" results in working networking
Test: builds, boots, wifi works
Test: atest FrameworksNetTests NetworkStackTests

(cherry picked from commit 3d680e887b)

Change-Id: I8a0a8d4b4e8872cb88ee526772ae519a8e6df615
2019-05-01 21:52:21 +09:00
Aaron Huang
9eeaa3aa9e Support adding NATT keepalive packet filter
Support adding NATT keepalive packet filter to APF
filter.
Generating APF program will be addressed in another CL.

Bug: 33530442
Test: - atest NetworkStackTests
      - atest FrameworksNetTests

Change-Id: I4961d5da343d8700600269632787c28112f0f9f1
2019-04-29 19:33:45 +08:00
Lorenzo Colitti
65f6ae271b Fix some checkstyle nits in DhcpPacketTest.
Use the Generated code suppression comment filter instead of the
IndentationCheck suppression comment filter because the latter
complains that '+' should be on a new line.

Bug: 120584519
Bug: 127423755
Test: atest NetworkStackTests
Test: atest FrameworksNetTests
Change-Id: Ia9865c75f940e2fbb3aef374a297339e8ea2fd1b
2019-04-27 16:36:39 +09:00
Lorenzo Colitti
681f33cc6a Additional code for server name in DHCP packets.
- Add the hostname to DhcpResultsParcelable.
- Don't store the server hostname if option overload is in use,
  as this is not valid.
- Add unit tests.

Bug: 120584519
Bug: 127423755
Test: atest NetworkStackTests
Test: atest FrameworksNetTests
Change-Id: I47d9d53d1fb58968322cc8b071a44fbc8f7156e1
2019-04-27 16:36:10 +09:00
Lorenzo Colitti
e721b4b83e Merge "Add a timeout for the DNS probe." 2019-04-23 14:13:14 +00:00
Remi NGUYEN VAN
1232fe37be Freeze the networkstack-aidl-interfaces interface
This freezes the interface as of the latest beta build, not the tip of
tree. IIpClient#setL2KeyAndGroupHint is not in the frozen definition in
particular.

Generated with:
m networkstack-aidl-interfaces-freeze-api \
    ipmemorystore-aidl-interfaces-freeze-api

Test: flashed, booted, WiFi and captive portal working
Bug: 128803828
Change-Id: Ideabe73fc93bbefca2d624ee9ca190cf31419424
2019-04-23 06:49:58 +00:00
Lorenzo Colitti
6413419435 Add a timeout for the DNS probe.
Bug: 129312219
Test: atest NetworkStackTests
Test: atest --generate-new-metrics 50 NetworkStackTests:com.android.server.connectivity.NetworkMonitorTest
Change-Id: Ib3ab9105d7ae39f551b51e8d5a04b9ec5e549655
2019-04-22 23:38:58 +09:00
Chalard Jean
1ad99fb064 Merge changes Id598ae1d,I475bd011
* changes:
  Fix a possible crash when the listener is null
  Straighten AIDL interface for the memory store
2019-04-22 02:15:04 +00:00
Chalard Jean
da3421e6e5 Straighten AIDL interface for the memory store
Some names were still wrong somehow, and the wrappers were
missing.

Test: NetworkStack & FrameworkNetTests
Change-Id: I475bd011ad9bc714a07021a9dfd85c4876f8e9ad
Merged-In: I475bd011ad9bc714a07021a9dfd85c4876f8e9ad
2019-04-22 00:40:28 +00:00
Chiachang Wang
32df8810c6 Merge changes from topic "StatsLog.write_migrate"
* changes:
  Java code for mainline modules to log to statsd.
  Migrate NetworkStack metrics off StatsLog.write
2019-04-19 00:58:24 +00:00
Chiachang Wang
e987ba6ccd Migrate NetworkStack metrics off StatsLog.write
Now that the new metrics API can be used, NetworkStack
metrics need to migrate off the legacy StatsLog.write.

Bug: 130323000
Test: Test with ./out/host/linux-x86/bin/statsd_testdrive 121
      to ensure log properly
Test: Ensure NetworkStackStatsLog will be generated as expected
Test: atest NetworkStackTest

cherry-picking commit e512b26913.

Change-Id: I8c70503cf1d9f1d06f30a1936d2d88857d0cff53
Merged-In: I1bfe856d771bf56fe33790aea22eceae2001921a
2019-04-18 09:28:01 +08:00
Chiachang Wang
8b2a8821a9 Move Setting constants for NetworkStack
From mainline perspective, we should use android flag api
instead of using Settings. Thus, move the definitions into
NetworkStack and apply new flag design.

Bug: 123167629
Test: atest NetworkStackTests
Change-Id: I9602263f0bff5d8e942bd652de69ccfcb3034a2f
2019-04-17 17:00:54 +08:00
Lorenzo Colitti
047940eff0 Merge "Add lifecycle tests to NetworkMonitorTest" 2019-04-10 09:30:03 +00:00
Chiachang Wang
e9a39ceb6b Merge "Move data stall definitions out from Setting" 2019-04-10 03:27:19 +00:00
Chiachang Wang
2449e583d8 Move data stall definitions out from Setting
From mainline perspective, we should use android flag api
instead of using Settings. Thus, move the definitions into
NetworkStack.

Bug:120013793
Test: atest NetworkStackTests SettingsBackupTest
Change-Id: I8e1fb5b47fff3bf624131ba1f5732daabd991e6d
Merged-In: I8e1fb5b47fff3bf624131ba1f5732daabd991e6d
Merged-In: I0a2a1e5d3de14ea86556ca471e26064df3481412
2019-04-10 02:37:57 +00:00
Lorenzo Colitti
cdef556adf Add lifecycle tests to NetworkMonitorTest
- Ensure that NetworkMonitor quits when notifyNetworkDisconnected
  is called.
- Ensure that BroadcastReceivers are registered when a captive
  portal is detected and unregistered when the network validates
  or when NetworkMonitor quits.

Bug: 122164725
Test: atest FrameworksNetTests NetworkStackTests
Test: atest --generate-new-metrics 10 NetworkStackTests:com.android.server.connectivity.NetworkMonitorTest
Test: test fails if "Don't leak captive portal broadcast receivers." change reverted
Change-Id: I1202626face33cc1e1ec02016b95da487b3335c8
2019-04-09 23:12:33 +09:00
Niklas Lindgren
afc5f9bd3d Expose captive portal urls for configuration
Carriers in Mainland China need to customize certain captive portal
urls. The main issue is that google servers are not accessible in
Mainland China.

Added the following captive portal resources to be targeted for overlay.
- config_captive_portal_http_url
- config_captive_portal_https_url
- config_captive_portal_fallback_urls (string-array)
- config_captive_portal_fallback_probe_specs (string-array)

These values can be customized for e g diffent countries

Bug: 111819230
Test: atest FrameworksNetTests NetworkStackTests
Test: Add a product RRO that targets a specific country code,
insert a SIM card that matches that country code and check the log
what URL is used.
Change-Id: I38a294a5e14417f65e96e76235ea153c53c4d7cc
2019-04-09 10:23:53 +09:00
Remi NGUYEN VAN
35487f959a Add NetworkStackTests dependency on libdl_android
This fixes tests that were failing because of the unsatisfied
dependency.

Test: atest NetworkStackTests
Bug: 129387775
Change-Id: Ie0c1bc2b292ad7172d144d9e7ad9edeecd2232b7
(cherry picked from commit 329c4dadbe)
2019-04-06 11:20:38 +02:00
Remi NGUYEN VAN
66d744ba74 Merge "Add a mechanism to pass the L2Key and group hint to IpClient" 2019-04-05 07:30:02 +00:00
Remi NGUYEN VAN
1ddf974859 Merge "Move attach*Filter() and addArpEntry() methods to NetworkStack" 2019-04-05 06:38:08 +00:00
Chalard Jean
3cab290648 Add a mechanism to pass the L2Key and group hint to IpClient
Test: IpClientTest
Change-Id: I399b20ce29a385a74971b7a7248a48cb4d66deb6
2019-04-05 12:51:04 +09:00
Yifan Hong
e4d640b3a8 Merge "Fix NetworkStackTests." 2019-04-04 01:21:34 +00:00
Yifan Hong
0e5459731f Fix NetworkStackTests.
NetworkStackTests dlopens library which indirectly
uses libcgrouprc. Add it to jni_libs.

Test: atest
Fixes: 129902619
Change-Id: I0d60d7a317fa60607d6fdaea15f61b458aefd2f0
2019-04-03 18:15:22 -07:00
paulhu
931cdd273f Move attach*Filter() and addArpEntry() methods to NetworkStack
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-04-03 17:49:36 +08:00
paulhu
b0f53b84cc Make CaptivePortalProbeSpec and CaptivePortalProbeResult as a library
These two classes were added to @SystemApi because they are used
both by NetworkMonitor and CaptivePortalLogin. However it turns
out they are not needed in the framework, so having them as a
library sounds better.

Change-Id: Iadf77ec5952b6da8812dc6d006a39bd4e93d2bd9
Fix: 129433264
Test: atest NetworkStackTests FrameworksNetTests
2019-04-02 17:55:42 +08:00
paulhu
028d7a55fd [IPMS] Implement regular maintenance
Implement regular maintenance of IpMemoryStoreService. Regular
maintenance is scheduled for when the device is idle with access
power and a minimum interval of one day.

Bug: 113554482
Test: atest NetworkStackTests
Change-Id: Id3985e30d12307fc2e9fcbe782caaf97a627cef3
2019-04-01 23:35:36 +08:00
Xiao Ma
17ea70c6d3 Merge "Add DHCP address lease expiry in IpMemoryStore." 2019-04-01 12:59:20 +00:00
Remi NGUYEN VAN
78454f3c46 Merge "Fix race when starting NetworkMonitor" 2019-04-01 03:54:03 +00:00
Remi NGUYEN VAN
3962f678c3 Fix race when starting NetworkMonitor
NetworkMonitor obtained LinkProperties and NetworkCapabilities via
synchronous calls to ConnectivityManager after receiving an asynchronous
notification, which is prone to races: the network could be gone before
the LinkProperties/NetworkCapabilities can be fetched.

Fix the race by passing LinkProperties/NetworkCapabilities directly to
NetworkMonitor in the asynchronous notifications.

Test: atest FrameworksNetTests NetworkStackTests
Test: booted, WiFi works
Bug: 129375892
Change-Id: I200ac7ca6ff79590b11c9be705f650c92fd3cb63
2019-04-01 11:33:10 +09:00
Xiao Ma
385ccb05c8 Add DHCP address lease expiry in IpMemoryStore.
Bug:122710829
Test: atest FrameworksNetTests
Change-Id: I643fe1231edcd18923514ab66c64a6cf83e69443
2019-03-29 16:51:47 +09:00
Aaron Huang
75a6043bf1 apf: Documentation improvements and code optimizations for keepalive filters
Optimizing instruction to reduce code size of keepalive filters.

Bug: 123992088
Test: atest NetworkStackTests
Change-Id: I9ae55977c6d6740277ba55603ee957f33a97ecaa
2019-03-25 23:38:41 +08:00
Lucas Lin
f6cbc2d533 Merge "Improve partial connectivity" 2019-03-21 03:34:30 +00:00
lucaslin
4333899a41 Improve partial connectivity
Improve the design and fix some nits.

Bug: 113450764
Test: 1. Build pass
      2. atest FrameworksNetTests
      3. atest NetworkStackTests
      4. Change captive_portal_https_url to https://invalid.com
      to simulate partial connectivity.
Change-Id: Ia56645841d00d2ed8406cfeacb86a4a27fd58650
2019-03-20 18:21:59 +08:00
Chalard Jean
952135122d Move the IpMemoryStore to the network stack.
Test: atest FrameworksNetTests
Change-Id: Ic5bd6ff54b09a6fa92b6863f240a5b053011acb6
2019-03-18 11:33:17 +09:00
Remi NGUYEN VAN
e80be85790 Remove aidl wrappers for framework parcelables
The new @JavaOnlyStableParcelable annotation allows using the framework
parcelables directly, which removes a lot of boilerplate.

Includes new copy constructors for IpPrefix and LinkAddress so they can
be copied easily as-is into parcelables.

Test: atest FrameworksNetTests
Test: booted, WiFi works
Bug: 126477266

Change-Id: Icac8afe498d0b5ebf9a0d0b9eceb14d64a29b381
2019-03-16 03:50:58 +09:00
lucaslin
e252a740ca Check if network has partial connectivity
In some networks, network validation may only get success
result for http probe but fail result for https probe.
For this kind of network, it may still work at some websites
or apps, but user didn't know about that. In order to fix this
issue, we will check if network has partial connectivity and
notify user to make a choice if they want to use this partial
connectivity or not.

Bug: 113450764
Test: 1. Build pass.
      2. Fake partial connectivity case for testing.
      3. atest FrameworksNetTests
      4. atest NetworkStackTests

Change-Id: I69ed00ac4850904ff708c9fef22e148879a10e92
2019-03-12 07:37:33 +00:00
Remi NGUYEN VAN
b8f2ab9362 Merge "Use an in-process APK for in-process NetworkStack" 2019-03-12 01:37:26 +00:00
Remi NGUYEN VAN
06d8067975 Merge changes I9dbbf904,Iebc174ed
* changes:
  Move NetworkStackTests to presubmit
  Remove NetworkStack test dependency on testutils
2019-03-11 02:06:27 +00:00
Remi NGUYEN VAN
8acc99a974 Use an in-process APK for in-process NetworkStack
Instead of having a library in the classpath where the NetworkStack is
created by reflection on devices using the network stack in-process,
just bind to a version of the network stack service that runs in the
system process.

If the in-process version is installed it will be used, otherwise the
module is used with its own process.

Bug: 127908503
Test: blueline boots and has functional WiFi
Test: atest FrameworksNetTests NetworkStackTests
Test: svelte build boots and has functional WiFi
Change-Id: I7722b173e5686e0dbb9cfddcfb34344b0f4135d9
2019-03-08 19:18:40 +09:00
Remi NGUYEN VAN
22cd685c0a Remove NetworkStack test dependency on testutils
frameworks-base-testutils is close to unused in the tests, and has the
side-effect of adding some unrelated tests to be run in
NetworkStackTests like TestLooperTest. TestLooperTest is also failing in
some cases.

Bug: 127908503
Test: atest NetworkStackTests
Change-Id: Iebc174ed1362e8c341d765129a7fc51f8ed1999d
2019-03-08 18:05:41 +09:00
Chiachang Wang
e43f162371 Not to use any() to verify DataStallDetectionStats
Build a empty DataStallDetectionStats object instead of use
any() to do the verification to prevent NPE while trying to
write the metrics.

Bug: 120452078
Test: atest NetworkStackTests
Change-Id: Ib9f3e56195a539a5ca4826b4aad0e38945a9a3a7
2019-03-08 14:34:19 +08:00
Chiachang Wang
4349dc08c9 Update description based on API feedback
Bug: 126883311
Test: Build pass
      atest NetworkStackTests
Change-Id: If3d21829bbe98d125215abe96247ca7d5a66d1f3
2019-03-05 20:31:57 +08:00
Brett Chabot
8091d9e6d9 Migrate frameworks/base/tests/testables and its users to androidx.test
See go/jetpack-test-android-migration

Test: atest TestablesTests NetworkStackTests FrameworksServicesTests SystemUITests FrameworksUiServicesTests ExtServicesUnitTests
Exempt-From-Owner-Approval: already reviewed
Change-Id: I083fcdaa71b503535aa2b3c257740f3ecf055373
Merged-In: Ib04d80954bd8536914d88c66b28e6632e60a6245
2019-03-01 17:23:42 +00:00