Commit Graph

412 Commits

Author SHA1 Message Date
Xiao Ma
239e81596a Clean up the arguments annotation and verify items on IpMemoryStoreTest.
Bug: 131133347
Test: atest FrameworksNetTests

Merged-In: I8ce3bed435fbbb814d71fe48ffd305ff3f947f3f
Merged-In: I1db13a48b59d743482436ecf8a20d7f12edd6e1c
(cherry picked from commit 7567c4ac50)

Change-Id: I78024c0e25d812639d1236faa59d383742ae2141
2019-05-15 14:53:42 +00:00
junyulai
2ee367ece9 Support customization of supported keepalive count per transport
This change specifies the required minimum supported keepalives
in SDK, and allows OEMs to customize supported keepalive count
per network through resource overlay.

Bug: 129371366
Test: 1. m -j doc-comment-check-docs
      2. atest FrameworksNetTests

Clean cherry-pick of aosp/946359

Change-Id: I06840834d0ee8121358bf4829fe47ecf9964d395
Merged-In: I0218f3674628c13ead63fc9a873895ba7f113033
Merged-In: Ia667386c1a8949839871a6949d79552d9c8b88f0
2019-05-13 15:52:07 +09:00
Xiao Ma
3ce093b527 adopt non-blocking method to obtain the IpMemoryStore service.
Bug: 131133347
Test: atest FrameworksNetTests
Merged-In: I7de4f23370bdf9c9df5e74ed074c794080d93d95
Merged-In: If0d43f21710ca31149610d3e6a5f0d7e4acc11a2

Change-Id: If0d43f21710ca31149610d3e6a5f0d7e4acc11a2
(cherry picked from commit c4e4fd7bee)
2019-05-10 00:55:14 +00:00
TreeHugger Robot
fa2e9939d2 Merge "Add tests for DhcpErrorEvent" into qt-dev 2019-04-30 11:57:59 +00:00
Lorenzo Colitti
4d92d76567 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: I5e9fee5471740f5d7c001e9e98017f32be452344
Merged-In: I60071bc029d25485bf204cfd3a8cebd538ca12b6
(cherry picked from commit 681f33cc6a)
2019-04-29 10:54:42 +09:00
Paul Hu
be257d806e Add tests for DhcpErrorEvent
The tests are run both in unit and CTS tests.
Test: atest FrameworksNetTests NetworkStackTestCases
Bug: 129200175

Change-Id: I78d78dd421cc3ffea774ff5eaa6aa758debc9cf2
Merged-In: I9b65a2eef94567d2b79a9955619938e64906080d
Merged-In: I78d78dd421cc3ffea774ff5eaa6aa758debc9cf2
(cherry picked from commit 9e046d509a)
2019-04-29 01:49:17 +00:00
Paul Hu
469c5d69e5 Move more network unit tests to common tests
This adds the moved tests to CTS as well.
The moved unit tests are appropriate for CTS as they test data holder
classes that need to function properly for apps to work.

Test: atest FrameworksNetTests
Test: atest CtsNetTestCases: added tests pass
Bug: 129199900

Change-Id: I895d2b57da658d5bed28ebe128611d5d15835742
Merged-In: I9f708a252ab606b782f5f828dce8c1690c3703bf
Merged-In: I895d2b57da658d5bed28ebe128611d5d15835742
(cherry picked from commit cc21fbd483)
2019-04-25 23:16:13 +08:00
Rubin Xu
9a3f724597 Block incoming non-VPN packets to apps under fully-routed VPN
When a fully-routed VPN is running, we want to prevent normal apps
under the VPN from receiving packets originating from any local non-VPN
interfaces. This is achieved by using eBPF to create a per-UID input
interface whitelist and populate the whitelist such that all
non-bypassable apps under a VPN can only receive packets from the VPN's
TUN interface (and loopback implicitly)

This is the framework part of the change that build the whitelist.
The whitelist needs to be updated in the following cases:
* When a VPN is connected and disconnected
    This will cover the change to allowBypass bit, since that can't be
    changed without reconnecting.
* When a VPN's NetworkCapabilites is changed (whitelist/blacklist app changes)
* When a new app is installed
* When an existing app is removed
* When a VPN becomes fully-routed or is no longer fully-routed

New user/profile creation will automatically result in a whitelist app change
transition so it doesn't need to be handled specially here.

Due to the limitation of the kernel IPSec interacting with eBPF (sk_buf->ifindex
does not point to the virtual tunnel interface for kernel IPSec), the whitelist
will only apply to app VPNs but not legacy VPN connections, to prevent breaking
connectivity with kernel IPSec entirely.

Test: atest PermissionMonitorTest
Test: atest android.net.RouteInfoTest
Test: atest com.android.server.ConnectivityServiceTest
Test: atest HostsideVpnTests
Bug: 114231106

Merged-In: I5af81bc80dadd086261ba4b1eb706cc873bb7cfa
Change-Id: I5af81bc80dadd086261ba4b1eb706cc873bb7cfa
(cherry picked from commit 65968ea16b)
2019-04-24 11:56:46 +01:00
Chiachang Wang
bd92d1539f Enforce NETWORK_STACK permission for calling NSS#forceUpdateIfaces
ConnectivityManager and its usages are removed from
NetworkStatsService. After that, forceUpdateIfaces requires
information that only ConnectivityService has, hence
restricting the calling permission to NETWORK_STACK or
MAINLINE_NETWORK_STACK permission. The required permission
will be changed from READ_NETWORK_USAGE_HISTORY to
NETWORK_STACK or MAINLINE_NETWORK_STACK. This change would make
it impossible to call outside the system.

Bug: 126830974
Test: atest FrameworksNetTests
Merged-In: I1b26dc64eaab2151e6885fd01cc5e8d4e18c4e60
Change-Id: I4ea421e4126a45f65d25fe0bec74243a3b20aeab
(cherry picked from commit 6b895dea25)
2019-04-10 06:36:55 +00:00
Lorenzo Colitti
b878dff849 Disable InetDiagSocketTest in a better way.
Test: treehugger
Bug: 124354087
Bug: 128024100
Change-Id: I3048625a2507e70402ce376e7208f58cdf5ddfba
Merged-In: I3d8cebec00dde7d0b61469f36887cd5afface043
Merged-In: I1fcb9ca292777fb017e9108a3e12cffba87e1985
(cherry picked from commit 2373c8a129)
2019-04-09 06:40:07 +00:00
Lorenzo Colitti
db54f46641 Temporarily disable InetDiagSocketTest.
This test is too flaky to run in presubmits.

Bug: 124354087
Test: atest InetDiagSocketTest
Change-Id: I90bc52a6f5b92d634862e3464634dfdbd3cada6a
Merged-In: Ic580b9261e0d556ec10f92ddffd8f2766e25f424
Merged-In: Ide5ac3f5316c4671b17fb9486ac56fc5feaf7b08
(cherry picked from commit fdc03bab0b)
2019-04-09 06:38:08 +00:00
Remi NGUYEN VAN
7aea73b882 Add common tests for FrameworksBaseTests and CTS
The common package covers tests that should be included both in CTS and
unit tests.

Test: atest FrameworksBaseTests
Bug: 129199908
Change-Id: Ic78ff947250871fa773252c924f1dee9395c6074
(cherry picked from commit 054e3e0f5e)
2019-04-05 05:52:03 +00:00
Paul Hu
d3c115b26a Merge "Make CaptivePortalProbeSpec and CaptivePortalProbeResult as a library" am: 3db9cfe660 am: 2d20cd2378
am: 4bf4e79766

Change-Id: Iccf60b710df5895d8d269b6c918a8b2f252e93a6
2019-04-02 21:19:14 -07: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
Paul Hu
c533a42c80 Merge "Fix IpPrefixTest#testContainsInetAddress fail." am: 66a133858b am: 9872066d02
am: c13f50f5af

Change-Id: I9e74dc9bf30a53ce78395e502a52891ba488f4b1
2019-04-01 19:24:38 -07:00
paulhu
4fcdc7ed05 Fix IpPrefixTest#testContainsInetAddress fail.
The argument of IpPreFix#contains() has been marked as @NonNull.
So the IpPrefixTest#testContainsInetAddress should not test
contains() method wiht null object.

Bug: None
Test: atest FrameworksNetTests
      atest IpPrefixTest#testContainsInetAddress

Change-Id: I2f6bee19514dc47702f64d2a2bbf02d8b7b1b407
2019-04-02 00:49:00 +08:00
Xiao Ma
60a54acbbf Merge "Add DHCP address lease expiry in IpMemoryStore." am: 17ea70c6d3 am: 23f6cd281a
am: 8e6c80f238

Change-Id: Ib09ee6a702fb25a682d4782a8822237ebb9a0dfb
2019-04-01 06:35:34 -07: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
Varun Anand
6c93e5378a Merge changes from topic "vpn_data_accounting"
* changes:
  Move BatteryStats and StatsCompanionService to use NetworkStatsService.
  NetworkStatsService: Fix getDetailedUidStats to take VPNs into account.
  Take all VPN underlying networks into account when migrating traffic for VPN uid.
2019-03-29 00:40:53 +00:00
Varun Anand
29d2ef2fe1 NetworkStatsService: Fix getDetailedUidStats to take VPNs into account.
This API is similar to one provided by NetworkStatsFactory with the
difference that NSS also migrates traffic from VPN UID to other apps.

Since traffic can only be migrated over NetworkStats delta, NSS
therefore maintains NetworkStats snapshot across all UIDs/ifaces/tags.

This snapshot gets updated whenever NSS records a new snapshot
(based on various hooks such as VPN updating its underlying networks,
network getting lost, etc.), or getDetailedUidStats API is invoked by
one of its callers.

Bug: 113122541
Bug: 120145746
Test: atest FrameworksNetTests
Test: manually verified that battery stats are migrating traffic off of
TUN (after patching above CL where we point BatteryStats to use this
API).
Change-Id: Ib0f0c2d4d41ee1d7a027ea9da457baaf198d649e
2019-03-28 10:31:51 -07:00
Varun Anand
95aa6d446f Take all VPN underlying networks into account when migrating traffic for
VPN uid.

Bug: 113122541
Bug: 120145746
Test: atest FrameworksNetTests
Test: Manually verified on device that stats from VPN UID are moved
      appropriately based on its declared underlying network set.
Test: vogar --mode app_process --benchmark NetworkStatsBenchmark.java

Change-Id: I9d8d0cc58d18002c1c96f8ddff780ef8dc452d21
2019-03-28 10:31:49 -07:00
Remi NGUYEN VAN
b38180edc1 Merge "Use SystemApi framework parcelables directly" am: 021ea66aea am: 4864ffd97e
am: ddac1161d9

Change-Id: I99a21274856a0f9903cc8242f91735128117919f
2019-03-26 20:28:03 -07:00
Treehugger Robot
021ea66aea Merge "Use SystemApi framework parcelables directly" 2019-03-27 02:55:15 +00:00
Remi NGUYEN VAN
266868246a Use SystemApi framework parcelables directly
Remove StaticIpConfigurationParcelable and ApfCapabilitiesParcelable and
use StaticIpConfiguration and ApfCapabilities directly.
These two classes are SystemApi and defined in framework.jar, so no
stability guarantee is needed: the parceled and unparceled class will
always be the framework.jar version.

Bug: 126477266
Fixes: 126477266
Test: atest FrameworksNetTests NetworkStackTests
Test: flashed, booted, WiFi and captive portal works.
Change-Id: Iaf80ae23e003752cc6d2300700021931923b6533
2019-03-26 12:05:27 +09:00
Mark Chien
cddc41318e Merge "[TCPKeepalive] Fill correct TOS and TTL value" am: 6aef2afd4e am: 37dd29a169
am: 71f6e5b794

Change-Id: I80c56a14a0be2e6b7996f2bcb9a1a320f0c2c058
2019-03-25 06:44:17 -07:00
markchien
1fc82b223f [TCPKeepalive] Fill correct TOS and TTL value
Fill correct TOS/TTL value by fetching them from kernel with
getsockopt.

bug: 123967966
Test: -build, flash, boot
      -atest FrameworksNetTests

Change-Id: I75b1be51040b4a381163958b4cddd27dbb22bac1
2019-03-25 11:14:57 +08:00
Paul Hu
21b9f61f6f Merge "Fix Automated API Review issues." am: 43c1ade661 am: 9e3f29037b
am: ce18c5a1ec

Change-Id: Iba1630161579571d4975aba9bbd5c767f82c8a98
2019-03-21 11:54:51 -07:00
Paul Hu
43c1ade661 Merge "Fix Automated API Review issues." 2019-03-21 17:19:26 +00:00
Mark Chien
6be24edf54 Merge "Replace TcpSocketInfo with similar structure" am: a34aa2acab am: 43411c851d
am: 840623e94e

Change-Id: I9b51e6905245ada2707ef7498cc1b8e4cb4c69a0
2019-03-21 05:35:15 -07:00
paulhu
d9736de38b Fix Automated API Review issues.
1. Some API's argument/return value must be marked either
@NonNull or @Nullable.
2. Change some system APIs to public APIs.
3. Modify the method name

Bug: 126700123
Bug: 126702339
Bug: 126699682
Bug: 118296575
Bug: 126699216
Bug: 126699675
Bug: 126699429
Bug: 126699193
Bug: 123586045
Test: atest FrameworksNetTests
Change-Id: Iaa2832cdcf83758ed0fec81b954a0c63bc5a7bf6
2019-03-21 13:55:37 +08:00
markchien
d42fca678e Replace TcpSocketInfo with similar structure
Replace TcpSocketInfo with TcpKeepalivePacketDataParcelable
because their structures are very similar.

bug: 128882321
Test: -build, flash, boot
      -FrameworksNetTests

Change-Id: Iafb4031a64ba4775a495c156e2c997d890c6b261
2019-03-20 22:29:48 +08:00
Remi NGUYEN VAN
c3f661ffdb Merge "Add Parcelable implementation for ApfCapabilities" am: cea27f4327 am: 39e5f3feaf
am: 61ac53a0fc

Change-Id: I4d878b8dc0928aca47f944050becaa4d5206e336
2019-03-19 18:09:23 -07:00
Remi NGUYEN VAN
cea27f4327 Merge "Add Parcelable implementation for ApfCapabilities" 2019-03-20 00:34:53 +00:00
Xiao Ma
2ce206c82d Merge "Move the IpMemoryStore to the network stack." am: 93bf5ef495 am: 5db1518bfa
am: 3176d57308

Change-Id: I243056012d2f099d96a33657c0eb63a5b66a2cfe
2019-03-19 06:54:43 -07:00
Xiao Ma
93bf5ef495 Merge "Move the IpMemoryStore to the network stack." 2019-03-19 13:21:12 +00:00
Luke Huang
f004c56618 Merge "Refactor answer callback for async DNS query JAVA API" am: f1d0fd2642 am: 9a4c839725
am: 6e2648a7bc

Change-Id: Id4d0ae87b1ac8618c28da666619c5c5b5bd2d722
2019-03-18 23:24:06 -07:00
Luke Huang
f1d0fd2642 Merge "Refactor answer callback for async DNS query JAVA API" 2019-03-19 05:35:18 +00: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
462e944ff9 Merge "Remove aidl wrappers for framework parcelables" am: 1a1396070e am: 7cf43a2f53
am: 5fd40295cb

Change-Id: I019fbbfd5dde5268cbb38bdaee1bc50a434372bc
2019-03-17 18:59:43 -07:00
Luke Huang
304491dba8 Refactor answer callback for async DNS query JAVA API
1. refactor AnswerCallback with a generic type
2. support onError in AnswerCallback
3. Fix minor problem reported from API Review

Bug: 124882626
Test: built, flashed, booted
      atest DnsResolverTest DnsPacketTest

Change-Id: I685c9989f8401acb63d2e83f552b2d5b20c41af0
2019-03-16 18:53:05 +08: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
Remi NGUYEN VAN
3ac239292c Add Parcelable implementation for ApfCapabilities
This is necessary to allow usage of ApfCapabilities as-is in AIDL,
instead of relying on ApfCapabilitiesParcelable, assuming that stable
AIDL starts allowing usage of @SystemApi classes. The Parcelable
implementation would be convenient for clients in any case.

Bug: 126477266
Test: atest FrameworksNetTests
Change-Id: Id2ef3cad261832a2918ccb6bb6bc154d99d75746
2019-03-15 13:41:59 +09:00
Lucas Lin
fc0fbbb3af Merge "Check if network has partial connectivity" am: 174ae05817 am: 6cf91d1558
am: c0448b383f

Change-Id: Ib6c5ecc8238e1ac237eddcc00802fa5e7c0e24b9
2019-03-12 01:47:25 -07: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
Luke Huang
e2ff3cb9fd Merge "Minor changes to the async DNS query JAVA API" am: c8dfb72891 am: 5b0b36a6b4
am: 6a047b2645

Change-Id: I5ce24db3888c9ac4e05af254aa99aae3abcb7140
2019-03-09 04:33:13 -08:00
Luke Huang
33bfef3b54 Minor changes to the async DNS query JAVA API
1. refine the naming in DnsPacket and add more comment
2. add comment in DnsResolver

Test: built, flashed, booted
      atest DnsResolverTest DnsPacketTest

Change-Id: Ib482d079d6823fd1d9bff163427b7aad38374199
2019-03-07 16:40:49 +08:00
Brett Chabot
0f73a36b6f Merge "Migrate frameworks/base/tests/net/ to androidx.test" am: 58038da960 am: dc1077d5db
am: 1e33868f0b

Change-Id: I01657671712799f5a29a3a7530430cc5bfb14f41
2019-03-06 22:10:32 -08:00
Brett Chabot
1ae2aa66eb Migrate frameworks/base/tests/net/ to androidx.test
Test: atest FrameworksNetTests
Change-Id: Iaa59d606f5e1678cc5aaca9ed37e184fad894e5d
2019-03-05 09:05:47 -08:00
Chalard Jean
de626e0520 Merge "[KA03.5] Add stable AIDL parcelable for TcpKeepalivePacketData" am: 533b2960fc am: 968c9f495c
am: 66b84e3c44

Change-Id: I700550160c795becb4c3e37a88328488846d272f
2019-02-06 01:47:49 -08:00
Chalard Jean
f431962460 Merge "[KA03] Support tcp keepalive offload" am: 5f8ddc2eb1 am: 6bbaced544
am: 9eb8724be7

Change-Id: I55d7b285a75946713986163fbaa166d4b02513d4
2019-02-05 22:41:37 -08:00