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
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
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)
See go/jetpack-test-android-migration
cherrypicked from ag/4608401
Test: atest FrameworksServicesTests
Change-Id: I2d9641c681489135aa3167bb4c9b1296a1a6a4f7
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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