Commit Graph

1911 Commits

Author SHA1 Message Date
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
34c3ba6be7 Merge "Add NATT keepalive resources and methods into IpSecService" am: c345527430 am: 70e5117542
am: 5dd6a60745

Change-Id: I65a8e6d4b4d7c8ccbd708eb3bc16a19becfff43c
2019-04-22 14:11:15 -07: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
Chalard Jean
a2a6e08245 [automerger skipped] Merge "Restrict access to dangerous methods to <= P" into qt-dev am: f3a812858c -s ours
am: 0ea6659635 -s ours
am skip reason: change_id I95107f7b628eecb54e9f4411785186b668e9f3d8 with SHA1 b3dbc3f845 is in history

Change-Id: Iea63d9398078fcd421f93b78b62ca5e87e77f939
2019-04-22 00:42:55 -07:00
Chalard Jean
0ea6659635 [automerger skipped] Merge "Restrict access to dangerous methods to <= P" into qt-dev
am: f3a812858c -s ours
am skip reason: change_id I95107f7b628eecb54e9f4411785186b668e9f3d8 with SHA1 b3dbc3f845 is in history

Change-Id: I18b0c3f0f36f39e8cc758b98c3e8c44a23b69f25
2019-04-22 00:32:19 -07:00
TreeHugger Robot
f3a812858c Merge "Restrict access to dangerous methods to <= P" into qt-dev 2019-04-22 07:14:10 +00:00
Benedict Wong
4aac3e9e48 Add NATT keepalive resources and methods into IpSecService
This change adds a new NATTKeepalive resource type, along with the
associated allocation/deallocation. Additionally, this change allows
ReferenceCountedResource(s) to not be binder-linked, to allow the
ConnectivityService to verify ownership and allocate a NattKeepalive
without double-registering for binder-death notifications.

Bug: 125517194
Test: IpSecService frameworks tests ran
Change-Id: I8293f79940ad57dabb6f2b9de5e334d06b869443
2019-04-19 11:17:21 -07:00
Chalard Jean
d66c1869f4 [automerger skipped] Merge "Move TrafficStats tags for the network stack constants" am: d2eb7f71b8 am: 2c28ee4cb8 -s ours
am: 19a6b5c027 -s ours
am skip reason: change_id I4882686a86e7c6d42f4b0619b921d02619ed6d4c with SHA1 cf0e250114 is in history

Change-Id: I3e682721ed3e8a574d84d12baf84cc2d6c097412
2019-04-17 00:06:14 -07:00
Chalard Jean
19a6b5c027 [automerger skipped] Merge "Move TrafficStats tags for the network stack constants" am: d2eb7f71b8
am: 2c28ee4cb8 -s ours
am skip reason: change_id I9b648ed6c687d56db61a54570c7880c51c1bae51 with SHA1 1c9c56a164 is in history

Change-Id: If30091ab2a164d01cab11fdd7e6e3aeaa805082c
2019-04-16 23:19:28 -07:00
Chalard Jean
2c28ee4cb8 Merge "Move TrafficStats tags for the network stack constants"
am: d2eb7f71b8

Change-Id: I13ba9e3077bb4ec28229a09f2d4747a43c281bcc
2019-04-16 23:08:07 -07:00
Chalard Jean
d2eb7f71b8 Merge "Move TrafficStats tags for the network stack constants" 2019-04-17 05:45:56 +00:00
Chalard Jean
8a93ab8eef Move TrafficStats tags for the network stack constants
As per API council feedback, these constants should live in
a place that is private to the network stack, only with a
range defined in system API.

Bug: 129433383
Test: m
Change-Id: I84a90f84a9af6fef4667ee4d512ebd0413222086
Merged-In: I4882686a86e7c6d42f4b0619b921d02619ed6d4c
Merged-In: I9b648ed6c687d56db61a54570c7880c51c1bae51
2019-04-17 05:45:40 +00:00
Chalard Jean
cf0e250114 Merge "Move TrafficStats tags for the network stack constants" into qt-dev am: e7ef0a61f2
am: 1c9c56a164

Change-Id: I4882686a86e7c6d42f4b0619b921d02619ed6d4c
2019-04-16 17:38:30 -07:00
Chalard Jean
1c9c56a164 Merge "Move TrafficStats tags for the network stack constants" into qt-dev
am: e7ef0a61f2

Change-Id: I9b648ed6c687d56db61a54570c7880c51c1bae51
2019-04-16 15:06:03 -07:00
Chalard Jean
a69a73ece7 Restrict access to dangerous methods to <= P
Test: make
Fixes: 130143562
Change-Id: I1a6a472f83cf00a1ab174a9c5e67d3e9357a0c45
Merged-In: I95107f7b628eecb54e9f4411785186b668e9f3d8
Merged-In: I890030580fdad45c3f8589bf6adbe5798d578cfe
(cherry picked from commit 0bb53dbb64bbc937a23e1dc7641c8988a6d11d64)
2019-04-16 06:13:09 +00:00
Chalard Jean
ea057ac6a7 Merge "Restrict access to dangerous methods to <= P" am: a1c9270562 am: af8f384985
am: b3dbc3f845

Change-Id: I890030580fdad45c3f8589bf6adbe5798d578cfe
2019-04-15 23:08:09 -07:00
Chalard Jean
b3dbc3f845 Merge "Restrict access to dangerous methods to <= P" am: a1c9270562
am: af8f384985

Change-Id: I95107f7b628eecb54e9f4411785186b668e9f3d8
2019-04-15 22:39:08 -07:00
Chalard Jean
af8f384985 Merge "Restrict access to dangerous methods to <= P"
am: a1c9270562

Change-Id: I3c1271e00e026518e9c4ddafc931a2cac87dcee0
2019-04-15 22:29:28 -07:00
Chalard Jean
a1c9270562 Merge "Restrict access to dangerous methods to <= P" 2019-04-16 05:17:20 +00:00
Chalard Jean
65081e4cf6 Move TrafficStats tags for the network stack constants
As per API council feedback, these constants should live in
a place that is private to the network stack, only with a
range defined in system API.

Bug: 129433383
Test: m
Change-Id: I84a90f84a9af6fef4667ee4d512ebd0413222086
(cherry picked from commit 79a6330650ca04bd7a08afbd63f8016a3b30bc72)
2019-04-16 00:41:54 +09:00
Chenbo Feng
d9e86cc9bd Merge "Ask netd to swap stats map before reading" am: f8b251fd28 am: 3878f31aff
am: 273e13711d

Change-Id: I4ac7af7b290f4f9cfeaef31e3acfc1c1e0458c3c
2019-04-12 18:30:36 -07:00
Chenbo Feng
273e13711d Merge "Ask netd to swap stats map before reading" am: f8b251fd28
am: 3878f31aff

Change-Id: I333e4cdc807da0dd1e2ca118f9ebcf2d94c683de
2019-04-12 16:39:07 -07:00
Chenbo Feng
3878f31aff Merge "Ask netd to swap stats map before reading"
am: f8b251fd28

Change-Id: I7a683e479fe7631a167138314bcf5948e72386ec
2019-04-12 16:06:30 -07:00
Treehugger Robot
f8b251fd28 Merge "Ask netd to swap stats map before reading" 2019-04-12 22:35:52 +00:00
Chenbo Feng
300b6a3b73 Merge "Add a lock to protect persistent stats snapshot" am: f31face531 am: 57f207b1c7
am: 24e9a313cd

Change-Id: I20ba17b211657542c0bfde6acd4299d9ae6b169b
2019-04-12 06:39:02 -07:00
Chenbo Feng
24e9a313cd Merge "Add a lock to protect persistent stats snapshot" am: f31face531
am: 57f207b1c7

Change-Id: Ia91b71536447e65725a85ebf2ac4f411aebe86c8
2019-04-12 05:59:36 -07:00
Chenbo Feng
57f207b1c7 Merge "Add a lock to protect persistent stats snapshot"
am: f31face531

Change-Id: I73851336452110afb74d6dd1ca5e50047d5b3d4a
2019-04-11 18:44:45 -07:00
Treehugger Robot
f31face531 Merge "Add a lock to protect persistent stats snapshot" 2019-04-12 01:33:00 +00:00
Chenbo Feng
876218abcb 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
2019-04-10 12:59:38 -07:00
Chenbo Feng
0c419ca9eb 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: I22afb46f17697e8b6359d4f593802e0f4b95db8b
2019-04-10 12:59:18 -07:00
Benedict Wong
5eda9257d9 [automerger skipped] Merge "Fix remove-before-add for IpSecService RefcountedResource" into qt-dev am: 21dbd30681 -s ours
am: 80e078d789 -s ours
am skip reason: change_id I6db75853da9f29e1573512e26351623f22770c5d with SHA1 04738f5b07 is in history

Change-Id: Ibecfa12754acbdce0eb3369d1577eedea91ecaa4
2019-04-10 12:14:07 -07:00
Benedict Wong
80e078d789 [automerger skipped] Merge "Fix remove-before-add for IpSecService RefcountedResource" into qt-dev
am: 21dbd30681 -s ours
am skip reason: change_id I6db75853da9f29e1573512e26351623f22770c5d with SHA1 04738f5b07 is in history

Change-Id: I3e0bd244d8a2ddf86cf4dab99d4a563ea1e2b01e
2019-04-10 11:14:47 -07:00
Benedict Wong
21dbd30681 Merge "Fix remove-before-add for IpSecService RefcountedResource" into qt-dev 2019-04-10 17:07:02 +00:00
Chiachang Wang
92625dde9a [automerger skipped] Merge "Enforce NETWORK_STACK permission for calling NSS#forceUpdateIfaces" into qt-dev am: 60cc2ab6e7 -s ours
am: dee0e3d241 -s ours
am skip reason: change_id I1b26dc64eaab2151e6885fd01cc5e8d4e18c4e60 with SHA1 e3f8027e89 is in history

Change-Id: I20681ad9cedf6beddf3fdf528e6a514694839258
2019-04-10 04:40:37 -07:00
Chiachang Wang
dee0e3d241 [automerger skipped] Merge "Enforce NETWORK_STACK permission for calling NSS#forceUpdateIfaces" into qt-dev
am: 60cc2ab6e7 -s ours
am skip reason: change_id I1b26dc64eaab2151e6885fd01cc5e8d4e18c4e60 with SHA1 e3f8027e89 is in history

Change-Id: I23657309145be45306d2df70dcc517e4c36a82a1
2019-04-10 04:14:11 -07:00
Chiachang Wang
8757df33e4 Enforce NETWORK_STACK permission for calling NSS#forceUpdateIfaces
ConnectivityManager and its usages are removed from
NetworkStatsService. After that, forceUpdateIfaces requires
information that only ConnectivityService has, hence
restricting the calling permission to NETWORK_STACK or
MAINLINE_NETWORK_STACK permission. The required permission
will be changed from READ_NETWORK_USAGE_HISTORY to
NETWORK_STACK or MAINLINE_NETWORK_STACK. This change would make
it impossible to call outside the system.

Bug: 126830974
Test: atest FrameworksNetTests
Merged-In: I1b26dc64eaab2151e6885fd01cc5e8d4e18c4e60
Change-Id: I4ea421e4126a45f65d25fe0bec74243a3b20aeab
(cherry picked from commit 6b895dea25b4fca87d275bb78367411623ded1d4)
2019-04-10 06:36:55 +00:00
Chiachang Wang
851b15c72a Merge "Enforce NETWORK_STACK permission for calling NSS#forceUpdateIfaces" am: 41c49d1a8e am: a1a994c7eb
am: e3f8027e89

Change-Id: I4ea421e4126a45f65d25fe0bec74243a3b20aeab
2019-04-09 23:24:41 -07:00
Chiachang Wang
e3f8027e89 Merge "Enforce NETWORK_STACK permission for calling NSS#forceUpdateIfaces" am: 41c49d1a8e
am: a1a994c7eb

Change-Id: I1b26dc64eaab2151e6885fd01cc5e8d4e18c4e60
2019-04-09 20:14:44 -07:00
Chiachang Wang
a1a994c7eb Merge "Enforce NETWORK_STACK permission for calling NSS#forceUpdateIfaces"
am: 41c49d1a8e

Change-Id: Id5922a41d07c95958090f88a65d22ef5883aefff
2019-04-09 19:37:20 -07:00
Chiachang Wang
41c49d1a8e Merge "Enforce NETWORK_STACK permission for calling NSS#forceUpdateIfaces" 2019-04-10 02:27:30 +00:00
Benedict Wong
098b1e8ab0 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
Benedict Wong
24b1bcb245 Merge "Fix remove-before-add for IpSecService RefcountedResource" am: dcd06394d4 am: 47fa5b0f7f
am: 70c844d317

Change-Id: Ib955acaa5e498c0e977cb5f2e48cffbc9fea8c7c
2019-04-09 11:31:46 -07:00
Benedict Wong
70c844d317 Merge "Fix remove-before-add for IpSecService RefcountedResource" am: dcd06394d4
am: 47fa5b0f7f

Change-Id: I416c2e43961ec0e1cc6b2fbcef970fbce858603b
2019-04-09 10:56:30 -07:00
Benedict Wong
47fa5b0f7f Merge "Fix remove-before-add for IpSecService RefcountedResource"
am: dcd06394d4

Change-Id: Ief286a54a93efd731deeff9fc32815663ab7695d
2019-04-09 10:39:16 -07:00
Benedict Wong
dcd06394d4 Merge "Fix remove-before-add for IpSecService RefcountedResource" 2019-04-09 17:22:56 +00:00
Chiachang Wang
f04137e99e Enforce NETWORK_STACK permission for calling NSS#forceUpdateIfaces
ConnectivityManager and its usages are removed from
NetworkStatsService. After that, forceUpdateIfaces requires
information that only ConnectivityService has, hence
restricting the calling permission to NETWORK_STACK or
MAINLINE_NETWORK_STACK permission. The required permission
will be changed from READ_NETWORK_USAGE_HISTORY to
NETWORK_STACK or MAINLINE_NETWORK_STACK. This change would make
it impossible to call outside the system.

Bug: 126830974
Test: atest FrameworksNetTests
Change-Id: I776484921b2dbb6735d7940c558fb5e4baed6d1e
2019-04-09 19:42:52 +08:00
Lorenzo Colitti
9dee45962a [automerger skipped] Merge "Fix flaky UdpEncapsulationSocket test" into qt-dev am: 634dff01cb -s ours
am: 8c9e2b7871 -s ours
am skip reason: change_id Idf040a67e53d9b9ec6e6c647ce24f8ada501d355 with SHA1 4be55d08d9 is in history

Change-Id: Ic488c621c0ebe04c6298d7d2a06201abcbb61a37
2019-04-09 04:33:08 -07:00
Lorenzo Colitti
8c9e2b7871 [automerger skipped] Merge "Fix flaky UdpEncapsulationSocket test" into qt-dev
am: 634dff01cb -s ours
am skip reason: change_id Idf040a67e53d9b9ec6e6c647ce24f8ada501d355 with SHA1 4be55d08d9 is in history

Change-Id: Ic9b6b8c2ca4aabd3ed18291a94992a2b67286064
2019-04-09 02:31:35 -07:00
Chalard Jean
3cfb4991eb Restrict access to dangerous methods to <= P
Test: make
Fixes: 130143562
Change-Id: I1a6a472f83cf00a1ab174a9c5e67d3e9357a0c45
2019-04-09 15:47:25 +09:00