Commit Graph

1265 Commits

Author SHA1 Message Date
Chalard Jean
de9b8a9d7e Make LegacyTypeTracker testable
...and add basic trivial tests for it.

Test: this, and ConnectivityServiceTest
Bug: 62650382
Change-Id: Ie7ca938e6f66f1b15feb6ed93afa0aebb20884ae
2019-04-22 15:44:23 +09:00
Chalard Jean
8fe63a3498 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
08c2d9e81f 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
Chalard Jean
1395062bb4 Merge "Make LegacyTypeTracker testable" am: 54cedaca89
am: 080562b154

Change-Id: I53457ad6af430c551c6909a7e68127a3667efde9
2019-04-21 17:25:03 -07:00
Benedict Wong
bdf7048571 Add NATT keepalive resources and methods into IpSecService
This change adds a new NATTKeepalive resource type, along with the
associated allocation/deallocation. Additionally, this change allows
ReferenceCountedResource(s) to not be binder-linked, to allow the
ConnectivityService to verify ownership and allocate a NattKeepalive
without double-registering for binder-death notifications.

Bug: 125517194
Test: IpSecService frameworks tests ran
Change-Id: I8293f79940ad57dabb6f2b9de5e334d06b869443
2019-04-19 11:17:21 -07:00
Chalard Jean
3a3f5f2a08 Make LegacyTypeTracker testable
...and add basic trivial tests for it.

Test: this, and ConnectivityServiceTest
Bug: 62650382
Change-Id: Ie7ca938e6f66f1b15feb6ed93afa0aebb20884ae
2019-04-19 15:33:44 +09:00
Wayne Ma
cd616ebc95 Backwards-incompatible resolv module API change for making setResolverConfiguration take a parcelable.
Test: built, flashed, booted
      atest FrameworksNetTests

Bug: 130788363
Change-Id: I3b4e8672f5273c3baa9378025bfaef2e6514df64
Merged-In: I6dc9029af0df0d3b391210bd315516bdf1b5e4c9
(cherry picked from commit 9e9fda7558a924feb86869fca7dc7fd7dd01a78c)
2019-04-18 11:06:51 +00:00
Wayne Ma
89ddc90b91 Merge "Backwards-incompatible resolv module API change for making setResolverConfiguration take a parcelable." am: c9308bb32d
am: 009dcb2d12

Change-Id: I6dc9029af0df0d3b391210bd315516bdf1b5e4c9
2019-04-17 07:26:59 -07:00
Wayne Ma
c9308bb32d Merge "Backwards-incompatible resolv module API change for making setResolverConfiguration take a parcelable." 2019-04-17 13:58:11 +00:00
waynema
7b76545b94 Backwards-incompatible resolv module API change for making setResolverConfiguration take a parcelable.
Test: built, flashed, booted
      atest FrameworksNetTests

Change-Id: I3b4e8672f5273c3baa9378025bfaef2e6514df64
2019-04-17 13:55:53 +00:00
Junyu Lai
2ffcae18d9 Merge "Release keepalive slot after stopped" am: 79c7b5a300
am: 82a0ddb40d

Change-Id: I8bf18f5dd10412f251071cea8140793b22c7fd95
2019-04-15 22:16:02 -07:00
Junyu Lai
79c7b5a300 Merge "Release keepalive slot after stopped" 2019-04-16 04:46:18 +00:00
junyulai
e1bed4ddfa Release keepalive slot after stopped
Currntly, keepalive slot is released when stop() is called. Next
starting keepalive can use the same slot number while previous
keepalive is still stopping. When the previous keepalive is
stopped, the incoming as will be processed by the new keepalive.

This change release keepalive slot after the result of stopping
has returned. Thus, newly created keepalive cannot allocate the
same slot number while lower layer is still processing stop event.

This change also disable flaky assertions that are caused by
test port has been occupied by other process.

Bug: 129512753
Test: 1. atest com.android.server.ConnectivityServiceTest \
         #testNattSocketKeepalives --generate-new-metrics 100
      2. atest FrameworksNetTests --generate-new-metrics 10
      3. simulate the fail case manually.

Change-Id: I1991627545519ee5cb408a3df3a006f710f4af7b
2019-04-15 17:44:48 +08: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
44c6efb9c1 Revert new tests and PackageManager mock
A mocked PackageManager caused test failures in existing tests.
Revert that for now to make tests pass again.

Bug: 114231106
Bug: 130397860
Test: atest FrameworksNetTests
Change-Id: I4f181789152438f18e6cd2d235d76fabe3872ea3
2019-04-12 19:52:45 +09: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
Benedict Wong
608168402b Fix remove-before-add for IpSecService RefcountedResource
This patch fixes a bug where if a binder dies before the linkToDeath
call, the cleanup will be performed before the entry is added to the
array. While it is safe in that quotas and tracking performs as per
normal, the RefcountedRecord may not be cleaned up.

Rethrowing this exception is safe, since the only paths that would hit
this are all on binder threads coming from applications. Further, it
seems there is only one real way of this getting hit - if the app that
called the creation died during the binder call.

Bug: 126802451
Test: Compiled, CTS tests passing
Change-Id: Ib955acaa5e498c0e977cb5f2e48cffbc9fea8c7c
Merged-In: I6db75853da9f29e1573512e26351623f22770c5d
Merged-In: I416c2e43961ec0e1cc6b2fbcef970fbce858603b
Merged-In: Ib955acaa5e498c0e977cb5f2e48cffbc9fea8c7c
(cherry picked from commit 6c089d90bfa728e9842de0f5947f0c557c62dea0)
2019-04-09 21:37:26 +00:00
Benedict Wong
b64f22c9b4 Merge "Fix remove-before-add for IpSecService RefcountedResource" am: 342d6de289
am: 15b70fe885

Change-Id: I416c2e43961ec0e1cc6b2fbcef970fbce858603b
2019-04-09 10:56:30 -07:00
Benedict Wong
342d6de289 Merge "Fix remove-before-add for IpSecService RefcountedResource" 2019-04-09 17:22:56 +00:00
Lorenzo Colitti
cd1fec8907 Fix flaky UdpEncapsulationSocket test
This commit reduces the flakiness of the
testOpenAndCloseUdpEncapsulationSocket by retrying up to three times.
Unfortunately, testing port-selected socket creation is racy against
other applications. This helps to handle the same race condition as done
in IpSecService#bindToRandomPort

Bug: 128024100
Test: 200x runs of testOpenAndCloseUdpEncapsulationSocket
Change-Id: I7e036ce821019dbac6c50899bd0894e89d2fe82a
Merged-In: Idf040a67e53d9b9ec6e6c647ce24f8ada501d355
Merged-In: Iad9aea4b42cd8b31a5a2659bb9cb54dd1c64e8b7
(cherry picked from commit 614ab3dd4e49e9b664f5065983fb9067148fef12)
2019-04-09 06:44:32 +00:00
Benedict Wong
2d9864ab3c Fix remove-before-add for IpSecService RefcountedResource
This patch fixes a bug where if a binder dies before the linkToDeath
call, the cleanup will be performed before the entry is added to the
array. While it is safe in that quotas and tracking performs as per
normal, the RefcountedRecord may not be cleaned up.

Rethrowing this exception is safe, since the only paths that would hit
this are all on binder threads coming from applications. Further, it
seems there is only one real way of this getting hit - if the app that
called the creation died during the binder call.

Bug: 126802451
Test: Compiled, CTS tests passing
Change-Id: I6db75853da9f29e1573512e26351623f22770c5d
2019-04-08 18:51:50 -07:00
Treehugger Robot
c832132056 Merge "Move NetworkStatsFactory into service directory" 2019-04-05 19:27:22 +00: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
Lorenzo Colitti
97a2e106c5 Merge "Fix flaky UdpEncapsulationSocket test" am: 95e8a2b5c3
am: 3b7fefe97e

Change-Id: Idf040a67e53d9b9ec6e6c647ce24f8ada501d355
2019-04-04 09:18:29 -07:00
Treehugger Robot
e2908b64dd Merge "Add common tests for FrameworksBaseTests and CTS" 2019-04-04 12:29:44 +00:00
Lorenzo Colitti
95e8a2b5c3 Merge "Fix flaky UdpEncapsulationSocket test" 2019-04-04 08:09:06 +00:00
Benedict Wong
b5bc70dc6a Fix flaky UdpEncapsulationSocket test
This commit reduces the flakiness of the
testOpenAndCloseUdpEncapsulationSocket by retrying up to three times.
Unfortunately, testing port-selected socket creation is racy against
other applications. This helps to handle the same race condition as done
in IpSecService#bindToRandomPort

Bug: 128024100
Test: 200x runs of testOpenAndCloseUdpEncapsulationSocket
Change-Id: I7e036ce821019dbac6c50899bd0894e89d2fe82a
2019-04-03 17:52:03 -07:00
TreeHugger Robot
76e2c02339 Merge "Move NetworkStatsFactory into service directory" 2019-04-03 23:44:26 +00:00
Chenbo Feng
6566d1b82f Move NetworkStatsFactory into service directory
In order to notify netd to swap eBPF maps before pulling the
networkStats from eBPF maps, NetworkStatsFactory need to use the
NetdServices to issue binder calls. So it need to be moved from
framework/base/core to framework/base/service since object in
framework/base/core cannot get any system services. This change is also
necessary for setting up a lock inside NetworkStatsFactory to prevent
racing between two netstats caller since the lock need to be hold before
netd trigger the map swap.

Also fix the compile problem caused by moving the NetworkStatsFactory
and the related tests. Rename the packages and the jni functions to a
more proper name.

Bug: 124764595
Bug: 128900919
Test: NetworkStatsFactoryTest
      android.app.usage.cts.NetworkUsageStatsTest
      android.net.cts.TrafficStatsTest

Change-Id: Ifcfe4df81caf8ede2e4e66a76552cb3200378fa8
2019-04-03 14:28:41 -07:00
Chalard Jean
8aaebde014 Merge "Straighten AIDL interface for the memory store" 2019-04-03 19:58:46 +00:00
Chenbo Feng
550ed56426 Move NetworkStatsFactory into service directory
In order to notify netd to swap eBPF maps before pulling the
networkStats from eBPF maps, NetworkStatsFactory need to use the
NetdServices to issue binder calls. So it need to be moved from
framework/base/core to framework/base/service since object in
framework/base/core cannot get any system services. This change is also
necessary for setting up a lock inside NetworkStatsFactory to prevent
racing between two netstats caller since the lock need to be hold before
netd trigger the map swap.

Also fix the compile problem caused by moving the NetworkStatsFactory
and the related tests. Rename the packages and the jni functions to a
more proper name.

Bug: 124764595
Bug: 128900919
Test: NetworkStatsFactoryTest
      android.app.usage.cts.NetworkUsageStatsTest
      android.net.cts.TrafficStatsTest

Merged-In: Ifcfe4df81caf8ede2e4e66a76552cb3200378fa8
Change-Id: Ifcfe4df81caf8ede2e4e66a76552cb3200378fa8
2019-04-03 11:33:40 -07:00
Chenbo Feng
9a10bb92b7 Merge "Clean up permissions when uids are no longer used" am: 9235821478 am: 6825c65462
am: c3a583e52e

Change-Id: I7773132d11d6225eac91ab2fee1043159c295d83
2019-04-03 11:03:32 -07:00
Treehugger Robot
9235821478 Merge "Clean up permissions when uids are no longer used" 2019-04-03 17:15:48 +00: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
Chenbo Feng
ade2fe930a Merge "Add tests for PermissionMonitor" am: 4e39721f18 am: e11632e768
am: 073ca45f14

Change-Id: Ifcb29bfded1b1675231c397ed886506a70267279
2019-04-03 02:19:30 -07:00
Chalard Jean
8472116bff Straighten AIDL interface for the memory store
Some names were still wrong somehow, and the wrappers were
missing.

Test: NetworkStack & FrameworkNetTests
Change-Id: I475bd011ad9bc714a07021a9dfd85c4876f8e9ad
2019-04-03 15:18:08 +09:00
Treehugger Robot
4e39721f18 Merge "Add tests for PermissionMonitor" 2019-04-03 06:12:12 +00:00
Chenbo Feng
fe00494c97 Clean up permissions when uids are no longer used
The kernel eBPF maps have a blacklist to store all the uids that doesn't
have internet permission. When an app is unintalled from the device and
it is the last package on device that uses that uid, make sure we
cleaned the uid from the map and do not add no longer used uids into the
eBPF map. This action helps reduce the number of entries stored in the
map and reduce the chance of overflow the eBPF map.

Bug: 128944261
Test: PermissionMonitorTest
Change-Id: I10dd0113d00d6cf9ca39902d9721f2591d387d4a
2019-04-02 20:31:57 -07:00
Chenbo Feng
1401715e6f Add tests for PermissionMonitor
Add more tests to PermissionMonitor to verify the functionality related
to INTERNET permission and UPDATE_DEVIE_STATS permission. Modified some
of the class design of PermissionMonitor so that it is easier to test
the new functionalities.

Bug: 111560570
Test: PermissionMonitorTest

Change-Id: Ic5585f337db5de48e2f87bf4f01ed7d85c349827
2019-04-02 20:31:49 -07:00
Paul Hu
6aeeca832f Merge "Address leftover comments on 923337 and 930217." am: a9b8e31cf8 am: bc8ca075ef
am: 6106d1e017

Change-Id: I75eadb66c81d72c768e77feddd383d60f8accd65
2019-04-02 01:29:08 -07:00
Paul Hu
a9b8e31cf8 Merge "Address leftover comments on 923337 and 930217." 2019-04-02 07:39:04 +00: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