Commit Graph

1184 Commits

Author SHA1 Message Date
Wayne Ma
cce8a9da85 Merge "Backwards-incompatible resolv module API change for making setResolverConfiguration take a parcelable." into qt-dev 2019-04-24 13:05:59 +00:00
Lorenzo Colitti
a484cc95d6 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

Merged-In: Ib59e211d4329f885108de9ea0a74669ffb144e17
(cherry picked from commit 8574c9bf350ca60e2b21c759aa75bc3843ffde17)

Change-Id: I603a0b0dfb67a942679a668c182aa650774c80b2
2019-04-24 13:55:48 +01: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
Rubin Xu
f8905980dc Merge "Reinstate new VPN uid filtering unit tests" am: 14ae90a4a6
am: c5f2f8e08d

Change-Id: Ic2faef44831575b2d03bc00ef2553d5c549adc95
2019-04-24 03:05:12 -07:00
Rubin Xu
3dc90033a9 Reinstate new VPN uid filtering unit tests
Mock out PackageManager and returns correct information corresponding
to the test app package itself.

Test: atest --generate-new-metrics 10 com.android.server.ConnectivityServiceTest
Bug: 114231106
Bug: 130397860
Change-Id: Ib921700eda417f411d7a2c77c1140fba9ab50bbb
2019-04-23 18:04:14 +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
Paul Hu
8aec50df25 Merge "Add tests for DhcpErrorEvent" 2019-04-23 11:31:03 +00:00
Junyu Lai
7e2ba67527 Merge "[KA11] Verify fd ownership and allocate resource for NattKeepalive" am: 91cc5cc467
am: a1ed113552

Change-Id: I410acc19ceb13e32c65cbdf3095da9db0802470c
2019-04-23 01:18:54 -07:00
junyulai
2bb85a0bc0 [KA11] Verify fd ownership and allocate resource for NattKeepalive
Since socket keepalive APIs for UDP encapsulation sockets are
public to generic app. In order to ensure the given fd is valid,
this change verifies the resource id inside the UDP
encapsulation socket by using methods provided by IpSecService.

Bug: 125517194
Fix: 123968920
Test: 1. atest FrameworksNetTests --generate-new-metrics 10
      2. atestcom.android.server.ConnectivityServiceTest \
         #testNattSocketKeepalives --generate-new-metrics 100
Change-Id: I408aacc19b364683854d15a095c34e72389a6e5b
2019-04-23 10:47:19 +08:00
Chalard Jean
e6a296dca5 Fix an argument to the legacy broadcast
Test: new test for this
Fixes: 62650382
Change-Id: I918b8271d3c3c058553ca888cb54cd36a6efba66
Merged-In: I0fc408d546ae9d72b7dd9415e502252b484d4329
Merged-In: I9282930106d1eee3274d9e5c4e89de60e929a0e6
2019-04-23 02:36:32 +00:00
Chalard Jean
ac1bcee0b8 Merge "Fix an argument to the legacy broadcast" am: 157c444fcf
am: 40b6f96f8d

Change-Id: I0fc408d546ae9d72b7dd9415e502252b484d4329
2019-04-22 18:12:27 -07:00
Chalard Jean
157c444fcf Merge "Fix an argument to the legacy broadcast" 2019-04-23 00:38:10 +00:00
Benedict Wong
6934b250e2 Merge "Add NATT keepalive resources and methods into IpSecService" am: 8ab1de2439
am: 866cba5a1b

Change-Id: I3affb5bdbb0c3f980b6606d728668e74c31646d0
2019-04-22 13:44:20 -07:00
Benedict Wong
8ab1de2439 Merge "Add NATT keepalive resources and methods into IpSecService" 2019-04-22 20:03:54 +00: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
Paul Hu
bce9cb271f Merge "Move more network unit tests to common tests" 2019-04-22 13:59:25 +00:00
Chalard Jean
37a2b46f75 Fix an argument to the legacy broadcast
Test: new test for this
Fixes: 62650382
Change-Id: I918b8271d3c3c058553ca888cb54cd36a6efba66
2019-04-22 22:26:16 +09:00
Luke Huang
fdd11f803c Make DNS cache lifecycle management explicit
1. ConnectivityService calls netd binder to create/destroy network directly.
2. Call dnsresolver binder to create/destroy cache after create/destroy network.
3. Remove unused network create/destroy methods in NetworkManagementService.

Bug: 129453995
Test: atest FrameworksNetTests
Change-Id: I15660d27f735e33d621d4af8972cdf115bf76dfa
2019-04-22 17:43:37 +08:00
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