Commit Graph

403 Commits

Author SHA1 Message Date
Remi NGUYEN VAN
4cac91f292 Merge "Add method to NetworkStatsService for UID stats." into pi-dev 2018-04-02 05:40:04 +00:00
Benedict Wong
97e1f5b953 Merge "Disallow Reserved SPI Allocation" into pi-dev 2018-03-30 22:29:26 +00:00
Benedict Wong
cafd11d598 Merge changes from topic "encap-api" into pi-dev
* changes:
  Require explicitly supplied truncation length
  Clarify UDP encapsulation socket API
2018-03-30 20:28:19 +00:00
Remi NGUYEN VAN
944eab8689 Add method to NetworkStatsService for UID stats.
Useful for clients such as BatteryStats which currently rely
on NetworkStatsFactory. Data at that stage is incomplete as
it does not account for tethering, VT data and corresponding
464xlat corrections.

Test: runtest frameworks-net, CTS tests pass.
Bug: b/72107146
Merged-In: I31c5b9b4a7c6e72910152415894a137f000a5858
Merged-In: I2527d95000c7500c824ede70f87ecb38e21ed323
(cherry picked from aosp 088ff6824f13145ea52207bdead0d7e454a6f3ce)

Change-Id: Ie80f1bb21124241f3414f9be77aceac9a44ec6d1
2018-03-30 18:58:18 +09:00
Nathan Harold
1b88f0e6ab Disallow Reserved SPI Allocation
Disallow the allocation of SPIs in the range
reserved for future use by RFC 4303.

Bug: 77205120
Test: runtest frameworks-net
Merged-In: I05e26ed34b5871f1a07d5bd7b58b79a64cd74b67
Change-Id: I05e26ed34b5871f1a07d5bd7b58b79a64cd74b67
(cherry picked from commit 7f606ee8e57d9d8b7c5d0cb2a78421aa02efb385)
2018-03-30 01:54:36 -07:00
Remi NGUYEN VAN
66fcefd311 Merge "Allow null subscriberId in NetworkStatsManager." into pi-dev 2018-03-30 07:39:23 +00:00
Benedict Wong
ad2615cae5 Require explicitly supplied truncation length
Instead of providing default truncation lengths (based on RFC or
otherwise), this change imposes a restriction that the truncation length
must be supplied for all auth or aead algorithms.

Bug: 77204048
Test: Updated tests, ran on walleye
Merged-In: I4a0e2e71aa97259e56f44e7c8a2ce53135708d97
Change-Id: I4a0e2e71aa97259e56f44e7c8a2ce53135708d97
(cherry picked from commit bb7f2820f5bcccf8618078c2cbe4ea9836797e3b)
2018-03-29 23:07:42 -07:00
Benedict Wong
a386e37eab Clarify UDP encapsulation socket API
This change updates the getSocket() methods for IPsec to improve clarity
of the return types, both for public APIs, and internal-only methods.

Bug: 72473753
Test: APIs updated, CTS + unit tests ran.
Merged-In: I0afebd432c5d04c47c93daa1ce616d712aa323d7
Change-Id: I0afebd432c5d04c47c93daa1ce616d712aa323d7
(cherry picked from commit 4c987ebade580d4abc8a3d549e0df90baab33140)
2018-03-29 23:05:42 -07:00
Remi NGUYEN VAN
9968ec4f14 Allow null subscriberId in NetworkStatsManager.
Use a MATCH_MOBILE_WILDCARD template to avoid filtering by
subscriberId when querying statistics from NetworkStatsService.

Bug: 74038898
Change-Id: I8296220472a9ba37044dd1a5ede9bdb45d3ed339
Fixes: 74038898
Test: runtest frameworks-net, CTS tests pass
Merged-In: I1e4e283c6eaecf33d12488e41e0c524f6ff83954
Merged-In: Ia84d2c7cc63bf8b8bf30f133e0382fd7103bf490
(cherry-picked from aosp I4b39e7031416cb33b23d89aa36ff0f774eaa942f)
2018-03-30 12:18:23 +09:00
Benedict Wong
0f57fe460b Merge "Add documentation for TCP interactions with transforms" into pi-dev 2018-03-30 00:01:43 +00:00
Benedict Wong
c5106f3cfc Add documentation for TCP interactions with transforms
Updates API documentation to mention that TCP sockets where transforms
are deactivated will not send FIN packets.

Bug: 74851550
Test: API updates only
Merged-In: I8169f221c8c747538a8bddfbf02dcc73c9337189
Change-Id: I8169f221c8c747538a8bddfbf02dcc73c9337189
(cherry picked from commit 7d31a2f3579eff80c3cef07feadf77dbfcbfcd17)
2018-03-27 15:20:32 -07:00
Jeff Sharkey
17a3875fb6 API council requested tweaks to TrafficStats.
Test: atest android.appsecurity.cts.AppSecurityTests#testAppFailAccessPrivateData
Bug: 71584606
Change-Id: I4be8a47d54a04f17cbaac735d543ff7d6370376d
2018-03-26 13:12:39 -06:00
Nathan Harold
00e77247eb Add MANAGE_IPSEC_TUNNELS Permission
Add a new MANAGE_IPSEC_TUNNELS permission and
protect all IPsec Tunnel mode APIs with it.
This permission is only granted to the system or
through an AppOp.

Bug: 66955045
Test: compilation
Change-Id: I0f618373b500c493ef2211bece681f74652a1833
2018-03-22 14:16:50 -07:00
Nathan Harold
9594175655 Merge "Add NonNull Annotations To IpSec API Surface" into pi-dev 2018-03-22 18:31:03 +00:00
Nathan Harold
4f1703787d Merge changes I4c26aea7,I79911434 into pi-dev
* changes:
  Check mOwnedByTransform to avoid DELSA on SPI
  Expose add/removeAddress for IpSecInterfaces
2018-03-21 20:59:02 +00:00
Nathan Harold
6303d9ef32 Add NonNull Annotations To IpSec API Surface
This CL adds NonNull annotations to a large
number of method returns and parameters as
part of API council feedback.

Bug: 72473424
Test: compilation (docstring-only change)
Merged-In: I2f865dde56fe12116c461ad98e9460bf1802ce18
Change-Id: I2f865dde56fe12116c461ad98e9460bf1802ce18
(cherry picked from commit 8fd26f67fdfdedb535ddb8c7d5ededa5dcba40f8)
2018-03-21 11:15:28 -07:00
Benedict Wong
d99c2eb909 Merge "Added implementation for VTI add/remove address" into pi-dev 2018-03-21 17:03:52 +00:00
Nathan Harold
49cd8d7268 Expose add/removeAddress for IpSecInterfaces
When exposing the APIs, these were missed.
The outer structure is exposed, so this exposes
the addAddress and removeAddress methods.

Bug: 75234273
Test: compilation
Merged-In: I79911434f9baa660e4d8564cc59d80da4a710c42
Change-Id: I79911434f9baa660e4d8564cc59d80da4a710c42
(cherry picked from commit a83601a511c3f11470109d78d1a736acdb9c6bd8)
2018-03-20 16:01:28 -07:00
Benedict Wong
97c3c945d7 Added implementation for VTI add/remove address
This change adds implementation details for add/remove addresses onto a
VTI.

Bug: 73675031
Test: New tests added, passing on Walleye
Merged-In: Idde9d943a5285d2c13c5c6b0f7b8a9faf718e6a5
Change-Id: Idde9d943a5285d2c13c5c6b0f7b8a9faf718e6a5
(cherry picked from commit ecc9f7cc08804e3fa15fea04ae94ea1bc74edbfe)
2018-03-20 16:01:27 -07:00
Benedict Wong
778327e548 Add support for auth-only transforms
Kernel limitations prevent auth-only SAs from being created. Explicitly
request a null encryption algorithm instead of omitting the algorithm
to comply with the kernel requirement for ESP.

Bug: 75049573
Test: CTS tests for auth-only, crypt-only transforms added for all
combinations of (UDP, TCP, IPv4, IPv6, UDP-encap) Also added unit
tests to ensure correct triggering of NULL_CRYPT usage.
Merged-In: Ia9a5cfee9c7786412846bc039f326420f6211c08
Change-Id: Ia9a5cfee9c7786412846bc039f326420f6211c08
(cherry picked from commit bf013a3820c69348e034c6340b28e95f3441ebe8)
2018-03-20 12:34:52 -07:00
Nathan Harold
e3536f066d Docstring Updates for applyTransportModeTransform
-Add anotations to usages of PolicyDirection for
 apply...() methods.
-Update the comments on DIRECTION_IN and DIRECTION_OUT
 to better reflect their current usage.
-Add a better explanation to the rekey procedure doc.
-Remove disused createTunnelInterface() stub.

Bug: 73751066
Test: make docs
Merged-In: I9f2ec864466148a18899f1e952c74a525902ccbc
Change-Id: I9f2ec864466148a18899f1e952c74a525902ccbc
(cherry picked from commit f4cdf25a906d0f52ffd76508d660b843b13b3ff8)
2018-03-16 17:46:05 -07:00
Jeff Sharkey
1459069bb6 Name specific app for rapid data usage.
When a single app is responsible for more than half of the data usage
that caused us to trigger a "rapid usage" alert, name that app in the
notification.  Tests to verify.

Move NPMS->NSS direct calls to "Internal" pattern, following
best-practices to avoid unnecessary AIDL exposure.

Remove 3G/4G split mobile plan support, which has been deprecated for
years and was never supported in a shipping product.

Move MultipathPolicyTracker in tree to reflect its package name.

Test: bit FrameworksNetTests:*
Test: bit FrameworksServicesTests:com.android.server.NetworkPolicyManagerServiceTest
Bug: 69263587, 64221505, 73431080, 72746951
Exempt-From-Owner-Approval: approved in previous PS
Change-Id: I3e4ec1ae2222d51b232f76f32faca93d4f8cd272
2018-02-23 16:27:39 +00:00
Benedict Wong
5e58ea8a2f Merge "Copy IpSecConfig when IpSecTransforms are created" am: 2c8456b22e am: 3988c929ad
am: 4aa9fef2fc

Change-Id: I511e6b0cadfc24f24a492ae63c48a8b4baa89edb
2018-02-15 06:01:49 +00:00
Benedict Wong
e5623e2b61 Copy IpSecConfig when IpSecTransforms are created
This change prevents IpSecTransforms from being inadvertently modified
by changes to the IpSecConfig. Specifically, once the transform is
created, it takes a copy of the config, rather than a reference.

Bug: 69385347
Test: New tests added, and all test passing
Change-Id: I89b8660c175ca20aa70352dcda893434ff7fd42b
2018-02-13 23:23:13 +00:00
nharold
c40b5fb671 Merge "Require NETWORK_STACK Permission for IpSec Tunnel Mode" am: 43699e90f3 am: e736f83caf
am: 34c6697356

Change-Id: Ib33ccecfe2fc600c05a208d24df10a474addb0e5
2018-02-10 02:11:15 +00:00
Nathan Harold
025aae1fc9 Require NETWORK_STACK Permission for IpSec Tunnel Mode
At least until further permissions are agreed upon,
the NETWORK_STACK permission is sufficient to ensure
that access to the tunnel mode APIs is secure, and
this permission will always be a sufficient condition.
Thus, adding NETWORK_STACK.

Bug: 66955045
Test: compilation
Change-Id: I2dc36896a52d2e71fad55041507d68ca91191ffc
2018-02-08 21:16:51 +00:00
Pavel Maltsev
f8505b7fae Merge "Enable multiple active Ethernet interfaces" am: cbcc1d6665 am: ac908d6728
am: f4c6c808a2

Change-Id: Ibd84c2ba3252e3d65ba4a63a0be912747ea18df9
2018-02-04 01:06:51 +00:00
Treehugger Robot
cbcc1d6665 Merge "Enable multiple active Ethernet interfaces" 2018-02-02 23:13:54 +00:00
Chenbo Feng
c2a2f738ba Merge "Return non-negetive value in getMobileStats method" am: 9fb04e29e5 am: 515a54a93e
am: 4ae5e0c06c

Change-Id: I304f42d473289ad876f6ceae8d6866e4248686a9
2018-02-02 17:59:53 +00:00
Treehugger Robot
9fb04e29e5 Merge "Return non-negetive value in getMobileStats method" 2018-02-02 04:22:34 +00:00
Benedict Wong
04514d3e4b Merge "Fix minor bugs with tunnel mode implementation" am: cb9cd96c50 am: b7afa3f6fb
am: 25cb38a9b7

Change-Id: Ie74c4edcc7586e0220ff948222010e126841e8f7
2018-02-01 04:12:18 +00:00
Benedict Wong
7660370a83 Fix minor bugs with tunnel mode implementation
This change makes sure tunnel mode transforms are properly activated
upon construction, and corrects bugs with how policy selectors were being
generated for tunnel mode policies. Specifically, the source/destination could
not be empty strings, even for cases where an empty selector was desired.

Bug: 72457770
Test: GTS tests run
Change-Id: I9a9f64c34b07883a02a5c996614f958486d214fc
2018-01-31 01:16:53 +00:00
Chenbo Feng
905f034c57 Return non-negetive value in getMobileStats method
The current implementation of getMobileRxBytes and all the similiar
method adds up the return values for multiple calls to getRxBytes so if
all of them return UNSUPPORTED for any reason, getMobileRxBytes() would
return a value such as -3. This behavior is not compliance with the cts
TrafficStatsTest which always assume getMobileRxBytes to return a
non-negetive value. The method now will check tha stats get from
getRxBytes method and add them up only if the stats is valid.

Bug: 72473294
Test: run cts -m CtsNetTestCases -t android.net.cts.TrafficStatsTest
Change-Id: I656970ebc8f6506cf17c4353ad46c0178bb65cfd
2018-01-29 12:19:26 -08:00
Pavel Maltsev
50ec1f33c6 Enable multiple active Ethernet interfaces
- add Ethernet interface configurations to config.xml; no vendors can
specify network capabilities (in particular they can mark network as
restricted which make sense for embedded applications + static IP
configuration)
- extend EthernetManager to support multiple interfaces, use interface
name as an identificator
- extend IpConfigStore to store IP configuration based on string
identifier (e.g. ethernet name)

Test: runtest -x frameworks/base/services/tests/servicestests/ -c com.android.server.net.IpConfigStoreTest
Change-Id: Ic1e70003f2380ca8edb4469d6b34e27c5e8cf059
2018-01-29 10:11:05 -08:00
nharold
c20e9c8b4b Merge "Move Keepalive out of IpSecTransform.Builder" am: af3fb3efe4 am: bbb4b05a64
am: b9d614d4df

Change-Id: Ic554e34d9b16f522156bc7e8b176f96693e8e32c
2018-01-25 07:59:57 +00:00
Nathan Harold
b559164017 Move Keepalive out of IpSecTransform.Builder
The lifecycle of Keepalive offloading is, unfortunately
different from that of an IpSecTransform. Because starting
a keepalive is fundamentally asynchronous, and isn't valid
until after a transform exists, it will now be a separate
optional procedure that may succeed or fail. It remains
linked with a Transform by the need for a Transform to exist
in order to initiate a Keepalive.

Bug: 38350389
Test: compilation
Change-Id: Ia76fccee41f86d694dff436043293d0c0762c041
2018-01-24 19:32:04 -08:00
Benedict Wong
45828d7122 Merge "Add TunnelInterface API and KernelResourceRecords" am: e02b700032 am: e1aa92f1c1
am: 5c3eb9ce8e

Change-Id: I955d5090171f08e4fa20eac5bdfe761132b87d35
2018-01-24 09:54:06 +00:00
Benedict Wong
f86780fa1f Merge "Add xfrm mark in IpSecConfig" am: 6b3456b253 am: 4077e802ad
am: fc2bcb4153

Change-Id: Ibaee9700cc6befdf6bbdb792cb673611e571d19a
2018-01-24 09:48:25 +00:00
Benedict Wong
8bc907311b Add TunnelInterface API and KernelResourceRecords
This change adds one KernelResourceRecord type (TunnelInterfaceRecord),
and adds methods for the creation of TunnelInterfaces, as well as the
application of Transforms to the given TunnelInterfaces

As part of the generation of ikeys/okeys, a ReserveKeyTracker manages a
java bitset to avoid collisions and reserve/release keys.

Bug: 63588681
Test: Compiles, CTS, unit tests all pass on AOSP_marlin
Change-Id: I9e9b6455e27073acd4491eae666aa966b3b10e0f
2018-01-24 07:24:27 +00:00
Benedict Wong
6b3456b253 Merge "Add xfrm mark in IpSecConfig" 2018-01-24 05:53:29 +00:00
Chenbo Feng
a94de8c9b5 Merge changes from topic "bpfStats" am: bd268b204c am: e041f38289
am: c10bd12062

Change-Id: I672efa1221e17d0962ca5702330fc83d75fcac81
2018-01-24 05:46:52 +00:00
Treehugger Robot
bd268b204c Merge changes from topic "bpfStats"
* changes:
  Use /proc/net/dev to get stats summary
  Add bpf support for NetworkStatsFactory
  Add BPF support for NetworkStatsService
2018-01-24 04:08:29 +00:00
Benedict Wong
7ea128e242 Merge "Expose applyTunnelModeTransform as a system API" am: d056f32bd9 am: c2253ff48d
am: 82d8e1a25d

Change-Id: Ia1f81f5696814f5b9479882e1102a5f8508a4512
2018-01-24 02:58:17 +00:00
Benedict Wong
03e732a299 Expose applyTunnelModeTransform as a system API
Simple change to expose systemAPI for applyTunnelModeTransform

Bug: 36033193
Test: All CTS, unit tests passing
Change-Id: I2d857c048bc0dc80c3949387f946b1f5adf0527e
2018-01-23 23:25:54 +00:00
Lorenzo Colitti
f1b197b23b Support passing a template to NetworkStatsManager queries.
Currently, NetworkStatsManager queries and callbacks only allow
selecting network traffic based on network identifiers:
networkType, subscriptionId and networkId.  The code ends up
converting these into a template under the hood.

Now that templates can express more fine-grained queries (e.g.,
select only roaming traffic, or select only traffic that's not
on the default network) add a hidden method to pass in a
template. This should have no security implications, as all the
access controls are performed in NetworkStatsService.

Bug: 35142602
Test: android.app.usage.cts.NetworkUsageStatsTest passes
Change-Id: Iab4afa26b34544299d2a9c501c1b0feb470e90a9
Merged-In: Iab4afa26b34544299d2a9c501c1b0feb470e90a9
2018-01-23 18:38:48 +09:00
Lorenzo Colitti
75ec1aed18 Add metered, roaming, and defaultNetwork info to NetworkTemplate.
This will allow data usage clients to query for and receive
callbacks on data usage matching these conditions.

Bug: 35142602
Test: atest FrameworksNetTests
Change-Id: I4d985a2734eeab7ee454c09cc2098b6b3c671c23
Merged-In: I4d985a2734eeab7ee454c09cc2098b6b3c671c23
2018-01-23 18:38:48 +09:00
Lorenzo Colitti
0ba426b8a1 Add the defaultNetwork element to the netstats.proto.
This is in its own commit because AOSP has diverged from internal
master.

Bug: 35142602
Test: builds, boots
Change-Id: I75fc85b961bc919e3d6c2adce6d6861c6f2c8379
Merged-In: I75fc85b961bc919e3d6c2adce6d6861c6f2c8379
2018-01-23 18:38:48 +09:00
Lorenzo Colitti
92a946d09f Add getDefaultNetwork to the NetworkStats public API.
This allows an app using the public API to know whether the
traffic in a particular bucket was on the default network
(i.e., the network was selected by the system), or not (i.e.,
the network was selected by the app).

Bug: 35142602
Test: builds, boots
Test: added coverage to NetworkUsageStatsTest CTS test, still passes
Change-Id: I9f6669908fa119743b9c0aa0c31a03e5ebafa7db
Merged-In: I9f6669908fa119743b9c0aa0c31a03e5ebafa7db
2018-01-23 18:28:07 +09:00
Chenbo Feng
75a1efb3f5 Use /proc/net/dev to get stats summary
If the qtaguid proc file is no longer exist, the device is running new
eBPF module to do traffic accounting. So the NetworkStatsFactory need to
use the proc/net/dev interface to get the per interface traffic stats
summary. Also, adding a test to verify the helper function work properly

Bug: 30950746
Test: run NetworkStatsFactoryTest
Change-Id: Ia36808bf02f1637dd41a3e7c50917b91b1a77524
2018-01-23 00:35:02 -08:00
Chenbo Feng
adfda6945d Add bpf support for NetworkStatsFactory
Add the native method used to read the detail information of network
stats from bpf maps. The native method of NetworkStatsFactory should
choose the correct implementation to get the stats detail depending on
the kernel version. Currently the bpf result is printed as a reference
and the actual behavior of NetworkStatsFactory should not change.

Test: NetworkStatsFactory related cts test should not fail.
Bug: 30950746
Change-Id: I4715a23559b5b2306bd556cea0431f0ed172a993
2018-01-23 00:34:53 -08:00