Commit Graph

1807 Commits

Author SHA1 Message Date
Benedict Wong
a3da62f5a1 Remove unused lastStats parameter
This change removes an unused parameter that is always null in
getNetworkStatsUidDetail

Bug: 113122541
Bug: 134244752
Test: FrameworksNetTest passing
Merged-In: I995b108ef30e1fbd6190131ed4db40a3d9327eb5
Change-Id: I575a7e4fa145f2c93537f33a2bfe952aeafd0e69
(cherry picked from commit 5823e8d3c69b10ad2a458e491c146631457ca86d)
2019-06-21 01:12:10 +00:00
Benedict Wong
2cca1ef390 Revert "Revert "Take all VPN underlying networks into account when migrating traffic for""
This reverts commit d8220c20507f0c346f517d715c7b9826b04d64e2.

Reason for revert: Fix available for deadlocks.

Bug: 113122541
Bug: 134244752
Merged-In: Ib65214598837289bd39dbf040b56ab7835f893ba
Change-Id: Ia90bf2c72ef686e80800d113d03548e0efcadb66
(cherry picked from commit a84d9fa57247cf78a9297b0c6dbd3d81b69e235f)
2019-06-21 01:09:49 +00:00
Benedict Wong
720bf37264 Merge "Inline readNetworkStatsDetailInternal, make mUseBpfStats final" am: b8f3f2446e am: df3deaf33d
am: bdcf776874

Change-Id: I9125dc1aa39189a43b3c68618853e0a7a7298fe2
2019-06-20 14:23:25 -07:00
Benedict Wong
bdcf776874 Merge "Inline readNetworkStatsDetailInternal, make mUseBpfStats final" am: b8f3f2446e
am: df3deaf33d

Change-Id: I8fc5e96150bc30ae87881feb5730be2fbb5891ac
2019-06-20 14:11:17 -07:00
Chalard Jean
dc168b63fb Merge "Factorize custom asserts." am: 6c176efa3d am: 99fbb40990
am: b4dd87625b

Change-Id: I8774ea64f004999ddb46223a76a671388687d455
2019-06-20 14:06:58 -07:00
Chalard Jean
b4dd87625b Merge "Factorize custom asserts." am: 6c176efa3d
am: 99fbb40990

Change-Id: I65ea7497abb8b77ebd10ba622075ef3b6c49b2a8
2019-06-20 14:01:31 -07:00
Benedict Wong
b8f3f2446e Merge "Inline readNetworkStatsDetailInternal, make mUseBpfStats final" 2019-06-20 20:25:31 +00:00
Benedict Wong
d749767f44 Inline readNetworkStatsDetailInternal, make mUseBpfStats final
This change inlines the logic from readNetworkStatsDetailInternal, and
reduces reundant checks in mUseBpfStats

Bug: 113122541
Test: atest FrameworksNetTests run, passing
Change-Id: If2ef8d8f038f32c8cf974aa02cfc1dc7e44dbad3
2019-06-20 20:23:17 +00:00
Chalard Jean
812ffea029 Factorize custom asserts.
Also a few utilities that were in the way, and some opportunistic
cleanups.

Test: FrameworksNetTest NetworkStackTest
Change-Id: I385070e2044fd967cb18f1ffea9a86a4627b742e
2019-06-20 16:24:25 +09:00
Varun Anand
82c57bcb79 Merge changes Ieb8645ac,I6466ec14,I87deb82b,I995b108e,Ib6521459 am: f4c10e8bc2 am: 48f59a0fdf
am: a87d30ba9a

Change-Id: I16884eef6e2b8d64031363cfb4adacc4a0a9ead7
2019-06-17 10:43:22 -07:00
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
8249d4ac1e [automerger skipped] Merge changes from topic "vpn_data_accnt_revert" am: 8af90ce15b am: 39f9c1c212 -s ours
am: d7ca6e7dc7 -s ours
am skip reason: change_id Ibdaad3a4cbf0d8ef1ed53cfab1e454b9b878bae9 with SHA1 612ac19261 is in history

Change-Id: I48f805c08d46e03a837173f59f411506c9748951
2019-06-11 19:11:23 -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
Android Build Merger (Role)
102c6a2a35 Merge changes from topic "am-9a435ce648dc47d49fc32dc2680fa5b7" into qt-r1-dev-plus-aosp
* changes:
  Revert "Take all VPN underlying networks into account when migrating traffic for" am: 612ac19261 am: 3e9726c69c
  Revert "NetworkStatsService: Fix getDetailedUidStats to take VPNs into account." am: 75fc9e4e15 am: 9b8282b7ba
  Revert "Addressing comments for http://ag/7700679." am: bebb34732d am: 25f881d116
  Revert "Add one more test for VPN usage stats." am: 54a08a686d am: 469ee82902
2019-06-07 09:44:50 +00:00
Benedict Wong
392e82a09d Revert "Take all VPN underlying networks into account when migrating traffic for" am: 612ac19261
am: 3e9726c69c

Change-Id: Ia6598f3550d1dcdd42e04f846ac6cfcce18ce7c1
2019-06-07 02:43:37 -07:00
Benedict Wong
8eb19b9ead Revert "NetworkStatsService: Fix getDetailedUidStats to take VPNs into account." am: 75fc9e4e15
am: 9b8282b7ba

Change-Id: I799bbaed92dfce20690ae5a8b59241d22e5dc6d6
2019-06-07 02:43:33 -07:00
Benedict Wong
f886ba8635 Revert "Addressing comments for http://ag/7700679." am: bebb34732d
am: 25f881d116

Change-Id: Ib986a6e4bf6f9a66722c612fcae6f79c1cce91b6
2019-06-07 02:43:29 -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