Commit Graph

1935 Commits

Author SHA1 Message Date
Maciej Zenczykowski
a22218b772 [automerger skipped] Merge "Fix mobile data usage didn't get increased for xlat464 traffic" into qt-dev am: 2c74b2e5d8 -s ours
am: 84f11755d6 -s ours
am skip reason: change_id I8ebbefbe4df00e40f4896a17fa52c8438d41286e with SHA1 96fe3f5ff6 is in history

Change-Id: I9678ef008af3682687fe692cf98bb78e46f09748
2019-07-02 14:07:34 -07:00
Xin Li
084a82cd1a [automerger skipped] Merge "DO NOT MERGE - Merge qt-dev-plus-aosp-without-vendor (5699924) into stage-aosp-master" into stage-aosp-master
am: 3f1f8d1315 -s ours
am skip reason: subject contains skip directive

Change-Id: I1a32cee69d0edcb92d81a4bb8e6f98912d86a735
2019-07-02 12:40:14 -07:00
Maciej Zenczykowski
0741d47a2d [automerger skipped] Merge "Fix mobile data usage didn't get increased for xlat464 traffic" into qt-dev am: 2c74b2e5d8 -s ours
am: e6e7d93808 -s ours
am skip reason: change_id I8ebbefbe4df00e40f4896a17fa52c8438d41286e with SHA1 96fe3f5ff6 is in history

Change-Id: I78ea7922a88791b43eb0c8bc337443f128213c63
2019-07-02 12:34:36 -07:00
Maciej Zenczykowski
e6e7d93808 [automerger skipped] Merge "Fix mobile data usage didn't get increased for xlat464 traffic" into qt-dev
am: 2c74b2e5d8 -s ours
am skip reason: change_id I8ebbefbe4df00e40f4896a17fa52c8438d41286e with SHA1 96fe3f5ff6 is in history

Change-Id: Ia76c06513e23c4052262c8ac4c7212a548267a8c
2019-07-02 12:24:42 -07:00
Maciej Zenczykowski
84f11755d6 [automerger skipped] Merge "Fix mobile data usage didn't get increased for xlat464 traffic" into qt-dev
am: 2c74b2e5d8 -s ours
am skip reason: change_id I8ebbefbe4df00e40f4896a17fa52c8438d41286e with SHA1 e5e15aee20 is in history

Change-Id: If50b9304e64a5d4c18c78d933c121d428d660d61
2019-07-02 12:24:41 -07:00
junyulai
e7424f5646 [automerger skipped] Fix mobile data usage didn't get increased for xlat464 traffic
am: 96fe3f5ff6 -s ours
am skip reason: change_id I8ebbefbe4df00e40f4896a17fa52c8438d41286e with SHA1 e5e15aee20 is in history

Change-Id: I179221edf5fe58a1b4b747bd51f86a569ed051b4
2019-07-02 08:54:31 -07:00
junyulai
9bf1e821f5 Fix mobile data usage didn't get increased for xlat464 traffic
Interface stats on stacked interfaces is usually clatd. For
xt_qtaguid supported device, the stats is already accounted
against its final egress interface by the kernel.
Framework side does not need to handle stats on statcked
interface at all.

However, on devices that support BPF offload, xlat464
packets are seen by the iptables rules as arriving on stack
interface only. Thus, add stack interface into accounting is
needed.

Bug: 136193260
Test: 1. atest FrameworksNetTests
      2. atest android.app.usage.cts.NetworkUsageStatsTest
      3. manual test on ipv6-only wifi network

Merged-In: I8ebbefbe4df00e40f4896a17fa52c8438d41286e
Change-Id: I8ebbefbe4df00e40f4896a17fa52c8438d41286e
(cherry-pick from aosp/1009306)
(cherry picked from commit feb79bd0d7c5ecc7ac5ba9f54ed2d51ee9fd7e74)
2019-07-02 09:57:45 +00:00
TreeHugger Robot
3f1f8d1315 Merge "DO NOT MERGE - Merge qt-dev-plus-aosp-without-vendor (5699924) into stage-aosp-master" into stage-aosp-master 2019-07-02 07:41:13 +00:00
Maciej Żenczykowski
bb99759252 Merge "Fix mobile data usage didn't get increased for xlat464 traffic" am: e284b30c81 am: e74fb60c29
am: 854c2786ae

Change-Id: If8c252038d86ffb9d60de27d50994a2ebcca8408
2019-07-01 21:52:01 -07:00
junyulai
96fe3f5ff6 Fix mobile data usage didn't get increased for xlat464 traffic
Interface stats on stacked interfaces is usually clatd. For
xt_qtaguid supported device, the stats is already accounted
against its final egress interface by the kernel.
Framework side does not need to handle stats on statcked
interface at all.

However, on devices that support BPF offload, xlat464
packets are seen by the iptables rules as arriving on stack
interface only. Thus, add stack interface into accounting is
needed.

Bug: 136193260
Test: 1. atest FrameworksNetTests
      2. atest android.app.usage.cts.NetworkUsageStatsTest
      3. manual test on ipv6-only wifi network

Merged-In: I8ebbefbe4df00e40f4896a17fa52c8438d41286e
Change-Id: I8ebbefbe4df00e40f4896a17fa52c8438d41286e
(cherry-pick from aosp/1009306)
2019-07-02 04:34:33 +00:00
Maciej Żenczykowski
854c2786ae Merge "Fix mobile data usage didn't get increased for xlat464 traffic" am: e284b30c81
am: e74fb60c29

Change-Id: I670c09dd9aaf0e440a2e43b01cf1d94edbca28b7
2019-07-01 21:31:42 -07:00
junyulai
e5e15aee20 Fix mobile data usage didn't get increased for xlat464 traffic
Interface stats on stacked interfaces is usually clatd. For
xt_qtaguid supported device, the stats is already accounted
against its final egress interface by the kernel.
Framework side does not need to handle stats on statcked
interface at all.

However, on devices that support BPF offload, xlat464
packets are seen by the iptables rules as arriving on stack
interface only. Thus, add stack interface into accounting is
needed.

Bug: 136193260
Test: 1. atest FrameworksNetTests
      2. atest android.app.usage.cts.NetworkUsageStatsTest
      3. manual test on ipv6-only wifi network

Change-Id: I8ebbefbe4df00e40f4896a17fa52c8438d41286e
2019-07-01 14:17:47 -07: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
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
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
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
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
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