Commit Graph

210 Commits

Author SHA1 Message Date
Lorenzo Colitti
752a4e3cd4 Move the NetworkStack tests to unit/ to add an integration test.
Test: m
Change-Id: If638183f45956b60d694c859a759dd761c0598b2
2019-05-21 15:23:23 +09:00
Lorenzo Colitti
91dd063172 Add a factoryReset method to IIpMemoryStore, and freeze api.
Currently unimplemented. Implementation will be in a future CL.

Test: m
Bug: 128499160
Change-Id: Ia11ecd33f528d01667b1baeb8671b7213a31eef5
2019-05-20 16:43:23 +09:00
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
4d492d89fa Merge "apf: Remove IPv6 NAT-T keepalive related codes and ApfTest improvement" 2019-05-15 06:17:43 +00:00
Richard Uhler
87462d79ff Use embedded native libs for NetworkStack.apk.
So that the /system version of NetworkStack.apk can be re-installed on
/data without causing problems. This is useful for testing and necessary
for supporting rollback to the system version of NetworkStack.apk.

Bug: 131703417
Bug: 132195177
Test: Confirm NetworkStack.apk now includes .so files.
Test: adb install --staged NetworkStack.apk
      adb reboot
      Device reboots without problems.

Change-Id: I7c9a1702a2c18e0333b5e409f04b7658fe685f97
Merged-In: I7c9a1702a2c18e0333b5e409f04b7658fe685f97
(cherry picked from commit 103dbe38b4)
2019-05-14 15:18:01 +01: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
c4104f029f Merge "Dropping NAT-T keepalive packet from APF" 2019-05-13 11:33:37 +00: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
Aaron Huang
42e73893e0 Merge "Send message to add/remove NAT-T keepalive packet filter." 2019-05-10 13:57:11 +00:00
Chalard Jean
a56eab41a6 Merge "Support strict mode private DNS on VPNs that provide Internet." 2019-05-10 09:39:17 +00:00
Lorenzo Colitti
80986d9a53 Support strict mode private DNS on VPNs that provide Internet.
Currently, strict mode private DNS does not work on VPNs because
NetworkMonitor does not validate VPNs. When a VPN connects, it
immediately transitions to ValidatedState, skipping private DNS
hostname resolution.

This change makes NetworkMonitor perform private DNS hostname
resolution and evaluation even on VPNs.

In order to ensure that the system always immediately switches to
the VPN as soon as it connects, remove the unvalidated penalty
for VPN networks. This ensures that the VPN score is always 101
and the VPN always outscores other networks as soon as it
connects. Previously, it would only outscore other networks
when no-op validation completed.

Bug: 122652057
Test: atest FrameworksNetTests NetworkStackTests
Test: manually ran a VPN with private DNS in strict mode
atest android.net.cts.ConnectivityManagerTest com.android.cts.net.HostsideVpnTests
Change-Id: Iaa78a7edcf23755c89d7b354edbc28d37d74d891
2019-05-10 14:30:54 +09: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
abfef61707 Merge "Switch to positive naming for NetworkMonitor's Networks." 2019-05-09 11:57:50 +00:00
Lorenzo Colitti
6a4ae85e23 Merge "Add tests for strict mode private DNS validation." 2019-05-09 11:57:25 +00: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
Xiao Ma
a489a8d495 adopt non-blocking method to obtain the IpMemoryStore service.
Test: atest FrameworksNetTests
Change-Id: I7de4f23370bdf9c9df5e74ed074c794080d93d95
2019-05-09 10:39:50 +09:00
Aaron Huang
706ff1b00c Send message to add/remove NAT-T keepalive packet filter.
Remove definition of TYPE_NATT and TYPE_TCP since the type
can be identified by checking message.obj is an instance of
NattKeepalivePacketData or TcpKeepalivePacketData.
It's more simple and won't have dependency on KeepaliveInfo.

Bug: 33530442
Test: atest FrameworksNetTests
      atest NetworkStackTests

Change-Id: Ic97ffe9ff5781778efd264460809f5059f0f4230
2019-05-06 19:52:48 +08: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
d38eaa8820 Merge "Revert "Make the network stack a persistent process."" 2019-04-29 01:40:34 +00:00
Lorenzo Colitti
5574fd5248 Revert "Make the network stack a persistent process."
This reverts commit 796afddd6c.

Reason for revert: breaks updatability because persistent processes are not updatable.

Change-Id: I35ded113b31e742f13ad8523a10af3a83a111374
2019-04-27 15:02:50 +00: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
yuanyunli
43f1bc9d53 Parse the server host name field of the dhcp package
Some hotspot devices will fill in the server host name field of the DHCP
package, such as iphone. Parsing the server host name of the DHCP
package can help identify ios hotspots.

Bug: 120584519
Test: 127423755
Test: builds, boots, wifi works
Change-Id: Idbe10c36332ce421f1bba93eb87e9e1e12463088
2019-04-26 22:59:52 +09:00
Chiachang Wang
d32d766a04 Merge "Remove Settings constants for NetworkStack" 2019-04-25 04:49:04 +00:00
Chiachang Wang
e6d0ab916a Remove Settings constants for NetworkStack
The definitions reference of these constants are moved from
Settings to DeviceConfig. These definitions are @hide and the
usage in the Settings are removed. Thus, remove the definitions
from API level.

Bug: 123167629
Test: make system-api-stubs-docs-update-current-api \
      test-api-stubs-docs-update-current-api
Test: atest NetworkStackTests
Change-Id: I28c4bf2c0b72e154cea91d11007a9497c7f21570
Merged-In: I7291cfa86cd6e907df35e8fbc97e2e9a77e56cab
Merged-In: Ic48bea07e79490dd3787068bc88c748525752a61
2019-04-25 02:40:51 +00:00
Treehugger Robot
d0e7befaaf Merge "Make the network stack a persistent process." 2019-04-24 16:25:24 +00:00
Lorenzo Colitti
796afddd6c Make the network stack a persistent process.
The network stack should never be killed, because if it does,
recovering networking requires a reboot. Make the process
persistent to reduce the chances of it being killed by the OOM
killer.

Bug: 131046856
Test: builds, boots
Test: process oom_score_adj is -800
Test: process goes from "Persistent Service" to "Persistent" in dumpsys meminfo
Change-Id: Ic8ebf6356e23489f6cd984d680ff9f1b4cbbe52d
2019-04-24 22:36:55 +09:00
Lorenzo Colitti
11aaadd6ae Delete unused timeout constant.
Test: m
Bug: 129312219
Change-Id: I5b4c8b42dea515f674ff10d64d0e1d06d849cca1
2019-04-24 17:11:12 +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
587ee7240e Merge "Move Setting constants for NetworkStack" 2019-04-18 07:35:19 +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
Chalard Jean
896245a1e2 Move TrafficStats tags for the network stack constants
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-17 05:45:40 +00:00
Remi NGUYEN VAN
08d4a537ec Merge "Change the validation URL for Chinese SIMs" 2019-04-12 01:18:12 +00:00
Treehugger Robot
7db7b331ef Merge "provide a resource overlay to configure customized DNS Server." 2019-04-11 11:06:51 +00:00
Chiachang Wang
076317a01f Merge "Address nit in NetworkStackUtils" 2019-04-11 10:48:58 +00:00
Remi NGUYEN VAN
de568f7289 Change the validation URL for Chinese SIMs
The default HTTPS and fallback validation URLs are not accessible from
China, so users in China never get a validated network on WiFi with the
default AOSP settings. OEMs selling devices targeting China typically
change the check URLs for that reason.

When the device uses a Chinese SIM card, change the default validation
URLs to URLs accessible accessible from China as of now.

Test: inserted China SIM, WiFi off/on, dumpsys network_stack shows new
      URL used
Bug: 111819230
Change-Id: Ib7f41f470ef1a9c7712f2477ebfab44e915cf1b9
2019-04-11 17:23:35 +09:00
Xiao Ma
a4d0122048 provide a resource overlay to configure customized DNS Server.
Bug: 122621524
Test:  atest FrameworksNetTests NetworkStackTests
Change-Id: I123b3d4516cc6ba6d17629eb74daf448ba7121eb
2019-04-11 15:30:23 +09:00
Chiachang Wang
b805040fef Address nit in NetworkStackUtils
Follow up commit to fix nit in aosp/937891

Bug: 120013793
Test: Build
Change-Id: I61a6306d3c439a2d72323ab56e2b47771cc60d48
2019-04-11 11:10:51 +08:00
Remi NGUYEN VAN
eb8d81ca14 Merge "Freeze netd AIDL interface (framework)" 2019-04-11 00:13:29 +00: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