Commit Graph

445 Commits

Author SHA1 Message Date
junyulai
4dca18aa31 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

Change-Id: I0218f3674628c13ead63fc9a873895ba7f113033
2019-05-10 00:36:58 +08:00
Xiao Ma
42f6be8b40 Merge "adopt non-blocking method to obtain the IpMemoryStore service." am: 14b9e8b6d8
am: 042800ead0

Change-Id: If0d43f21710ca31149610d3e6a5f0d7e4acc11a2
2019-05-09 04:55:13 -07:00
Xiao Ma
afc8845452 adopt non-blocking method to obtain the IpMemoryStore service.
Test: atest FrameworksNetTests
Change-Id: I7de4f23370bdf9c9df5e74ed074c794080d93d95
2019-05-09 10:39:50 +09:00
Paul Hu
5e05934c54 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 9e046d509a37c6f37b4757f1681846cee60cfd5c)
2019-04-29 01:49:17 +00:00
Paul Hu
9ede7e9399 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 cc21fbd483138771dae04f4d86ab411e2e88e575)
2019-04-25 23:16:13 +08:00
Rubin Xu
dc587d75e1 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 65968ea16bf49f678d4a43c220e1d67393170459)
2019-04-24 11:56:46 +01:00
Paul Hu
5bc4f002b0 Merge "Add tests for DhcpErrorEvent" am: 8aec50df25
am: 1fe65ae26c

Change-Id: I9b65a2eef94567d2b79a9955619938e64906080d
2019-04-23 09:50:28 -07:00
Remi NGUYEN VAN
71a25d5827 Add tests for DhcpErrorEvent
The tests are run both in unit and CTS tests.
Test: atest FrameworksNetTests NetworkStackTestCases
Bug: 129200175

Change-Id: I52976bbbaca26fb317836e8461e372c25df02a22
2019-04-23 00:19:06 +08:00
Paul Hu
9dc3a9e437 Merge "Move more network unit tests to common tests" am: bce9cb271f
am: 457b5be451

Change-Id: I9f708a252ab606b782f5f828dce8c1690c3703bf
2019-04-22 07:30:55 -07:00
Lorenzo Colitti
73a6ab946c Merge changes I4f181789,Ia8a0c99b am: 1744b240f6
am: c4ac34f834

Change-Id: Ib59e211d4329f885108de9ea0a74669ffb144e17
2019-04-12 06:37:28 -07:00
Remi NGUYEN VAN
0539d81793 Merge "Revert "Block incoming non-VPN packets to apps under fully-routed VPN"" am: 27a60a1aff
am: 8de7fec0d0

Change-Id: I3e1c408fcfc14db8b2586a79416233ffe9e1173d
2019-04-12 06:24:30 -07:00
Lorenzo Colitti
bad9d911b8 Revert "Revert "Block incoming non-VPN packets to apps under fully-routed VPN""
This reverts commit bc571c7cc8.

Reason for revert: Rolling forward, will fix tests in same CL stack.

Bug: 114231106
Bug: 130397860
Test: FrameworksNetTests
Change-Id: Ia8a0c99b4e1fd5dff26c881715cd876618ca4321
2019-04-12 19:52:32 +09:00
Remi NGUYEN VAN
bc571c7cc8 Revert "Block incoming non-VPN packets to apps under fully-routed VPN"
This reverts commit 4773027064.
This change does not have any topic: not reverting the other 2 commits in the original topic.

Reason for revert: broke FrameworksNetTests presubmit: b/130397860

Change-Id: Iff41d9fe97fafea44680c8d67d1ce19277548cc0
2019-04-12 09:05:40 +00:00
Remi NGUYEN VAN
5564d5a8f6 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: I4c3d31ed595024af84093ca9110ed43633c383f4
2019-04-12 14:51:22 +09:00
Rubin Xu
131a0722cc Merge "Block incoming non-VPN packets to apps under fully-routed VPN" am: fd20f8da0a
am: 8951473446

Change-Id: I5af81bc80dadd086261ba4b1eb706cc873bb7cfa
2019-04-11 11:45:43 -07:00
Rubin Xu
4773027064 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
Change-Id: I143b03d60e46cb1b04732b4a4034f5847b4d1b1a
2019-04-10 17:05:54 +01:00
Remi NGUYEN VAN
fb21e4697b 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 054e3e0f5ebfffe5d9fdd0095abac309552ae0cd)
2019-04-05 05:52:03 +00:00
Remi NGUYEN VAN
732b67a250 Merge "Add common tests for FrameworksBaseTests and CTS" am: e2908b64dd
am: 25a8bf080c

Change-Id: I863ffea6358a353986cee7b1c76622c434310bba
2019-04-04 09:25:22 -07:00
Remi NGUYEN VAN
49b15870a9 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: I9c138d49ce010edde095e4bd3c47e36ca301634a
2019-04-03 18:53:04 +09:00
Paul Hu
777b96dcad Merge "Fix IpPrefixTest#testContainsInetAddress fail." am: 9c58ddc48e am: b9cffc513e
am: 736189fc88

Change-Id: I9e74dc9bf30a53ce78395e502a52891ba488f4b1
2019-04-01 19:24:38 -07:00
paulhu
207037a243 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
2476c3f532 Merge "Add DHCP address lease expiry in IpMemoryStore." am: 98aa76e2e8 am: bdb1f90f32
am: 77bd196428

Change-Id: Ib09ee6a702fb25a682d4782a8822237ebb9a0dfb
2019-04-01 06:35:34 -07:00
Xiao Ma
3c33ee5d81 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
06b4b6f92e 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
2af0b66aba 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
612520f544 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
Mark Chien
f2a195cad0 Merge "[TCPKeepalive] Fill correct TOS and TTL value" am: 13cc9e442e am: 52ffa51e7f
am: 73062f4600

Change-Id: I80c56a14a0be2e6b7996f2bcb9a1a320f0c2c058
2019-03-25 06:44:17 -07:00
markchien
b5a2b8076a [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
2e2bc9c173 Merge "Fix Automated API Review issues." am: acb5eca325 am: f1f3b08982
am: affa3f497d

Change-Id: Iba1630161579571d4975aba9bbd5c767f82c8a98
2019-03-21 11:54:51 -07:00
Paul Hu
acb5eca325 Merge "Fix Automated API Review issues." 2019-03-21 17:19:26 +00:00
Mark Chien
3fd041d2ec Merge "Replace TcpSocketInfo with similar structure" am: a460377cf9 am: bee0fa077b
am: 846e87b170

Change-Id: I9b51e6905245ada2707ef7498cc1b8e4cb4c69a0
2019-03-21 05:35:15 -07:00
paulhu
cbbc3db924 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
458c95b9ff 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
b71b242e7e Merge "Add Parcelable implementation for ApfCapabilities" am: d64b329979 am: 57b7aa8ec2
am: 84890d80e0

Change-Id: I4d878b8dc0928aca47f944050becaa4d5206e336
2019-03-19 18:09:23 -07:00
Remi NGUYEN VAN
d64b329979 Merge "Add Parcelable implementation for ApfCapabilities" 2019-03-20 00:34:53 +00:00
Xiao Ma
cefa778aa4 Merge "Move the IpMemoryStore to the network stack." am: edb899fcf8 am: 61e928c7cd
am: 78e3f9ab7d

Change-Id: I243056012d2f099d96a33657c0eb63a5b66a2cfe
2019-03-19 06:54:43 -07:00
Chalard Jean
4ae71e9ebc Move the IpMemoryStore to the network stack.
Test: atest FrameworksNetTests
Change-Id: Ic5bd6ff54b09a6fa92b6863f240a5b053011acb6
2019-03-18 11:33:17 +09:00
Remi NGUYEN VAN
df04297b86 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
1f01518b68 Merge "Check if network has partial connectivity" am: 2d3cc4577a am: 0ea87a4edb
am: 973a569390

Change-Id: Ib6c5ecc8238e1ac237eddcc00802fa5e7c0e24b9
2019-03-12 01:47:25 -07:00
lucaslin
2240ef679d 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
Brett Chabot
8e95e2105d Merge "Migrate frameworks/base/tests/net/ to androidx.test" am: e69a7a1554 am: 29e6ab8d01
am: 38f02479d6

Change-Id: I01657671712799f5a29a3a7530430cc5bfb14f41
2019-03-06 22:10:32 -08:00
Brett Chabot
147f6cf341 Migrate frameworks/base/tests/net/ to androidx.test
Test: atest FrameworksNetTests
Change-Id: Iaa59d606f5e1678cc5aaca9ed37e184fad894e5d
2019-03-05 09:05:47 -08:00
Chalard Jean
cd6d2a46eb Merge "[KA03.5] Add stable AIDL parcelable for TcpKeepalivePacketData" am: 6e55aca3fa am: 90cad47708
am: aa12af640b

Change-Id: I700550160c795becb4c3e37a88328488846d272f
2019-02-06 01:47:49 -08:00
Chalard Jean
a627caa478 Merge "[KA03] Support tcp keepalive offload" am: 5f8ddc2eb1 am: 0b93464e32
am: d6cedf5ed3

Change-Id: I55d7b285a75946713986163fbaa166d4b02513d4
2019-02-05 22:41:37 -08:00
junyulai
80d0356311 [KA03.5] Add stable AIDL parcelable for TcpKeepalivePacketData
Bug: 114151147
Test: atest FrameworksNetTests
Change-Id: I057dde79013b9eda5037b9a44f8eee06cc07352e
2019-02-06 14:07:39 +09:00
markchien
e5591ce2fa [KA03] Support tcp keepalive offload
When offload is starting, socket will be switched to repair
mode. Read and write on the socket will not be allowed until
repair mode is turned off. If remote packet arrives, repair
mode will be turned off automatically and a callback will
be raised to indicate that socket is ready to read from.

Bug: 114151147
Test: -atest FrameworksNetTests
      -manual

Change-Id: I0c335865912e183e7ad32a8ea12188f02ccde5fd
2019-02-06 12:22:22 +09:00
Remi NGUYEN VAN
8f8deae60f Merge "Move NetworkUtils used by NetworkStack" 2019-01-28 09:06:20 +00:00
Remi NGUYEN VAN
b19997dbe9 Merge "Move NetworkUtils used by NetworkStack" 2019-01-28 06:57:25 +00:00
Remi NGUYEN VAN
98d9df7a9b Move NetworkUtils used by NetworkStack
Depending on usage move into NetworkStackUtils or shared
Inet4AddressUtils.

Test: atest FrameworksNetTests NetworkStackTests
Bug: 112869080
(Cherry-pick of aosp/881952)
Change-Id: Ie20dcee375b377236004a7689890729493aca857
2019-01-28 13:45:46 +09:00
Remi NGUYEN VAN
e167e117c1 Move NetworkUtils used by NetworkStack
Depending on usage move into NetworkStackUtils or shared
Inet4AddressUtils.

Test: atest FrameworksNetTests NetworkStackTests
Bug: 112869080
Merged-In: Ie20dcee375b377236004a7689890729493aca857
Change-Id: Ib8d000529872796022706a35050fdc2c7141f2ab
2019-01-28 13:45:17 +09:00