Commit graph android_packages_modules_Co.../tests/net/java/com
Message SHA1
Add one more test for VPN usage stats.
(cherry picked from commit 54bb4f4608)

Covers the case where the majority of traffic through the VPN is
caused by the VPN app itself, and ensures that that traffic is
correctly attributed to the VPN app as opposed to spread between
the other apps that use the VPN.

Bug: 120145746
Test: atest NetworkStatsServiceTest
Change-Id: Ibd7646dc088fa4180abd696e89c3148ff34ce190
Merged-In: Iffd3f95fc2e11d311691a797b010edb38d2ef3c6

Lorenzo Colitti   authored and   Varun Anand   commited 2019-05-30 15:59:28 +00:00
e13b3791a0
Addressing comments for http://ag/7700679.
(cherry picked from commit 8031acad0e)

Note, that its in a separate CL so we could cherry-pick this CL to aosp.
http://ag/7700679 is already in aosp (http://aosp/865073).

Bug: 113122541
Bug: 120145746
Test: atest FrameworksNetTests

Change-Id: Ic1767bc8bf1460e4223f86465fc72344428e6055
Merged-In: I7cfda226b4ed11b67002b83b38fba0f5caf96718

Varun Anand   commited 2019-05-30 15:59:07 +00:00
ab4f831229
Merge "Always give VPN the INTERNET capability."
Chalard Jean   authored and   Gerrit Code Review   commited 2019-05-30 08:36:19 +00:00
a24f3216be
Always give VPN the INTERNET capability.
Split-tunnel VPN (which are the only ones affected by this change)
always fall through to the default network for routes they don't
handle, and even if the underlying network(s) don't provide access
this may be a pinhole that can actually reach the broader network.

In practice this behaves like the original release of P and is the
safest thing to do for Q. In R we should evaluate giving the VPN
app the ability to simply tell the network stack whether it does
provide Internet access or not.

Bug: 119216095
Test: FrameworksNetTests NetworkStackTests
Change-Id: I262ca41fe0225660551c9a421562405366b6acac

Chalard Jean   commited 2019-05-30 16:11:14 +09:00
16da69ea0e
Merge "NetworkStatAccess Should checkCarrierPrivileges cross all subscriptions"
Chen Xu   authored and   Gerrit Code Review   commited 2019-05-29 17:15:41 +00:00
43b5e55334
NetworkStatAccess Should checkCarrierPrivileges cross all subscriptions
Bug: 133236378
Test: Manual
Change-Id: I49fbde1fe73b33aadcf8fd23ad224f363b137bf3

chen xu   commited 2019-05-28 23:28:56 -07:00
38b98ab27c
Add a common test library.
This is the most common test library for Connectivity tests. It is
meant to be usable in framework tests, network stack tests, CTS,
GTS. To achieve that, it can only depend on framework classes.

Bug: none
Test: NetworkMonitorTest
Test: NsdManagerTest
Test: ConnectivityServiceTest
Test: OffloadControllerTest
Test: NetworkStatsObserversTest
Test: NetworkStatsServiceTest
(all the touched classes)

Change-Id: Ic47cbe7ba0e407145fa6bc49bb2adb3c5937dbc4

Chalard Jean   commited 2019-05-28 22:20:51 +09:00
d5cae6a6e4
Merge "Let the system server have CONNECTIVITY_USE_RESTRICTED_NETWORKS."
Chalard Jean   authored and   Gerrit Code Review   commited 2019-05-28 12:26:10 +00:00
2ada647c37
Let the system server have CONNECTIVITY_USE_RESTRICTED_NETWORKS.
Also :
- Fix testUidFilteringDuringVpnConnectDisconnectAndUidUpdates that
  was failing on devices with a first released SDK >= Q
- Add a test actually tests that the system has the permission, as
  the test was only testing what's in the mock

Bug: 119770201
Test: New test making sure this stays true
Change-Id: I74cf5f0fa17fcf818f1fed78c7e3e4375c20152e

Chalard Jean   commited 2019-05-27 16:35:22 +09:00
030a3c7c37
Clean up for multiple validation result update
This is a follow-up commit for aosp/955431 to update commets
and minor updates in unit test.

Test: atest com.android.server.ConnectivityServiceTest#testCaptivePortalOnPartialConnectivity
Bug: 130683832
Change-Id: I581eae8daeddd2c4c186e7b40e27fef2aaa7ab43

Chiachang Wang   commited 2019-05-24 03:29:56 +00:00
59d7d2957f
Merge "Update multiple validation result to ConnectivityService"
Chiachang Wang   authored and   Gerrit Code Review   commited 2019-05-24 02:50:54 +00:00
7eff27b409
[CM] Fix NPE due to unvalidated callback value
Fix flaky test resulting from the above fix.

Bug: 132950880
Test: atest ConnectivityServiceTest
Change-Id: I1ddf3bb016239bf88cdd8843a71dcb5e582e83ac

Etan Cohen   commited 2019-05-23 08:16:20 -07:00
bcf0006ff7
Update multiple validation result to ConnectivityService
Once a network is determined to have partial connectivity, it
cannot go back to full connectivity without a disconnect. This
is because NetworkMonitor can only communicate either
PARTIAL_CONNECTIVITY or VALID, but not both. Thus, multiple
validation results allow ConnectivityService to know the real
network status.

Bug: 129662877
Bug: 130683832
Test: atest FrameworksNetTests
Test: atest NetworkStackTests
Test: atest --generate-new-metrics 50
NetworkStackTests:com.android.server.connectivity.NetworkMonitorTest
Test: Simulate partial connectvitiy
Change-Id: I406c9368617c03a2dd3ab15fb1f6dbf539d7c714

Chiachang Wang   commited 2019-05-23 16:29:30 +08:00
9cfa6fe703
[CM] Fix NPE due to unvalidated callback value
When unregistering callback due to ON_UNAVAILABLE did not check for
a non-null callback.

Bug: 132950880
Test: atest ConnectivityServiceTest
Change-Id: I8f3322963f322e6690f1403681bf66e8b38b35f8

Etan Cohen   commited 2019-05-22 04:56:09 +00:00
bc3a4eb54c
Merge "Clean up the permission control code in framework"
Treehugger Robot   authored and   Gerrit Code Review   commited 2019-05-13 18:04:50 +00:00
2ecbe8b8b1
Merge "Support strict mode private DNS on VPNs that provide Internet."
Chalard Jean   authored and   Gerrit Code Review   commited 2019-05-10 09:39:17 +00:00
faf2bd1a23
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

Lorenzo Colitti   commited 2019-05-10 14:30:54 +09:00
ac456b2f36
Merge changes Ibff278a6,If6d537a3
* changes:
  Revert "Add NATT keepalive resources and methods into IpSecService"
  Revert "[KA11] Verify fd ownership and allocate resource for NattKeepalive"

Treehugger Robot   authored and   Gerrit Code Review   commited 2019-05-10 01:42:26 +00:00
6eaf680338
Revert "Add NATT keepalive resources and methods into IpSecService"
This reverts commit cece56e3ce.

Reason for revert: Adds dependency between IpSecService and
                   ConnectivityService may lead to future deadlock
		   problems. Uses a simpler approach instead,
		   hence the solution is not needed.
		   See aosp/954040.

Change-Id: Ibff278a6eee666cd85dba81c2bed94d568679b02

Junyu Lai   authored and   junyulai   commited 2019-05-10 00:58:18 +08:00
23409e34b4
Merge "adopt non-blocking method to obtain the IpMemoryStore service."
Xiao Ma   authored and   Gerrit Code Review   commited 2019-05-09 11:30:56 +00:00
6c6c6272dd
[CS] Unregister callback as part of onUnavailable dispatch
The onUnavailable semantics promise that it is equivalent to calling
the unregister callback method. But - it doesn't unregister the callback
allowing it to be reused. Fixed.

Additionally, modified the unregisterNetworkCallback method to not fail
on duplicate unregistration (since a callback could now self
unregister). Instead simply print a log.

Bug: 130651445
Test: atest ConnectivityServiceTest
Change-Id: I4c54b003a733eb0b1e4fd8674ed13081b1bef8e3

Etan Cohen   commited 2019-05-09 02:41:40 +00:00
e0e2ca979c
adopt non-blocking method to obtain the IpMemoryStore service.
Test: atest FrameworksNetTests
Change-Id: I7de4f23370bdf9c9df5e74ed074c794080d93d95

Xiao Ma   commited 2019-05-09 10:39:50 +09:00
24f9431d23
Revert "[KA11] Verify fd ownership and allocate resource for NattKeepalive"
This reverts commit 8368fe9fe0.

Reason for revert: Adds dependency between IpSecService and
                   ConnectivityService may lead to future deadlock
                   problems. Uses a simpler approach instead,
                   hence the solution is not needed.
                   See aosp/954040.

Change-Id: If6d537a39595cf132d3ed81d4eaac6700f5f0ab3

Junyu Lai   authored and   junyulai   commited 2019-05-08 11:44:20 +08:00
5218015ed8
Clean up the permission control code in framework
Delete the unused NetworkManagementService API for set/remove
permissions. Use PERMISSION_NONE to replace NO_PERMISSIONS so the
framework now use the same set of permission constant when communicate
with netd.

Bug: 128944261
Test: PermissionMonitorTest.java

Change-Id: I25224c9576f52d2a0a0bd2182325c7aac7b28eb5

Chenbo Feng   commited 2019-05-07 13:50:25 -07:00
cdd3087296
Merge "Add CTS API coverage for APIs which are used by NetworkStack"
Paul Hu   authored and   Gerrit Code Review   commited 2019-05-02 01:37:26 +00:00
4e78fd70d0
Add CTS API coverage for APIs which are used by NetworkStack
Change-Id: I4f6c34f3bcfa65e60cf73fc1b7cab2d83c32836a
Bug: 129200003
Bug: 129200292
Bug: 129199996
Bug: 129200261
Bug: 129200513
Bug: 129200316
Bug: 129200589
Bug: 129200181
Bug: 129200669
Bug: 129200504
Bug: 129200478
Test: atest FrameworksNetTests
Test: atest CtsNetTestCases: added tests pass

paulhu   commited 2019-04-30 17:26:24 +08:00
19ed8076b4
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

Aaron Huang   authored and   markchien   commited 2019-04-29 19:33:45 +08:00
87cd8a7e34
Merge "Make DNS cache lifecycle management explicit"
Lorenzo Colitti   authored and   Gerrit Code Review   commited 2019-04-26 00:23:22 +00:00
8970adbc8c
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

Rubin Xu   commited 2019-04-23 18:04:14 +01:00
ad26ff3fa1
[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

junyulai   commited 2019-04-23 10:47:19 +08:00
8368fe9fe0
Merge "Fix an argument to the legacy broadcast"
Chalard Jean   authored and   Gerrit Code Review   commited 2019-04-23 00:38:10 +00:00
5036127856
Merge "Add NATT keepalive resources and methods into IpSecService"
Benedict Wong   authored and   Gerrit Code Review   commited 2019-04-22 20:03:54 +00:00
4d31a792fa
Fix an argument to the legacy broadcast
Test: new test for this
Fixes: 62650382
Change-Id: I918b8271d3c3c058553ca888cb54cd36a6efba66

Chalard Jean   commited 2019-04-22 22:26:16 +09:00
24a433a538
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

Luke Huang   commited 2019-04-22 17:43:37 +08:00
135c5261ec
Merge changes Id598ae1d,I475bd011
* changes:
  Fix a possible crash when the listener is null
  Straighten AIDL interface for the memory store

Chalard Jean   authored and   Gerrit Code Review   commited 2019-04-22 02:15:04 +00:00
eefe399495
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

Chalard Jean   commited 2019-04-22 00:40:28 +00:00
2b73c58736
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

Benedict Wong   commited 2019-04-19 11:17:21 -07:00
cece56e3ce
Make LegacyTypeTracker testable
...and add basic trivial tests for it.

Test: this, and ConnectivityServiceTest
Bug: 62650382
Change-Id: Ie7ca938e6f66f1b15feb6ed93afa0aebb20884ae

Chalard Jean   commited 2019-04-19 15:33:44 +09:00
8cc4e876cd
Merge "Backwards-incompatible resolv module API change for making setResolverConfiguration take a parcelable."
Wayne Ma   authored and   Gerrit Code Review   commited 2019-04-17 13:58:11 +00:00
df39b855b5
Backwards-incompatible resolv module API change for making setResolverConfiguration take a parcelable.
Test: built, flashed, booted
      atest FrameworksNetTests

Change-Id: I3b4e8672f5273c3baa9378025bfaef2e6514df64

waynema   authored and   Wayne Ma   commited 2019-04-17 13:55:53 +00:00
4152690a6e
Merge "Release keepalive slot after stopped"
Junyu Lai   authored and   Gerrit Code Review   commited 2019-04-16 04:46:18 +00:00
5adfab71bc
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

junyulai   commited 2019-04-15 17:44:48 +08:00
37033fd067
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

Lorenzo Colitti   commited 2019-04-12 19:52:45 +09:00
c18f4b5f6f
Revert "Revert "Block incoming non-VPN packets to apps under fully-routed VPN""
This reverts commit 2b6cd177ba.

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

Bug: 114231106
Bug: 130397860
Test: FrameworksNetTests
Change-Id: Ia8a0c99b4e1fd5dff26c881715cd876618ca4321

Lorenzo Colitti   commited 2019-04-12 19:52:32 +09:00
ee6a630257
Revert "Block incoming non-VPN packets to apps under fully-routed VPN"
This reverts commit 1c19cf383f.
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

Remi NGUYEN VAN   commited 2019-04-12 09:05:40 +00:00
2b6cd177ba
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

Rubin Xu   commited 2019-04-10 17:05:54 +01:00
1c19cf383f
Merge "Fix remove-before-add for IpSecService RefcountedResource"
Benedict Wong   authored and   Gerrit Code Review   commited 2019-04-09 17:22:56 +00:00
3a9e68d173
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

Benedict Wong   commited 2019-04-08 18:51:50 -07:00
4dba79cc89
Merge "Move NetworkStatsFactory into service directory"
Treehugger Robot   authored and   Gerrit Code Review   commited 2019-04-05 19:27:22 +00:00
d82ae27bca
Merge "Fix flaky UdpEncapsulationSocket test"
Lorenzo Colitti   authored and   Gerrit Code Review   commited 2019-04-04 08:09:06 +00:00
e807af1b0a