Commit Graph

722 Commits

Author SHA1 Message Date
Benedict Wong
52bdf5bad9 Merge "Use UID as requestID" am: 583f3632e5
am: 0372703a46

Change-Id: I0d9fb770482e72f3b017702ffb7ec144a64462e0
2018-09-12 15:22:39 -07:00
Benedict Wong
6d0cd0b7b6 Use UID as requestID
This change makes all requestIDs use the UID of the creator, ensuring
that rekeys always use the same requestID. This also has the nice
property of separating app's resources from each other, and allowing for
identification of which app/UID allocated the resources from
command-line dumps (eg ip xfrm state show)

Bug: 111841561
Test: Updated tests & passing taimen
Change-Id: I4f1eadcdb795766ae4682b15e41727359c52fa38
2018-09-04 14:25:13 -07:00
Benedict Wong
0e2450fddb Merge "Merge "Use tunnel local/remote addresses in security policies" am: 8424a78b75 am: 6b66877f18" into pi-dev-plus-aosp
am: 74fc889c8c

Change-Id: I1c5c03777f1ae8dc3bc08096a06824d99a982738
2018-08-31 11:45:09 -07:00
Benedict Wong
9cdc11d5ef Merge "Use tunnel local/remote addresses in security policies" am: 8424a78b75
am: 6b66877f18

Change-Id: Id515c008da62a67ecb36ff60a6cfd646074061ab
2018-08-31 11:12:55 -07:00
Benedict Wong
38e52973d2 Use tunnel local/remote addresses in security policies
This patch changes tunnel mode security policies to use the actual
tunnel's local and remote addresses to select the SA.
This prevents the kernel from calling xfrm_get_saddr(), which does a
route lookup, potentially resolving an incorrect saddr.

Bug: 79384676
Test: CTS, IpSecService* tests passing
Change-Id: I8223225e2363a79591a0bb0040aa8619cf84c184
2018-08-30 10:55:02 -07:00
Remi NGUYEN VAN
172c9ae72a Merge "Fix testRegisterUsageCallback failure in setUp" am: 3e4562b391
am: 7026ccd445

Change-Id: I5723e356d1b6aa1a71ba693598a5796900fd9ddc
2018-08-17 02:02:08 -07:00
Remi NGUYEN VAN
2d18dc94ac Fix testRegisterUsageCallback failure in setUp
LocalServices.addService in NetworkStatsService is currently failing
with IllegalStateException "Overriding service registration". Setting up
LocalServices in the test to avoid this issue might be possible, but
moving the registration to the only non-test caller of that constructor
as done here solves the issue and avoids side-effects from a constructor.

Test: atest FrameworksNetTests does not choke on this test
Bug: b/78487385
Bug: b/80082746
Change-Id: I5dba98fc79aec0800c8b71e6c7e23d1cfbcae852
Merged-In: I884a7a8bd7db3fcd220b785ba9914ac8c77720f0
(Clean cherry-pick of go/ag/4061255)
2018-08-14 18:14:09 +09:00
Brett Chabot
02532fc4c2 Migrate frameworks/base/services/tests/servicestests to androidx.test
See go/jetpack-test-android-migration

cherrypicked from ag/4608401

Test: atest FrameworksServicesTests
Change-Id: I2d9641c681489135aa3167bb4c9b1296a1a6a4f7
2018-08-10 14:04:11 -07:00
Chiachang Wang
7821223c41 Merge "DO NOT MERGE: use legacy way to get tcp packet count" into pi-dev
am: 15cbfefb03

Change-Id: I7d0498bece672a482e2204424ca5d7780a6c7dc8
2018-07-22 18:57:43 -07:00
junyulai
0b4a66a1c2 DO NOT MERGE: use legacy way to get tcp packet count
The current networkStats getIfaceStats implementation check if
bpf is enabled, and use bpf to get all traffic stats. However,
the bpf implementation did not contain tcp packet counts. So
data stall detection in DcTracker could not get the packet
count to trigger data stall. Hence the data stall never
triggers for device that enables bpf.

This solution is for short term solution that rollback the
design to use xt_qtaguid for bpf enabled device.

Bug: 110443385
Test: 1. fake data stall to trigger data stall recovery
      2. enable debug log to make sure tcp packet count is
         correct
      3. runtest frameworks-net
      4. run cts -m CtsUsageStatsTestCases

Change-Id: I1ce9e92fe194da2ea0a3eec014fd50bb50cdd44a
2018-06-26 15:46:48 +08:00
Nathan Harold
ebe4aa77d4 Merge "Disable the AppOp Restriction for IpSec Tunnels" into stage-aosp-master am: bda7c96038
am: 48474a78ad

Change-Id: Idb6ff2adc72d0a293e1d99c287d0df68df88fe79
2018-06-09 09:43:53 -07:00
Nathan Harold
7c250aedb1 Disable the AppOp Restriction for IpSec Tunnels
This CL temporarily removes the AppOp restriction
that disallows creation of IpSec tunnels due to
the lack of the appropriate AppOp in AOSP/master.
When the relevant framework merges out to master,
this CL should be reverted.

Manually merging this due to skipping a merge
conflict at ef9f2740a790feceaa47a24b1a179e93c4ffb5e6

Bug: none
Test: compilation
Change-Id: Ic06c193f85f6bcdd0ead4238825c1add78703cde
2018-06-08 23:23:04 +00:00
Remi NGUYEN VAN
47df8a66e4 Merge "Fix testRegisterUsageCallback failure in setUp" 2018-05-31 00:05:53 +00:00
Jeff Sharkey
eecce38819 Merge "Last-ditch clamping of negative NetworkStats." into pi-dev
am: 0026f5eb18

Change-Id: I0db4e16533aeac3aa88307a0af0b64cb6041d2c0
2018-05-23 16:20:22 -07:00
Jeff Sharkey
0026f5eb18 Merge "Last-ditch clamping of negative NetworkStats." into pi-dev 2018-05-23 16:30:25 +00:00
Remi NGUYEN VAN
ea2710c799 Fix testRegisterUsageCallback failure in setUp
LocalServices.addService in NetworkStatsService is currently failing
with IllegalStateException "Overriding service registration". Setting up
LocalServices in the test to avoid this issue might be possible, but
moving the registration to the only non-test caller of that constructor
as done here solves the issue and avoids side-effects from a constructor.

Test: this test passes in master through runtest frameworks-net
Bug: b/78487385
Bug: b/80082746
Change-Id: I884a7a8bd7db3fcd220b785ba9914ac8c77720f0
2018-05-23 13:19:57 +09:00
Jeff Sharkey
d631c5836d Last-ditch clamping of negative NetworkStats.
We've seen reports of negative values flowing through to attempt
being recorded, which will outright crash.  This change does one
last-ditch check to see if we're about to work with negative values,
reporting any trouble and clamping them to zero so we don't crash.

This gives us the data we need to continue investigating without
triggering runtime restarts in the field.

Bug: 80057433
Test: atest android.net.NetworkStatsTest
Change-Id: I8174391c6cf5dadc2c2c10a8d841ee07e1f7d934
2018-05-22 11:35:32 -06:00
Chenbo Feng
f407e646b4 Merge "Check for bpf support at NetworkStatsService start" into pi-dev
am: 6555a9fa16

Change-Id: If2fd9e040e4717f1040c16e4b5f6c61cfc14e140
2018-05-21 12:44:23 -07:00
Chenbo Feng
dc9c7fc7bf Check for bpf support at NetworkStatsService start
The current implementation check for bpf map existance whenever a
NetworkStats request comes in. The check is not efficient and may
require additional permission for threads. So a member variable is added
to NetworkStatsService to store the bpf configuration status and is
initialized when NetworkStatsService start.

Test: -m CtsNetTestCases -t android.net.cts.TrafficStatsTest
      -m CtsUsageStatsTestCases -t android.app.usage.cts.NetworkUsageStatsTest
Bug: 79994577

Change-Id: I872ae18fb3e9631a4e6c4d773fefbba32e60a03b
2018-05-18 17:10:07 -07:00
Nathan Harold
f12f06c7cc Merge "[DO NOT MERGE] Use INetd Constant for IpSec Interface Prefix" into pi-dev
am: 89005ff73e

Change-Id: I09fe6255126cefbbf165bc1f8af031c17aead7d1
2018-05-09 10:46:20 -07:00
Nathan Harold
7be7f4596a [DO NOT MERGE] Use INetd Constant for IpSec Interface Prefix
Convert to using a constant in INetd to ensure
that there is a consistent tunnel prefix  between
Java and native code.

Bug: 74560705
Test: atest FramworksNetTest; atest CtsNetTestCases
Change-Id: Ida233aac2e6c6b26567463964e0ebac9d52eff1e
2018-05-09 01:33:06 +00:00
Nathan Harold
86238ee312 Merge "Rework Exception Handling for IpSecManager" into pi-dev
am: 16c671dc9a

Change-Id: I9c1acdc79053c70a8484935f61a537379b9be927
2018-04-25 11:51:00 -07:00
Nathan Harold
beed0b61b7 Rework Exception Handling for IpSecManager
In order to properly support EOPNOTSUPP this CL
applies a consistent approach to handling Exceptions.
Hereafter, all exceptions that aren't of a special
method-specific type (such as SpiUnavailableException)
will all be returned to the calling process unchanged.
At the API call site, the ServiceSpecificException,
which is really an Errno, will be inspected and either
converted to an unchecked exception for types we know,
or it will be converted to an IOException in cases where
that method can return a checked exception. In cases
where we do not expect an errno, we will simply throw
a generic RuntimeException. This means all API calls
will now properly throw UnsupportedOperationException
and may be CTS tested accordingly.

Bug: 72420898
Test: runtest frameworks-net
Change-Id: I4a00e221618896223fcdb4b4279fb14cd14e34d8
2018-04-24 19:04:08 -07:00
Jeff Sharkey
ce6d660a84 Merge "Give CTS a way to force-poll network stats." into pi-dev
am: 46e58e1b40

Change-Id: Id2252b803a33ddadfef71618b3b9106c93c5be2a
2018-04-20 13:51:02 -07:00
Jeff Sharkey
5a0df01ad7 Give CTS a way to force-poll network stats.
Collecting network statistics is pretty heavy, which is why we're
throttling callers.  However, to keep CTS running fast, we provide a
way for tests to force a poll event, instead of making them wait for
the throttle timeout.

Bug: 77908520
Test: atest cts/tests/tests/app.usage/src/android/app/usage/cts/NetworkUsageStatsTest.java
Change-Id: Ia792f0cd495023366ff8c4839df54e7da2ae8331
2018-04-20 12:18:23 -06:00
Jeff Sharkey
bc05a34970 Merge "Never interact with "phone" while holding locks." into pi-dev
am: d101084db7

Change-Id: I570994cd8ab5c7499dfa94b17e42687181637de0
2018-04-19 20:00:48 -07:00
Jeff Sharkey
c0ddfa3185 Never interact with "phone" while holding locks.
We've seen devices where heavy communication between "system_server"
and the "phone" process can exhuast Binder threads, especially when
calling while holding locks.  To mitigate this, we now interact with
the "phone" process before acquiring any locks.

Update our internal data structures either when we see a connectivity
change, or when SubscriptionManager tells us something changed.

Fix bug in resolveSubscriptionPlan() that always picked the 0'th
SubscriptionPlan instead of looking for the currently active plan;
we now use the same logic for both NSS and NPMS.

Bug: 77908520, 77154412
Test: atest com.android.server.NetworkPolicyManagerServiceTest
Test: atest com.android.server.net.NetworkStatsServiceTest
Change-Id: I177d3fa6cddc78d745b35a9ede12451d458b892c
2018-04-19 14:41:35 -06:00
Jeff Sharkey
addd48f987 Merge "Add tracing for network statistics and policy." into pi-dev
am: a4cd50c93e

Change-Id: I2b6634c8df4dfe14fb4cd01bca6611e7cf7a0056
2018-04-16 18:10:40 -07:00
Jeff Sharkey
8f3b754cd3 Add tracing for network statistics and policy.
These trace points surround areas of heavy lifting to help us debug
code that might be taking longer than expected.  (For example, slow
getting data from eBPF, slow recording into data structures, slow
writing to disk, or slow evaluating policy.)

Typical timings on a taimen:

performPollLocked:   25.5ms
snapshotUid:          4.4ms
snapshotXt:           1.4ms
[persisting]:        13.4ms
updateNotifications:  3.3ms

Bug: 77908520, 77808546, 77853238, 77154412
Test: builds, boots
Change-Id: I072bfecffee01eeec7e4cbad439bd1cdc166febc
2018-04-16 13:31:32 -06:00
Jeff Sharkey
31798e0b93 Merge "Revert "Revert "OP_GET_USAGE_STATS should be noted, not checked.""" into pi-dev
am: 004b279683

Change-Id: Ie9bcdc9736c04ab787efc193311a20d03718b593
2018-04-16 10:19:39 -07:00
Jeff Sharkey
aeaa916b66 Merge "Revert "OP_GET_USAGE_STATS should be noted, not checked."" into pi-dev
am: 893abe5d47

Change-Id: I2cc76316bca81c12e56337d6e36d82b0de6d9ded
2018-04-16 10:07:52 -07:00
Jeff Sharkey
004b279683 Merge "Revert "Revert "OP_GET_USAGE_STATS should be noted, not checked.""" into pi-dev 2018-04-16 16:54:32 +00:00
Jeff Sharkey
0eb04dc200 Revert "Revert "OP_GET_USAGE_STATS should be noted, not checked.""
This reverts commit c6624c7a1a.

Reason for revert: ijpedowitz@

Bug: 77662908
Change-Id: I596d330d64942105f447bb613012bb11e281a805
Exempt-From-Owner-Approval: keep tests passing
2018-04-16 16:50:34 +00:00
Jeff Sharkey
893abe5d47 Merge "Revert "OP_GET_USAGE_STATS should be noted, not checked."" into pi-dev 2018-04-16 16:50:06 +00:00
Jeff Sharkey
c6624c7a1a Revert "OP_GET_USAGE_STATS should be noted, not checked."
This reverts commit 930aeb0c00.

Reason for revert: ijpedowitz@

Bug: 77662908
Change-Id: I5dd0ad5038df90ea8a80ba6f583ee46fb24600c2
Exempt-From-Owner-Approval: keep tests passing
2018-04-16 16:39:55 +00:00
Jeff Sharkey
8984338162 Merge "OP_GET_USAGE_STATS should be noted, not checked." into pi-dev
am: e5a47054b3

Change-Id: I38f5aecdb94c8b886ca4eba5908ab1b4a9c1fb89
2018-04-14 18:11:58 -07:00
Jeff Sharkey
84151258a1 Merge "Don't process broadcasts until really ready." into pi-dev
am: fcc07b53fa

Change-Id: I898d5c2d351951a7c016cbc70cb81210a9e18b26
2018-04-14 17:39:59 -07:00
Jeff Sharkey
e5a47054b3 Merge "OP_GET_USAGE_STATS should be noted, not checked." into pi-dev 2018-04-13 23:58:44 +00:00
Jeff Sharkey
e6c2cfbe42 Don't process broadcasts until really ready.
Someone started setting mSystemReady too early, when we really want
to know SystemServer's real ready state.  Add a variable to track
that, and don't process broadcasts until that's set.

Bug: 78020762
Test: builds, boots
Change-Id: I65213e46044c95fb0a8a4b09b9aa463bb15c1844
2018-04-13 14:28:32 -06:00
Jeff Sharkey
930aeb0c00 OP_GET_USAGE_STATS should be noted, not checked.
Per email feedback, we should be using "noteOp" instead of "checkOp"
when testing if caller holds OP_GET_USAGE_STATS, so that we record
that caller used the operation.

Bug: 77662908
Test: builds, boots
Exempt-From-Owner-Approval: keep tests passing
Change-Id: I3a60345d590534fdbc2c1248e0d30dc85a5d6772
2018-04-13 19:32:25 +00:00
Remi NGUYEN VAN
f8536e7c44 Merge "Add rate limiting and logging for NetworkStats." into pi-dev
am: c9185b5f3c

Change-Id: I446a85f8d74fb33abb3a5f6fb1ef86f3c24bb6d4
2018-04-12 14:30:05 -07:00
Remi NGUYEN VAN
3d55d4c02e Add rate limiting and logging for NetworkStats.
Bug: 77908520, 77808546, 77853238, 77154412
Test: atest com.android.server.net.NetworkStatsServiceTest
Test: manual: flashed, verified network usage updated
Change-Id: I905dbea85e00f80103916939f6d4bf8cab931d03
2018-04-12 12:43:53 -06:00
Remi NGUYEN VAN
844d0f6091 Merge "Do not register callback for < MIN_THRESHOLD_BYTES" into pi-dev
am: 76823e1357

Change-Id: I7aab9434ab9b11fe588c057a4c2b774b09ad71d2
2018-04-10 20:46:55 -07:00
Remi NGUYEN VAN
76823e1357 Merge "Do not register callback for < MIN_THRESHOLD_BYTES" into pi-dev 2018-04-11 03:18:57 +00:00
Remi NGUYEN VAN
27d62a0a32 Do not register callback for < MIN_THRESHOLD_BYTES
This also avoids returning a nonzero multipath preference
if remaining data is low but nonzero.

Bug: b/72877610
Change-Id: I2459ded06de77d284ae1fe81a60d9e1df56b0c26
Fixes: b/72877610
Test: Tests in go/ag/3842960 pass
2018-04-10 10:27:00 +09:00
Jeff Sharkey
99670560ca Merge "API council requested tweaks to SubscriptionPlan." into pi-dev
am: ecd081f906

Change-Id: I447d4041d1dd0751147d13792b07d6617b27978a
2018-04-09 17:09:34 -07:00
Jeff Sharkey
17a51c8a56 API council requested tweaks to SubscriptionPlan.
Return new shiny Range<> object instead of Pair<>.  Tell developers
what permission to check on refresh broadcast.  Describe what
exceptions might be thrown, and that an empty list is okay.

Allow creation of plans with richer Period object, instead of forcing
them into rigid week or day options.

Protect SubscriptionPlan broadcast.

Test: atest android.util.RecurrenceRuleTest
Test: atest com.android.server.NetworkPolicyManagerServiceTest
Bug: 74945820
Change-Id: I7e555798e0cfaa214ca93d9df627c6443fc5d986
2018-04-04 16:06:27 -06:00
Nathan Harold
6807999817 Merge "Add AppOps Checks for MANAGE_IPSEC_TUNNELS" into pi-dev
am: 80a2bba9a6

Change-Id: Icd1b2cfc699ab44e4ca536b98298d5b23db7372e
2018-04-03 14:41:56 -07:00
Nathan Harold
65ef843176 Add AppOps Checks for MANAGE_IPSEC_TUNNELS
Adds support for a new AppOp to permit services to
use IpSec tunnel mode. The IpSecService now needs
a context so change the service mode to a cached
service rather than a static service.

Bug: 66955045
Test: runtest frameworks-net
Change-Id: I17a4a286225b432c3e15ea1587d946189931b4f4
2018-04-03 18:23:11 +00:00
Remi NGUYEN VAN
0023be9ea9 Fix network usage stats on 464xlat tethered.
Usage stats corrections for 464xlat in NetworkStatsFactory are not applied
to tethered traffic. Add adjustments in NetworkStatsService. After
migrating external callers off NetworkStatsFactory, we will be able to
only apply adjustments in NetworkStatsService and remove stacked
interface tracking from NetworkStatsFactory.
Bug: 72107146
Fixes: 72107146
Test: runtest frameworks-net & manual - checked corrected network usage
Merged-In: Ieb25c41c651499fdd01225ae5ac21d95e3d823f5
Merged-In: I016722f3a0ae2ae0a1d48bfacc4fe07ee3578ef7
(cherry-pick of aosp I5ce450e616b4fddf21f2a491fe5d0c9e9f969bda)

Change-Id: Id41cf22a0f9a63cb1832e9375bfb045861f08e52
2018-04-02 13:30:02 +00:00