Commit Graph

1839 Commits

Author SHA1 Message Date
android-build-team Robot
165a9995b6 Snap for 5697374 from ec016d73a48853236459e630da96d097bd1c1c91 to rvc-release
Change-Id: Ib54f7dadc74ce5b9c81e03bff883059b76deb655
2019-06-29 03:05:50 +00:00
Lorenzo Colitti
10db7f01f6 Merge "Remove all static members from NetworkStatsFactory." am: 63f94f411b am: 5409264cee am: 05f0587ca2
am: 0f3466c1a4

Change-Id: I83c93bb4fbd0302fe31c38a1dcbf6691d0043be3
2019-06-27 20:14:02 -07:00
android-build-team Robot
e58256824f Snap for 5694677 from 97af579aca5406205b84dbe8bda9b1ba33ba9ac0 to rvc-release
Change-Id: I7d734f935d8c4c4978067b6a88ea83a3585d3981
2019-06-28 03:04:01 +00:00
Lorenzo Colitti
0f3466c1a4 Merge "Remove all static members from NetworkStatsFactory." am: 63f94f411b am: 5409264cee
am: 05f0587ca2

Change-Id: I7f787d14b7c7dee7a77dbed84266f8192c21c446
2019-06-27 19:56:01 -07:00
Lorenzo Colitti
05f0587ca2 Merge "Remove all static members from NetworkStatsFactory." am: 63f94f411b
am: 5409264cee

Change-Id: Iada14a1fea74197014e75a1112c7a5b35d6b1a1d
2019-06-27 19:40:01 -07:00
Lorenzo Colitti
5cdb65627f Merge "Transfer ownership of NetworkStatsFactory to NetworkStatsService." am: bd94f0afd2 am: 92292f556b am: f189d8ee94
am: 468053d2ea

Change-Id: Iebaa91b450f1c43a978e96a15e409423e3ef6bb7
2019-06-27 12:22:55 -07:00
Lorenzo Colitti
ce3cad242c Merge "Synchronize the NetworkStatsFactory constructor." am: f2bd2bbfd8 am: e6193f4086 am: 1bb38318b4
am: 8e0cd114f6

Change-Id: Iee86f191a12207dc203dc0b0a50a74d65decd209
2019-06-27 12:21:04 -07:00
Lorenzo Colitti
468053d2ea Merge "Transfer ownership of NetworkStatsFactory to NetworkStatsService." am: bd94f0afd2 am: 92292f556b
am: f189d8ee94

Change-Id: Ibe2fcacb3779b3c6bc484fe6f398475bf5b6383b
2019-06-27 09:26:02 -07:00
Lorenzo Colitti
8e0cd114f6 Merge "Synchronize the NetworkStatsFactory constructor." am: f2bd2bbfd8 am: e6193f4086
am: 1bb38318b4

Change-Id: Ia0112e4307c055d7fe63f0c798588c94eba3df49
2019-06-27 09:24:23 -07:00
Lorenzo Colitti
bcaf1f959b Remove all static members from NetworkStatsFactory.
NetworkStatsFactory is owned by NetworkStatsService, and any
accesses to NSF data should go through NSS.

Test: atest FrameworksNetTests
Change-Id: Idbd0dbbaeb11313f63474e7ec0e01f974349fc89
2019-06-27 17:39:05 +09:00
Lorenzo Colitti
f189d8ee94 Merge "Transfer ownership of NetworkStatsFactory to NetworkStatsService." am: bd94f0afd2
am: 92292f556b

Change-Id: If897c9c95fc8571949183c45a99a5c28cb032ebb
2019-06-27 01:31:46 -07:00
Lorenzo Colitti
1bb38318b4 Merge "Synchronize the NetworkStatsFactory constructor." am: f2bd2bbfd8
am: e6193f4086

Change-Id: I521cd368a611bedaf9e6e5af4b8d71c040b502ac
2019-06-27 01:23:07 -07:00
Lorenzo Colitti
8b6fdeca3f Transfer ownership of NetworkStatsFactory to NetworkStatsService.
NetworkStatsService is the only consumer of the data coming from
NetworkStatsFactory, but the factory itself is instantiated and
owned by NetworkManagementService.

Move it into NetworkStatsService instead.

Test: atest FrameworksNetTests
Change-Id: I52df1e545c646927952579da22845a12d1d7563b
2019-06-26 19:29:51 +09:00
android-build-team Robot
8bd34567a5 Snap for 5685955 from b305f4fcd562d27f4eba6cb44784f9b21ae2971e to rvc-release
Change-Id: I2c087a627209d538eff936ab0e5f2dbbe4c6bb93
2019-06-25 11:58:53 +00:00
Lorenzo Colitti
4bbc0d2449 Merge "NetworkStats: Fix race condition causing system server crashes" am: 08b928e8ed am: f37da9a879 am: c993c0c45f
am: f126a7e923

Change-Id: Ia4adc58a4c8baef92e204bedd914b5e041e071a6
2019-06-25 03:31:52 -07:00
Lorenzo Colitti
ebfdc7c4e7 Synchronize the NetworkStatsFactory constructor.
This ensures the constructor takes the necessary lock before
accessing memmber variables.

Bug: 113122541
Test: atest FrameworksNetTests
Change-Id: Ibd324ed922c738b8d77d4eb74f45b75c6645bdc7
2019-06-25 18:58:42 +09:00
Lorenzo Colitti
f126a7e923 Merge "NetworkStats: Fix race condition causing system server crashes" am: 08b928e8ed am: f37da9a879
am: c993c0c45f

Change-Id: Ieb9f17b6e3eed82c450a5b90dd67a00e4ede8b3f
2019-06-25 02:21:15 -07:00
Lorenzo Colitti
c993c0c45f Merge "NetworkStats: Fix race condition causing system server crashes" am: 08b928e8ed
am: f37da9a879

Change-Id: I0ab308d5215ddb174ffb115e36948685d68da3ec
2019-06-25 01:53:11 -07:00
Hugo Benichi
0308b3971d NetworkStats: Fix race condition causing system server crashes
NetworkStatsService uses an internal boolean to know when it has
started for the purpose of preventing access to other internal
variables before they are initialized.

However that boolean is set to true in systemReady() non-atomically
with respect to the initialization of the other variables it guards,
which can cause the system server to crash.

This patch fixes this concurrency bug by moving setting the internal
boolean flag and the variable it guards in one atomic synchronized
block.

This patch also removes code checking if bandwidth control is enabled,
because this is now always true.

Bug: 132767673
Test: Compiled.
Change-Id: Ia089b5767ce271d669879c975508654d4dd03429
2019-06-25 10:51:51 +09:00
Lorenzo Colitti
3233bc2613 [automerger skipped] Merge changes If7d41052,I66f263d7,Id45ae956,Iba752fed,I575a7e4f, ... into qt-r1-dev am: f80234a9b0 -s ours
am: 85c6ebcce9 -s ours
am skip reason: change_id If2ef8d8f038f32c8cf974aa02cfc1dc7e44dbad3 with SHA1 d749767f44 is in history

Change-Id: I2081b6633b1d0f61bff7531a082e0b6856c23b5b
2019-06-24 09:09:35 -07:00
Lorenzo Colitti
85c6ebcce9 [automerger skipped] Merge changes If7d41052,I66f263d7,Id45ae956,Iba752fed,I575a7e4f, ... into qt-r1-dev
am: f80234a9b0 -s ours
am skip reason: change_id If2ef8d8f038f32c8cf974aa02cfc1dc7e44dbad3 with SHA1 d749767f44 is in history

Change-Id: I5b525feb1e7df2a89dea4f38b521973ccaac0746
2019-06-24 08:17:26 -07:00
android-build-team Robot
d901d36bae Snap for 5676985 from eeea914eef490e0fbf3eaa878b725bd5a027b780 to rvc-release
Change-Id: I493cde6332d8cdd70422f90f2fc3b682e540b99e
2019-06-21 03:16:17 +00:00
Benedict Wong
0768aa7770 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
Merged-In: If2ef8d8f038f32c8cf974aa02cfc1dc7e44dbad3
Change-Id: If7d41052115ed145da8a610d676f6ed33c8d5e63
(cherry picked from commit 8c9d8c5e05cd35a340c4224c61f7fa9e95b5c861)
2019-06-21 01:12:41 +00:00
Benedict Wong
4d326f96cc 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.
Merged-In: Ieb8645acc400fdaeb0df7092c5369b96f9f35af9
Change-Id: I66f263d7e12bce7668901306c0c2ecdda634abaf
(cherry picked from commit 833603caabb1a850a63a970fc285b4c8ed7401f8)
2019-06-21 01:12:34 +00:00
Benedict Wong
dedb6bb0e5 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.
Merged-In: I6466ec1411fc5ed6954125d27d353b6cd1be719e
Change-Id: Id45ae956ad7165be346ecc010e17d260563ac1c0
(cherry picked from commit 9fbbdebc61513982a6775460e1d400956f803bde)
2019-06-21 01:12:27 +00:00
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
20b7556bcf Merge "Inline readNetworkStatsDetailInternal, make mUseBpfStats final" am: b8f3f2446e am: df3deaf33d am: bdcf776874
am: 720bf37264

Change-Id: I5ddc834a7c50ae260704ce9d53c954cfb55bec7b
2019-06-20 14:46:35 -07:00
Chalard Jean
5baf78c082 Merge "Factorize custom asserts." am: 6c176efa3d am: 99fbb40990 am: b4dd87625b
am: dc168b63fb

Change-Id: I1eecc5dd9f8c77287b8cca76f5d647a23a9a2f7a
2019-06-20 14:29:43 -07: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
android-build-team Robot
4de8ea83e3 Snap for 5667442 from 8f182abb7cc06317884ea435fa5526b433ab6eb7 to rvc-release
Change-Id: I3c52e765a40b9b298f96d8f71db7fde30eacd400
2019-06-18 03:03:47 +00:00
Varun Anand
1c608de218 Merge changes Ieb8645ac,I6466ec14,I87deb82b,I995b108e,Ib6521459 am: f4c10e8bc2 am: 48f59a0fdf am: a87d30ba9a
am: 82c57bcb79

Change-Id: I8415a7c91158cce99e91e6054ed4f40e44563b89
2019-06-17 10:59:29 -07: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
android-build-team Robot
ea499b5770 Snap for 5656242 from 7a031ae8f42480f9d3cd2f4b9faf8c1260abdee3 to rvc-release
Change-Id: Ib94207b77f2bcc623d90978ecce6cff7d1d04413
2019-06-13 03:13:16 +00:00
Varun Anand
d1eed13f49 [automerger skipped] Merge changes from topic "vpn_data_accnt_revert" am: 8af90ce15b am: 39f9c1c212 -s ours am: d7ca6e7dc7 -s ours
am: 8249d4ac1e -s ours
am skip reason: change_id Ibdaad3a4cbf0d8ef1ed53cfab1e454b9b878bae9 with SHA1 612ac19261 is in history

Change-Id: I476f1bf69f0cceaeadbe6dbdd93b5dfa096e955a
2019-06-11 19:22:30 -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