Commit Graph

884 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
Xiao Ma
98aa76e2e8 Merge "Add DHCP address lease expiry in IpMemoryStore." 2019-04-01 12:59:20 +00:00
paulhu
1a40765101 Address leftover comments on 923337 and 930217.
- Restrict unprivileged apps to use
  NetworkRequest.Builder#setSignalStrength.

- Remove the "throws NullPointerException" in
  CaptivePortalProbeSpec constructor.

- Remove the null check in LinkProperties.

- Add annotataion into all ConnectivityManager.NetworkCallback
  methods.

Change-Id: Id275cac1d6a30d7515cd7b113394f5e8a0179314
Fix: 129097486
Test: atest FrameworksNetTests
2019-04-01 16:24:10 +08:00
Remi NGUYEN VAN
c8f93bca44 Merge "Fix race when starting NetworkMonitor" am: ef8485cc65 am: ea71c49a0e
am: 3a8102ab8e

Change-Id: I595ecdbf0b8e91fec4287c3476239a1e6c9c80a7
2019-03-31 21:35:25 -07:00
Remi NGUYEN VAN
ef8485cc65 Merge "Fix race when starting NetworkMonitor" 2019-04-01 03:54:03 +00:00
Remi NGUYEN VAN
ca33d197d9 Fix race when starting NetworkMonitor
NetworkMonitor obtained LinkProperties and NetworkCapabilities via
synchronous calls to ConnectivityManager after receiving an asynchronous
notification, which is prone to races: the network could be gone before
the LinkProperties/NetworkCapabilities can be fetched.

Fix the race by passing LinkProperties/NetworkCapabilities directly to
NetworkMonitor in the asynchronous notifications.

Test: atest FrameworksNetTests NetworkStackTests
Test: booted, WiFi works
Bug: 129375892
Change-Id: I200ac7ca6ff79590b11c9be705f650c92fd3cb63
2019-04-01 11:33:10 +09:00
Luke Huang
bd2a4be755 Merge "Use IDnsResolver instead of INetd for resolver related binder commands" am: efa4301a7f am: 8ef15888a5
am: 068f305fc7

Change-Id: I2d642b71df25934fddd8a1476b5d27457628b8e2
2019-03-29 02:24:24 -07:00
Luke Huang
efa4301a7f Merge "Use IDnsResolver instead of INetd for resolver related binder commands" 2019-03-29 08:45:19 +00: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
Junyu Lai
bf7917290e Merge changes I0baf582f,I4bba01ba am: 6d7c97dc5c am: a0540419f9
am: 7fd6b91b04

Change-Id: I2cc021899270b41e4b9047ef32869af53ea6fb65
2019-03-27 18:43:18 -07:00
Junyu Lai
6d7c97dc5c Merge changes I0baf582f,I4bba01ba
* changes:
  Block unpriviledged apps which create keepalives with null fd
  Fix keepalive don't get removed when lower layer error
2019-03-28 00:53:20 +00:00
junyulai
828dad188c Block unpriviledged apps which create keepalives with null fd
Currently, socketKeepalive implementation is accepting null fd
due to backward compatibility with legacy packet keepalive API.
However, due to lack of the fd, the service cannot guarantee the
port is not reused by another app if the caller release the port
for any reason.

Thus, grant the null fd access only for priviledged apps.

This commit also address some comments from aosp/918533.

Bug: 126699232
Test: atest FrameworksNetTests
Change-Id: I0baf582ff4ca8af6082c3754e8dfbcd867f39792
2019-03-27 19:51:08 +08:00
Luke Huang
8141319b4d Use IDnsResolver instead of INetd for resolver related binder commands
migrate resolver related commands from INetd to IDnsResolver

Bug: 126141549
Test: atest FrameworksNetTests ConnectivityServiceTest Nat464XlatTest
      atest DnsManagerTest
Change-Id: I559c0c1304d53dde408c062e1a52e742595e7cbe
2019-03-27 17:39:07 +08:00
Lucas Lin
63c0ac9f45 Merge "Fix flaky test for ConnectivityServiceTest#testPartialConnectivity" am: 52feef4450 am: b7977acec0
am: 5ae1bff2bf

Change-Id: I80399f9980119342ba5cd3d4f1922badb1fee3e9
2019-03-26 19:00:50 -07:00
Lucas Lin
52feef4450 Merge "Fix flaky test for ConnectivityServiceTest#testPartialConnectivity" 2019-03-27 01:29:51 +00:00
lucaslin
9df5336349 Fix flaky test for ConnectivityServiceTest#testPartialConnectivity
There are 2 problems will make testPartialConnectivity flaky:
1. If we call setNetworkValid() before expectCapabilitiesWith(),
there may be a timing issue that network will become VALID before
NetworkMonitor send PARTIAL_CONNECTIVITY to ConnectivityService.
Solution:
We should set network to valid after ConnectivityService received
NETWORK_TEST_RESULT_PARTIAL_CONNECTIVITY to ensure NetworkMonitor
will send PARTIAL_CONNECTIVITY to ConnectivityService first then
send VALID.

2. When test case call explicitlySelected(true) first then call
connect(true), NetworkMonitor will report the network validation
test result twice because ConnectivityServiceTest() will trigger
notifyNetworkTested() when setAcceptPartialConnectivity() is
called, it may cause a timing that before the second test result
send to ConnectivityService, connect() already called
setNetworkInvalid. So, NET_CAPABILITY_VALIDATED will be removed
and ConnectivityService will trigger onCapabilitiesChanged()
unexpectedly.
Solution:
Don't trigger notifyNetworkTested() when
setAcceptPartialConnectivity() is called. If there is needed,
use mCm.reportNetworkConnectivity() to report the test result
instead.

Bug: 128426024
Test: 1. atest FrameworksNetTests: \
      ConnectivityServiceTest#testPartialConnectivity \
      --generate-new-metrics 1000

Change-Id: I7200528378201a3c7c09a78ff827b41f2741dfa1
2019-03-26 17:49:49 +08:00
Junyu Lai
b8368cc806 Merge "Reveal the call trace of failed test cases which run in executors" am: 67cfb00800 am: ff5f8defa6
am: e674483e9f

Change-Id: I023c8140c94966479db7f12647838699324462af
2019-03-26 00:13:47 -07:00
Junyu Lai
67cfb00800 Merge "Reveal the call trace of failed test cases which run in executors" 2019-03-26 06:38:39 +00: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
Mark Chien
13cc9e442e Merge "[TCPKeepalive] Fill correct TOS and TTL value" 2019-03-25 13:10:17 +00:00
junyulai
c3106feee7 Reveal the call trace of failed test cases which run in executors
Currently, the fails in testTcpSocketKeepalives are triggered by
fail() inside the executor, which is hiding the actual call trace
but only message remains. And it made the fail case hard to
debug.

So this commit is to bubble up the Exception by using a custom
functional interface.

Bug: 123987272
Test: 1. atest FrameworksNetTests
      2. manually fail the test case and see the call trace

Change-Id: I125e673938a5e9d1de86f83c1a732227a4bd3207
2019-03-25 12:56:47 +00:00
Junyu Lai
40ad433f92 Merge "Fix SocketKeepalive APIs which do not meet API review requirement" am: 66bc22760a am: 7246f1a563
am: 0f69af35db

Change-Id: I873a82de90efce6f3baa17761c0576dc9c8210be
2019-03-25 04:16:18 -07:00
junyulai
7e06ad4ce9 Fix SocketKeepalive APIs which do not meet API review requirement
Per API review, change the use of FileDescriptor to
ParcelFileDescriptor.
This change also fix nullability according to API review
feedbacks.

Fix: 126698610
Fix: 126699425
Fix: 126699232
Fix: 126700278

Test: 1. m -j
      2. atest FrameworksNetTests --generate-new-metrics 50
      3. m -j doc-comment-check-docs
Change-Id: I19476c50dd1ca290bf3f41973829da2bd229796a
2019-03-25 15:56:35 +08: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
lucaslin
ea54b7ef6b Merge "Temporarily disable flaky test." am: a7f5cf3adb am: d7a9e6da54
am: 70cb4b5281

Change-Id: I583ed9aa0e42e864ef0c1e74fbcd9357e093cc25
2019-03-21 08:39:31 -07:00
Treehugger Robot
a7f5cf3adb Merge "Temporarily disable flaky test." 2019-03-21 15:04:15 +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