Commit Graph

1742 Commits

Author SHA1 Message Date
Varun Anand
a87d30ba9a Merge changes Ieb8645ac,I6466ec14,I87deb82b,I995b108e,Ib6521459 am: f4c10e8bc2
am: 48f59a0fdf

Change-Id: I960e94b03b29282ae2b03f78a19ed2692bd88e05
2019-06-17 10:33:53 -07:00
Benedict Wong
13162aefb1 Remove VPN info arrays from NetworkStats(Observer|Recorder)
This change removes the now-unused VPN arrays in the network stats
observer and recorder classes. These are always null values in every
call site.

Bug: 113122541
Bug: 120145746
Bug: 129264869
Bug: 134244752
Test: FrameworksNetTest passing
Test: Manual tests show data usage fixes maintained.
Change-Id: Ieb8645acc400fdaeb0df7092c5369b96f9f35af9
2019-06-14 11:41:31 -07:00
Benedict Wong
44f698e1c7 NetworkStatsFactory: Take VPNs into account for network/battery stats
This change fixes detailed UID stats to ensure network and battery stats
both take VPNs into account. NetworkStatsFactory is being made aware of
VPNs enabled, and the full set of underlying networks present.

Since traffic can only be migrated over a NetworkStats delta, NSF
maintains a NetworkStats snapshot across all UIDs/ifaces/tags.

This snapshot gets updated whenever NSF records a new snapshot
(based on various hooks such as VPN updating its underlying networks,
network getting lost, etc.), or NetworkStatsService's
getDetailedUidStats() method being called.

This change widens the scope of the existing mPersistentSnapshot lock,
renaming it to mPersistentDataLock, and ensures that TUN migrations are
not done in parallel. Additionally, mVpnInfos is updated via
pointer-swapping, to reduce the scope of the mPersistentDataLock.

The safety of this change is predicated on:
1. NetworkStatsFactory lock not held, so services cannot deadlock through
the cyclical lock.

2. The broadening of the scope of the lock in NetworkStatsFactory has no
threading implications, as it is always the last (leaf node) lock held,
and therefore is impossible to have lock inversion.

Additionally, to ensure VPNs work with 464xlat, the VPN info passed to
the NetworkStatsFactory includes all underlying interfaces, instead of
only passing the first one.

This (partially) re-applies changes from:
aosp/972848: Add one more test for VPN usage stats.
aosp/972847: Addressing comments for http://ag/7700679.
aosp/885338: NetworkStatsService: Fix getDetailedUidStats to take VPNs
             into account.
Co-developed with: Varun Anand <vaanand@google.com>

Bug: 113122541
Bug: 120145746
Bug: 129264869
Bug: 134244752
Test: FrameworksNetTest passing
Test: Manual tests show data usage fixes maintained.
Change-Id: I6466ec1411fc5ed6954125d27d353b6cd1be719e
2019-06-14 11:41:31 -07:00
Benedict Wong
9491d3a253 Remove unused lastStats parameter
This change removes an unused parameter that is always null in
getNetworkStatsUidDetail

Bug: 134244752
Test: FrameworksNetTest passing
Change-Id: I995b108ef30e1fbd6190131ed4db40a3d9327eb5
2019-06-13 15:36:36 -07:00
Benedict Wong
9b2ad58eae Revert "Revert "Take all VPN underlying networks into account when migrating traffic for""
This reverts commit b8e4b5bbbd.

Reason for revert: Fix available for deadlocks.

Bug: 134244752
Change-Id: Ib65214598837289bd39dbf040b56ab7835f893ba
2019-06-13 15:36:27 -07:00
Varun Anand
d7ca6e7dc7 [automerger skipped] Merge changes from topic "vpn_data_accnt_revert" am: 8af90ce15b
am: 39f9c1c212 -s ours
am skip reason: change_id Ibdaad3a4cbf0d8ef1ed53cfab1e454b9b878bae9 with SHA1 612ac19261 is in history

Change-Id: I47d22d76e3525efc7771e6b514ebadc9b2c75e22
2019-06-11 19:03:04 -07:00
Varun Anand
b8e4b5bbbd Revert "Take all VPN underlying networks into account when migrating traffic for"
This reverts commit c8dbdf35de.

Reason for revert: This change has been implicated in 4-way deadlocks as seen in b/134244752.

Bug: 134244752
Change-Id: I2f1839d7776a613ca571af8a542755ddc5fc8760
Merged-In: Ibdaad3a4cbf0d8ef1ed53cfab1e454b9b878bae9
2019-06-10 16:00:48 -07:00
Varun Anand
52ce558fef Revert "NetworkStatsService: Fix getDetailedUidStats to take VPNs into account."
This reverts commit 720133f79d.

Reason for revert: This change has been implicated in 4-way deadlocks as seen in b/134244752.

Bug: 134244752
Change-Id: I37f75c2b243ea548a88ef1dae88287405c6ef55f
Merged-In: I0c00e8f0e30cee987b71b561079a97bf09d4dae4
2019-06-10 16:00:38 -07:00
Varun Anand
2099b09982 Revert "Addressing comments for http://ag/7700679."
This reverts commit 6018f64055.

Reason for revert: This change has been implicated in 4-way deadlocks as seen in b/134244752.

Bug: 134244752
Change-Id: I12ab724e2ef8a5c1b42078330ba74713ff86fdd1
Merged-In: I5fbb3443a39a21fc9d96442726cd10d20e8d61cd
2019-06-10 16:00:28 -07:00
Benedict Wong
1951779616 Revert "Take all VPN underlying networks into account when migrating traffic for"
am: 612ac19261

Change-Id: Ie9e830962e702c5e66faa7239e6c5037ed3d791d
2019-06-07 02:33:33 -07:00
Benedict Wong
a2e0879840 Revert "NetworkStatsService: Fix getDetailedUidStats to take VPNs into account."
am: 75fc9e4e15

Change-Id: I9bf180aca56a8b5e2c5262beabac3ceaa9b00315
2019-06-07 02:33:30 -07:00
Benedict Wong
251f7ac812 Revert "Addressing comments for http://ag/7700679."
am: bebb34732d

Change-Id: I56e7736ced431a5dcd78a6a258abfad09745d25e
2019-06-07 02:33:26 -07:00
Benedict Wong
612ac19261 Revert "Take all VPN underlying networks into account when migrating traffic for"
This reverts commit 921b3f3e85.

Reason for revert: This change has been implicated in 4-way deadlocks as seen in b/134244752.

Bug: 134244752
Change-Id: Ibdaad3a4cbf0d8ef1ed53cfab1e454b9b878bae9
2019-06-07 09:18:01 +00:00
Benedict Wong
75fc9e4e15 Revert "NetworkStatsService: Fix getDetailedUidStats to take VPNs into account."
This reverts commit 8481d9d55d.

Reason for revert: This change has been implicated in 4-way deadlocks as seen in b/134244752.

Bug: 134244752
Change-Id: I0c00e8f0e30cee987b71b561079a97bf09d4dae4
2019-06-07 09:17:47 +00:00
Benedict Wong
bebb34732d Revert "Addressing comments for http://ag/7700679."
This reverts commit 81e79803de.

Reason for revert: This change has been implicated in 4-way deadlocks as seen in b/134244752.

Bug: 134244752
Change-Id: I5fbb3443a39a21fc9d96442726cd10d20e8d61cd
2019-06-07 09:17:31 +00:00
Varun Anand
1364e6a06c [automerger skipped] Merge changes from topic "vpn_data_accn_tests" am: b50e778fa7
am: 9561790069 -s ours
am skip reason: change_id Iffd3f95fc2e11d311691a797b010edb38d2ef3c6 with SHA1 1419b0b20e is in history

Change-Id: I86c99de74590e3ad54055a16b5c349b6ba3659ab
2019-05-30 13:26:09 -07:00
Varun Anand
6018f64055 Addressing comments for http://ag/7700679.
(cherry picked from commit 81e79803de)

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
2019-05-30 15:59:07 +00:00
chen xu
e23aa86ced [automerger skipped] Merge "NetworkStatAccess Should checkCarrierPrivileges cross all subscriptions" into qt-dev
am: 1824c32a5d -s ours
am skip reason: change_id I49fbde1fe73b33aadcf8fd23ad224f363b137bf3 with SHA1 47090f9dd0 is in history

Change-Id: Icfe0c92b130b7bde5686ec8186d5df0fa16aa126
2019-05-29 18:14:18 -07:00
TreeHugger Robot
1824c32a5d Merge "NetworkStatAccess Should checkCarrierPrivileges cross all subscriptions" into qt-dev 2019-05-30 01:00:44 +00:00
Chen Xu
911e39e070 Merge "NetworkStatAccess Should checkCarrierPrivileges cross all subscriptions" am: 478cbabf8c
am: 4d206af049

Change-Id: Ib2d02bd3936ae112f62861c301d99582e0b998b0
2019-05-29 10:43:06 -07:00
chen xu
3b8356c7ef NetworkStatAccess Should checkCarrierPrivileges cross all subscriptions
Bug: 133236378
Test: Manual
Change-Id: I49fbde1fe73b33aadcf8fd23ad224f363b137bf3
Merged-in: I49fbde1fe73b33aadcf8fd23ad224f363b137bf3
2019-05-29 17:16:54 +00:00
Varun Anand
72f3140992 Merge changes from topic "vpn_data_accounting" into qt-dev
am: b33d2ca2e3

Change-Id: I234eb2b20f47bde94b4aba89867e9d1c7e9ee7d5
2019-05-29 09:44:04 -07:00
Varun Anand
81e79803de Addressing comments for http://ag/7700679.
Note, that its in a separate CL so we could cherry-pick this CL to aosp.
http://ag/7700679 is already in aosp.

Bug: 113122541
Bug: 120145746
Test: atest FrameworksNetTests

Change-Id: I7cfda226b4ed11b67002b83b38fba0f5caf96718
2019-05-29 18:15:34 +09:00
Varun Anand
8481d9d55d NetworkStatsService: Fix getDetailedUidStats to take VPNs into account.
(cherry picked from commit 720133f79d)

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: I4b8d7c5b6905a4a12c1806dfd35c2c4c63610404
2019-05-29 18:15:24 +09:00
Varun Anand
921b3f3e85 Take all VPN underlying networks into account when migrating traffic for
VPN uid.

(cherry picked from commit c8dbdf35de)

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: I7f368c5970b2dcb969fe0daf5ef44edb1f51d09d
2019-05-29 18:15:17 +09:00
chen xu
47090f9dd0 NetworkStatAccess Should checkCarrierPrivileges cross all subscriptions
Bug: 133236378
Test: Manual
Change-Id: I49fbde1fe73b33aadcf8fd23ad224f363b137bf3
2019-05-28 23:28:56 -07:00
Lei Yu
77d71f800f Merge "Use merged NetworkTemplate to query data usage" into qt-dev
am: 35fcd6b0e3

Change-Id: I1030f49eb9e24ad8bc4a10c3ab8890c34d20f8f6
2019-05-14 17:51:03 -07:00
Lei Yu
3c6fb30f24 Use merged NetworkTemplate to query data usage
This CL uses merged NetworkTemplate so that it shows correct
data for carrier which is a virtual that has multiple
subscriberId under the hood.

By doing this, this CL also adds several hidden API so settings
can query by NetworkTemplate directly.

Fixes: 120566366
Test: RunSettingsLibRoboTests
Change-Id: I8b747697933c75b48b14387adafb5ac9ca165926
2019-05-13 11:42:23 -07:00
Junyu Lai
bf5b7628c5 Merge changes Ibff278a6,If6d537a3 am: 33e236823f
am: a865058628

Change-Id: Ic51f3b32375378ff74bdd54d1f36569b277fc80f
2019-05-09 23:30:19 -07:00
Treehugger Robot
33e236823f Merge changes Ibff278a6,If6d537a3
* changes:
  Revert "Add NATT keepalive resources and methods into IpSecService"
  Revert "[KA11] Verify fd ownership and allocate resource for NattKeepalive"
2019-05-10 01:42:26 +00:00
Xin Li
884a1ada47 [automerger skipped] DO NOT MERGE - Merge Pie Bonito/Sargo into master. am: e963030676 -s ours
am: bd1a8961e2 -s ours
am skip reason: subject contains skip directive

Change-Id: I862d40111b2e525e5838bf09e169c8c3f416633b
2019-05-09 17:16:31 -07:00
Junyu Lai
75eabfeb7c Revert "Add NATT keepalive resources and methods into IpSecService"
This reverts commit 4aac3e9e48.

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
2019-05-10 00:58:18 +08:00
Xin Li
e963030676 DO NOT MERGE - Merge Pie Bonito/Sargo into master.
Bug: 131756210
Change-Id: I77a701deda4935526ad452564f9bda77af345f46
2019-05-09 09:27:04 -07:00
Lorenzo Colitti
707fc41210 Merge "Add IPsec checks for IPSEC_TUNNEL feature" into qt-dev
am: 22e0b2c514

Change-Id: I9bd0fa3958c63a148af98abfe7cc6e4301cf01c2
2019-05-08 21:20:19 -07:00
Lorenzo Colitti
22e0b2c514 Merge "Add IPsec checks for IPSEC_TUNNEL feature" into qt-dev 2019-05-09 03:25:35 +00:00
Lorenzo Colitti
d50abfdae5 [automerger skipped] Merge "Add EPROTONOSUPPORT to IpSecManager SSE map" into qt-dev
am: a1a0653dab -s ours
am skip reason: change_id Iec3d5fc4a9bcad7c104414afefae775232d46558 with SHA1 7e9c1ceadd is in history

Change-Id: Ifb346ddf63b0d6547f3c67110c17c630f3aa72c9
2019-05-08 02:37:04 -07:00
Benedict Wong
e9763752c7 Add IPsec checks for IPSEC_TUNNEL feature
This patch adds checks to ensure that the IPSEC_TUNNEL feature flag is
enabled.

Bug: 117183273
Test: Compiles & tests passing
Change-Id: I2699dda29e1eed139bc6fd1b70071e5ab33cad88
2019-05-08 00:11:28 +00:00
Android Build Merger (Role)
5b5a0240a6 Merge changes into qt-dev-plus-aosp 2019-05-07 22:19:43 +00:00
Benedict Wong
c45974b0d6 Add EPROTONOSUPPORT to IpSecManager SSE map
This change maps EPROTONOSUPPORT to the list of error codes that map to
UnsupportedOperationException in IpSecManager.

Bug: 80103456
Test: Compiles, CTS tests ran
Change-Id: Iec3d5fc4a9bcad7c104414afefae775232d46558
Merged-In: Iec3d5fc4a9bcad7c104414afefae775232d46558
(cherry picked from commit dcbc670688d815ce89954765fac46aa2ad6d8adb)
2019-05-07 14:32:17 -07:00
Benedict Wong
7a2cf07c8d Merge "Add EPROTONOSUPPORT to IpSecManager SSE map" am: 7050ce9434
am: 533559234e

Change-Id: I23e0b56529b9df23558002ddb9e6210d711228cf
2019-04-29 14:16:30 -07:00
Benedict Wong
533559234e Merge "Add EPROTONOSUPPORT to IpSecManager SSE map"
am: 7050ce9434

Change-Id: I9ab4161e2b04615ce782c89cd9e99d98cdbdc92d
2019-04-29 13:35:37 -07:00
Benedict Wong
7e9c1ceadd Add EPROTONOSUPPORT to IpSecManager SSE map
This change maps EPROTONOSUPPORT to the list of error codes that map to
UnsupportedOperationException in IpSecManager.

Bug: 80103456
Test: Compiles, CTS tests ran
Change-Id: Iec3d5fc4a9bcad7c104414afefae775232d46558
2019-04-24 21:31:01 +00:00
Chenbo Feng
811f91f337 [automerger skipped] Merge "Ask netd to swap stats map before reading" into qt-dev
am: 197077dc8f -s ours
am skip reason: change_id I8fa37c26bec23ffca0b29b679e72ba1189f557f1 with SHA1 876218abcb is in history

Change-Id: I48dc5783885a97a0b0c975202c5878c058695524
2019-04-23 15:13:56 -07:00
TreeHugger Robot
197077dc8f Merge "Ask netd to swap stats map before reading" into qt-dev 2019-04-23 21:57:09 +00:00
Chenbo Feng
2c8ab195b0 [automerger skipped] Merge "Add a lock to protect persistent stats snapshot" into qt-dev
am: 8e7794e97b -s ours
am skip reason: change_id I73851336452110afb74d6dd1ca5e50047d5b3d4a with SHA1 57f207b1c7 is in history

Change-Id: I30d66ea36a7beee9ccf940c547c47a6f7220e0a2
2019-04-23 12:23:12 -07:00
TreeHugger Robot
8e7794e97b Merge "Add a lock to protect persistent stats snapshot" into qt-dev 2019-04-23 18:19:06 +00:00
Chenbo Feng
10fac71887 Ask netd to swap stats map before reading
To avoid protentail race problem between netd and system_server when
reading the network stats map. Always inform netd before reading the
stats and let netd to do a swap between active stats map and inactive
stats map. So the system_server can safely remove the stats after
reading.

Bug: 126620214
Test: android.app.usage.cts.NetworkUsageStatsTest
      android.net.cts.TrafficStatsTest

Change-Id: I8fa37c26bec23ffca0b29b679e72ba1189f557f1
Merged-In: I8fa37c26bec23ffca0b29b679e72ba1189f557f1
(cherry picked from commit f729cb5fd654a0f099128734f849800fde9ba525)
2019-04-23 14:21:32 +00:00
Chenbo Feng
aeb31b53c6 Add a lock to protect persistent stats snapshot
Since the network stats could be polled from multiple services at
runtime, it is not thread safe for networkStatsFactory to hold a
persistent stats snapshot without any protection. Use a internal lock to
prevent concurrent modification on mPersistentSnapshot to fix the
problem.

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

Change-Id: I73851336452110afb74d6dd1ca5e50047d5b3d4a
Merged-In: I73851336452110afb74d6dd1ca5e50047d5b3d4a
Merged-In: I22afb46f17697e8b6359d4f593802e0f4b95db8b
(cherry picked from commit 25243b4eb93c234412a35f9e5d9f1649f8964f83)
2019-04-23 14:21:05 +00:00
Benedict Wong
5dd6a60745 Merge "Add NATT keepalive resources and methods into IpSecService" am: c345527430
am: 70e5117542

Change-Id: I3affb5bdbb0c3f980b6606d728668e74c31646d0
2019-04-22 13:44:20 -07:00
Benedict Wong
70e5117542 Merge "Add NATT keepalive resources and methods into IpSecService"
am: c345527430

Change-Id: I97e7451959d619f42d68a5c29cca410bf0740852
2019-04-22 13:31:52 -07:00