Commit graph android_packages_modules_Co.../core/java
Message SHA1
Add xfrm mark in IpSecConfig
Bug: 63589600
Test: runtest frameworks-net
Change-Id: I2d38d781b8b31d8bf39fd4e9a7e31509f15a9e16

Di Lu   commited 2018-01-18 15:23:56 -08:00
47d108c191
IpSec - API Tweak for removeTransportModeTransform
Because IpSecTransforms are now unidirectional,
and because the only mechanism for removing Transforms
removes it from both directions, the API can no longer
use the Transform parameter to meaningfully validate
that the caller had applied a transform. Since that
functionality was as-yet unimplemented and is now
infeasible, the transform parameter is removed.

Bug: 72079356
Test: cts - IpSecManagerTest; runtest frameworks-net
Change-Id: If19b0d34bdc6daf31a40d6d62bff326dcbca08c0

Nathan Harold   commited 2018-01-17 01:11:46 -08:00
24f3bb8c6d
Prevent Closure of Underlying Socket FDs
The version of applyTransportModeTransform() and
removeTransportModeTransform() that accepted
Socket and DatagramSocket were closing the underlying
FDs upon return. It's unclear whether this is due to
a behavior change elsewhere in ParcelFileDescriptor,
but either way, converting to using getFileDescriptor$
and then calling dup() explicitly rather than relying
on ParcelFileDescriptor seems like a better idea anyway.

Bug: 72047396
Test: CTS - IpSecManagerTest.testCreateTransform()
Change-Id: Ia2f02564e1289f25bf113dbb861fcfd2240537a7

Nathan Harold   commited 2018-01-16 21:30:20 -08:00
16e0b07615
Make Transforms Unidirectional
Convert the IpSecTransform from being a bi-directional
pair of SAs to a unidirectional single SA. This CL
also removes the concept of "direction from SAs meaning
that a IpSecTransform may now be applied to a socket
in either direction.

-Make transforms unidirectional
-Add Convert allocateSpi() to use destination rather
 than direction and remote address
-Remove directionality from builders for IpSecTransform
-Change applyTransportModeTransform() to take a
 direction in which to apply the transform object.
-Additional minor naming updates
-Restrict IpSecConfig to only print keys on eng builds
-Move DIRECTION constants to IpSecManager
-Add sourceAddress parameter to IpSecTransform to provide
 additional guarantees about the source address of data;
 (explicit failure rather than implicit failure).
-Move SPI to the build() method of IpSecTransform

Bug: 71717213
Test: runtest frameworks-net, CTS - IpSecManagerTest
Change-Id: I0824b37f443f4b8c62536d9801238c63ed8f2a1c

Nathan Harold   commited 2018-01-16 11:08:31 -08:00
ce6d573795
Merge "Add validation to IpSecConfig algorithm setters"
Benedict Wong   authored and   Gerrit Code Review   commited 2018-01-09 18:18:28 +00:00
321d55696d
Add validation to IpSecConfig algorithm setters
Adds checks to ensure that users can only set the correct types of
algorithms for the Authentication, Encryption and Authenticated
Encryption algorithms.

Bug: 65223935
Test: Added tests in IpSecConfigTest, and passed on aosp_marlin-eng
Change-Id: I462c77d9eb5710b8d03a48866453649d3b6fc6bf

Benedict Wong   commited 2018-01-04 16:56:40 -08:00
aac9965a89
IpSec Invalidate the Resource IDs on close()
To facilitate error checking we should invalidate
the resource IDs of all objects when we close() them.
Today, the resource ID is invalidated on the Transform
object but not on the SPI or Encap Socket. This CL
unifies the behavior.

Bug: 70641274
Test: cts - IpSecManagerTest
Change-Id: I28caec3e913902c748c6a50b4ef742ccef8b1b09

Nathan Harold   commited 2018-01-04 15:28:29 -08:00
5149f29b41
Use NetworkStatsService to get stats for apps
Move the native implementation of TrafficStats to NetworkStatsService
and apps need to get the NetworkStatsService binder interface from
system_server in order to get the network usage stats since boot. This
implementation can hide the detail of retrieving network traffic
information from apps and the NetworkStatsService can choose which
methoed it use to get the data depending on the kernel version of the
device.

Bug: 30950746
Test: CtsNetTestCases -t android.net.cts.TrafficStatsTest
Change-Id: I53bbefd19aa0b783b9b4b42ea4d76db3e9ec07a3

Chenbo Feng   commited 2017-12-19 19:57:44 -08:00
65b99191e6
[ipsec-qtaguid] Tag sockets upon creation of encap sockets
Added calls to tag encap sockets to that of the UID for which the encap
socket is being created on behalf of. This ensures that all data
accounting generated for the UDP-encap-ESP socket is correctly billed to
the right UID.

Bug: 62994731
Test: New tests added to IpSecServiceTest.java, passing
Change-Id: I15365ea9c982fd7b4e3cdeff314ddfba2289c86e

Benedict Wong   commited 2017-12-18 19:46:06 +00:00
8231eaffb0
[CHERRY-PICK] API for apps to tag sockets with their own UID.
This enables app A to create a socket, pass it to app B, and have
app B accept blame for the traffic performed on that socket.

Also adds helpful public APIs for tagging raw FileDescriptor sockets
instead of making developers go through shady SocketImpl wrappers.

Test: cts-tradefed run commandAndExit cts-dev -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.AppSecurityTests#testAppFailAccessPrivateData
Bug: 63932076
Change-Id: I08925c843974675fc82e4080cec2eaab9ab7cd41
Merged-In: I08925c843974675fc82e4080cec2eaab9ab7cd41
(cherry picked from commit 152b263678)

Jeff Sharkey   authored and   Benedict Wong   commited 2017-12-18 19:44:40 +00:00
f5c1f30527
Use consistent naming for allocating SPI.
Throughout the IPsec code (API, system server, netd) we use "reserve"
SPI and "allocate" SPI interchangeably. This renames to use "allocate"
everywhere for self-consistency and consistency with the kernel
(ALLOCSPI).

In javadoc, I am leaving the word "reserve" in several places because it
is still an accurate description of how the method behaves.

Bug: 69128142
Test: TreeHugger should be enough
Change-Id: I8ea603b4612303b0393beef04032671fa53d2106

Jonathan Basseri   authored and   Nathan Harold   commited 2017-12-12 13:50:35 -08:00
f33f4845b3
Merge "Validate IpSecAlgorithm Length"
am: 68b81299d2

Change-Id: I23f7612c119e67f9a1647568aeefde38a365f8da

nharold   authored and   android-build-merger   commited 2017-12-05 02:28:10 +00:00
2058f01ff5
Validate IpSecAlgorithm Length
Improve the Validation of IpSecAlgorithm by
explicitly checking the length in addition to
the truncation length (previously an oversight).
In addition, we now check the lengths during
un-parceling, which will catch someone maliciously
manually building a parcel and passing it, bypassing
the checks in the constructor.

Bug: 68780091
Test: runtest -x IpSecAlgorithmTest.java
Change-Id: I8172762617264d34f47d5144336464510f07a701

Nathan Harold   commited 2017-12-04 15:12:14 -08:00
7175f27cbe
Merge "Javadoc cleanup of IpSecManager API."
am: d09d106ec0

Change-Id: Iaf206b0980d3bed14fe6b8318d2073577212b460

Jonathan Basseri   authored and   android-build-merger   commited 2017-11-22 01:51:46 +00:00
d040c18283
Javadoc cleanup of IpSecManager API.
This changes only comments and annotations, which results
in minor API changes.

Bug: 63777932
Test: `make update-api` and visually inspect generated HTML.
Change-Id: I7a7a9244eade6cc55aca17a47e0a838cd6f84cc9

Jonathan Basseri   commited 2017-11-20 10:49:59 -08:00
745d586d48
Merge commit '98e12851336b7db16e583f9afac63ecc97465980' from
oc-mr1-dev-plus-aosp-without-vendor into stage-aosp-master.

Change-Id: Ia7b8da4a00d215160e4a4fa40f6044208d1297b7
Merged-In: I19846d2a3ee27aecbae2367a74ee49082eea154d

Xin Li   commited 2017-11-14 12:31:11 -08:00
9c3ee5bf22
Merge "Fix signature for finalize() to resolve API Lint error"
nharold   authored and   Gerrit Code Review   commited 2017-11-08 17:56:43 +00:00
ad26865598
Merge "Update documentation for AES-GCM-ESP keymat length"
Benedict Wong   authored and   Gerrit Code Review   commited 2017-11-08 17:47:40 +00:00
8135f66c46
Fix signature for finalize() to resolve API Lint error
The API linter on goog/master noticed that this method is
listed in the public API even though it's protected. The
change is probably related to a signature change from the
internal finalize method which throws a Throwable. Fix the
method in IpSecManager to throw Throwable, which should
fix the current.txt and resolve the lint error.

Bug: 69006767
Test: compilation, make update-api
Change-Id: I173d014baaa505c365b7916fcb52f2a8b4af9373

Nathan Harold   commited 2017-11-07 17:46:12 -08:00
8d88a14392
Update documentation for AES-GCM-ESP keymat length
Added notes that keymat length must include 32 bits of salt.

Bug: 68672051
Test: Frameworks-net unit tests & IpSecManager CTS tests run
Change-Id: I0ae0c5be8a45b2374783b3bd1fa8bf930f15e687

Benedict Wong   commited 2017-11-07 17:39:35 -08:00
debeb8779d
Define NOT_ROAMING network capability.
The "roaming" state of a network really belongs on NetworkCapabilities
instead of being published through NetworkInfo.isRoaming().  One major
reason is to support developers creating NetworkRequests for a
non-roaming network.

Watch for any capability changes that network statistics are
interested in (either metered or roaming) and notify it to perform
an update pass; fixes bug where we previously only triggered on
roaming changes.

Fix bug in VPNs where metered/roaming capabilities of underlying
networks weren't being propagated; this was probably preventing
some jobs from running over unmetered networks, and causing other
jobs to run over roaming networks!  Also passes along link bandwidth
information from underlying networks, and propegates any changes
to underlying networks.

Fix race condition by reading prevNc inside lock.  Utility methods
correctly calculate min/max link bandwidth values.

Test: bit FrameworksNetTests:android.net.,com.android.server.net.,com.android.server.connectivity.,com.android.server.ConnectivityServiceTest
Bug: 68397798, 16207332
Change-Id: I3e1a6544c902bf3a79356b72d3616af1fd2b0f49

Jeff Sharkey   commited 2017-11-01 19:05:42 -06:00
1c09bde6ad
Merge "Add support for AES-GCM-ESP as an IPSec algorithm"
am: b6df7f0d35

Change-Id: Ic099206a28c4f21fa796969c953a8d4e81e8495b

Benedict Wong   authored and   android-build-merger   commited 2017-10-19 17:14:53 +00:00
b35d6fb1aa
Add support for AES-GCM-ESP as an IPSec algorithm
Allows native AES-GCM-ESP to be used as an IPSec transport/tunnel mode
algorithm with kernel support

Bug: 63589918
Test: IPsecService tests added, existing ones pass
Change-Id: Ie1a9a902be205f269aa37bf956198f2e5b177c21

Benedict Wong   commited 2017-10-18 11:22:24 -07:00
be43096635
Merge "Cosmetic Cleanups for IpSecService" am: 1d1b79b0b6 am: b50b5dd36a
am: cc51ef0a47

Change-Id: I0a9c52ca26ad1b7e4505f7c9dc32ad9550b62afc

nharold   authored and   android-build-merger   commited 2017-10-05 01:07:53 +00:00
916740b323
Merge "Cosmetic Cleanups for IpSecService"
am: 1d1b79b0b6

Change-Id: If47968dbd55f8f38f9e8dda4d78a0e2e41827da8

nharold   authored and   android-build-merger   commited 2017-10-05 00:44:37 +00:00
b50b5dd36a
Merge changes from topic "ipsec-svc-cleanup" am: 9778c7884f am: abdf4618ed
am: 4e793fd0b5

Change-Id: Ib7eae5c9e223493281524e862979e16d25984dde

nharold   authored and   android-build-merger   commited 2017-10-04 20:53:04 +00:00
91873c03e8
Merge changes from topic "ipsec-svc-cleanup"
am: 9778c7884f

Change-Id: Ide81ae76bd05ba3a2cc7c06c072306d30a489057

nharold   authored and   android-build-merger   commited 2017-10-04 20:24:10 +00:00
abdf4618ed
Cosmetic Cleanups for IpSecService
This is a follow-up CL to address comments
on aosp/466677
-Rename ManagedResourceArray.get()
-Comment cleanup

Bug: 38397094
Test: runtest frameworks-net
Change-Id: I6fbdd89c4a864fe1d8a19c68947f582d7b1f0f21

Nathan Harold   commited 2017-10-04 13:04:55 -07:00
71d62fd623
Add equals() for IpSecAlgorithm and IpSecConfig
Add equality testing methods to support tests
for parceling and un-parceling IpSecConfig.

Bug: 38397094
Test: runtest -x IpSecConfigTest.java
Change-Id: I31e318334d39ed6e9daf5ec8f3be7dcec75e12ad

Nathan Harold   commited 2017-10-03 19:45:58 -07:00
ffc2fa53f5
Input Validation for IpSecService
All of the input to IpSecService over the Binder
interface needs to be validated both for sanity
and for safety.

-Sanity check all the parameters coming from binder.
-Added setters for IpSecConfig to decouple the test
 from the IpSecManager. This was needed because the
 input validation caused the tests to fail due to a
 null parameter that was previously un-tested.
-Added the mode flag to the IpSecConfig bundle this
 oversight was found during testing.
-Expose the getResourceId() methods for testing in
 UdpEncapsulationSocket, SecurityParameterIndex, and
 IpSecTransform classes.
-Remove the unneeded getIpSecConfig() from
 IpSecTransform: unneeded now that we can synthesize
 configs.

Bug: 38397094
Test: runtest frameworks-net
Change-Id: I5241fc7fbfa9816d54219acd8d81a9f7eef10dd4

Nathan Harold   commited 2017-10-03 19:45:55 -07:00
ed813205fa
Merge changes from topic "re-enable-ipsec" am: ed10c76e7b am: f38afafd80
am: 80107540bb

Change-Id: I13a7134864a648aff9338fda044b3bffd653119e

nharold   authored and   android-build-merger   commited 2017-09-26 22:39:01 +00:00
a656df2a6c
Re-Enable Starting of the IpSecService am: 2e2cec680a am: 2bacca7a0f
am: 686a8282bb

Change-Id: Ia24348d585b2f1050dafd161eafcdadf0edd82c0

Nathan Harold   authored and   android-build-merger   commited 2017-09-26 22:37:44 +00:00
df89deb808
Merge changes from topic "re-enable-ipsec"
am: ed10c76e7b

Change-Id: Ia1d1f3981a9dd1eb8f60631d318211daf135d575

nharold   authored and   android-build-merger   commited 2017-09-26 22:13:20 +00:00
f38afafd80
Re-Enable Starting of the IpSecService
am: 2e2cec680a

Change-Id: I1f64aa2fdf1cce6dea91427eda65c4b8ee6f6b02

Nathan Harold   authored and   android-build-merger   commited 2017-09-26 22:11:58 +00:00
2bacca7a0f
Re-Expose IpSecService API Surface
Note, This reverts commit faf8a91917.

Bug: 64800246
Test: compilation
Change-Id: I709d4c476647cfe9f6b982fc373f8d76018b3922

Nathan Harold   commited 2017-09-12 19:25:13 -07:00
004a59a6ab
Re-Enable Starting of the IpSecService
This reverts commit 41004ff4113dc9175c993638a47af602af6d8a98.

Bug: 64800246
Test: compilation
Change-Id: I4f5e3cd23001b9d94b3f6dc9fcfe731a90650e6e

Nathan Harold   commited 2017-09-12 19:25:09 -07:00
2e2cec680a
NetworkStats: more robust subtraction for deltas
This patch ensures that subtract() between two NetworkStats object will
return a delta with no negative entries in all cases.

When the stats delta contains some negative values, there are clamped to
0. Some logging is added when this happens.

This is what's expected by NetworkStatsHistory#recordData().

Bug: 64365917
Bug: 65439160
Test: runtest frameworks-net
Merged-In: I16e97e73f600225f80e0ce517e80c07c6f399196
Merged-In: I2ac0bc3914cb65ae8ee27921856d698dc59624b2
Merged-In: I67d5dc4b52b254748ff17fe1e16c2eeb1d03c30d
Merged-In: Ib488fb034f72c92f19916490981342a3ef2eb33b

(cherry picked from commit ce144deb7b)

Change-Id: Ic86b65a65a2517c871221f8784088ec1de18f534

Hugo Benichi   commited 2017-09-08 13:39:44 +09:00
d18ca7c9fa
Merge "Network Service Discovery test: properly release resources" am: c9d24d203d am: 0681b9a649
am: f467db29f9

Change-Id: Id9be284a16112f999d752751a7972fd735573cda

Hugo Benichi   authored and   android-build-merger   commited 2017-09-04 12:42:56 +00:00
b420788896
Merge "Network Service Discovery test: properly release resources"
am: c9d24d203d

Change-Id: If34b3770a5c0fef65d124201e0ca1374cc6b1eca

Hugo Benichi   authored and   android-build-merger   commited 2017-09-04 12:14:11 +00:00
0681b9a649
Network Service Discovery test: properly release resources
Bug: 32561414
Bug: 62918393
Bug: 62044295
Test: runtest frameworks-net
Change-Id: If23993b5e391947ecbdc01677f0a643144794b2b

Hugo Benichi   commited 2017-09-02 14:54:29 +09:00
648283ecc7
Merge "Augment network stats based on SubscriptionPlan." into oc-mr1-dev
am: f31cf45e82

Change-Id: Ia6c6d5893d841f21d181363dc01f77efa6579a8f

Jeff Sharkey   authored and   android-build-merger   commited 2017-08-30 19:14:21 +00:00
a40e1163db
Augment network stats based on SubscriptionPlan.
When a carrier provides an "anchor" of data usage at a specific
moment in time, augment the network statistics used by warning/limit
thresholds and Settings UI.  For example, if the OS measured 500MB
of usage, but the carrier says only 400MB has been used, we "squish"
down the OS measured usage to match that anchor.

Callers using the hidden API will have their data augmented by
default, and the public API offers a way to opt-into augmentation.

Thorough testing to verify behavior.

Test: bit FrameworksNetTests:android.net.,com.android.server.net.
Test: cts-tradefed run commandAndExit cts-dev -m CtsUsageStatsTestCases -t android.app.usage.cts.NetworkUsageStatsTest
Bug: 64534190
Change-Id: Id3d4d7625bbf04f57643e51dbf376e3fa0ea8eca

Jeff Sharkey   commited 2017-08-30 10:01:10 -06:00
95b454fdf5
Merge changes I325b13d5,I89719fe7 am: 5fda524776 am: a0646105ef
am: 4fa0187015

Change-Id: Ib980879b0e50ffe1c8209339df22da4a50d5b74e

Lorenzo Colitti   authored and   android-build-merger   commited 2017-08-19 03:38:10 +00:00
0643369ef7
Merge changes I325b13d5,I89719fe7
am: 5fda524776

Change-Id: Iaced543ab17ea87c8f701975764d957bc1b17fc7

Lorenzo Colitti   authored and   android-build-merger   commited 2017-08-19 03:15:08 +00:00
a0646105ef
Add tether offload traffic to interface stats as well.
Currently, we only count add tethering traffic to per-UID
stats, but not to total data usage (i.e., dev and XT stats). This
is correct for software tethering, because all software forwarded
packets are already included in interface counters, but it is
incorrect for hardware offload, because such packets do not
increment interface counters.

To fix this:
1. Add an argument to ITetheringStatsProvider#getTetherStats to
   indicate whether per-UID stats are requested. For clarity,
   define integer constants STATS_PER_IFACE and STATS_PER_UID
   to represent these operations.
2. Make NetdTetheringStatsProvider return stats only if per-UID
   stats are requested. (Otherwise tethering traffic would be
   double-counted).
3. Make OffloadController's stats provider return the same
   stats regardless of whether per-UID stats were requested or
   not.
4. Make NetworkStatsService add non-per-UID tethering stats to
   the dev and XT snapshots. The per-UID snapshots were already
   correctly adding in per-UID stats.

(cherry picked from commit 5356a35c3bcfcdf2d184c620af6bfbf9bddf35c5)

Bug: 29337859
Bug: 32163131
Test: runtest frameworks-net
Test: runtest frameworks-telephony
Change-Id: I325b13d50e88841dfb0db4c35e7e27f163ee72fe
Merged-In: I4e8e923d68dce1a4a68608dbd6c75a91165aa4ee

Lorenzo Colitti   commited 2017-08-19 10:12:05 +09:00
591c50889a
Merge "Add tether offload traffic to interface stats as well." into oc-mr1-dev
am: 21bc3a39a4

Change-Id: I4e8e923d68dce1a4a68608dbd6c75a91165aa4ee

Lorenzo Colitti   authored and   android-build-merger   commited 2017-08-19 01:02:33 +00:00
27fb1330c3
Add tether offload traffic to interface stats as well.
Currently, we only count add tethering traffic to per-UID
stats, but not to total data usage (i.e., dev and XT stats). This
is correct for software tethering, because all software forwarded
packets are already included in interface counters, but it is
incorrect for hardware offload, because such packets do not
increment interface counters.

To fix this:
1. Add an argument to ITetheringStatsProvider#getTetherStats to
   indicate whether per-UID stats are requested. For clarity,
   define integer constants STATS_PER_IFACE and STATS_PER_UID
   to represent these operations.
2. Make NetdTetheringStatsProvider return stats only if per-UID
   stats are requested. (Otherwise tethering traffic would be
   double-counted).
3. Make OffloadController's stats provider return the same
   stats regardless of whether per-UID stats were requested or
   not.
4. Make NetworkStatsService add non-per-UID tethering stats to
   the dev and XT snapshots. The per-UID snapshots were already
   correctly adding in per-UID stats.

Bug: 29337859
Bug: 32163131
Test: runtest frameworks-net
Test: runtest frameworks-telephony
Change-Id: I7a4d04ab47694d754874136179f8edad71099638

Lorenzo Colitti   commited 2017-08-19 00:21:56 +09:00
f5138c8f44
Merge "Rename API to match StorageStats." into oc-mr1-dev
am: 74f7a1425f

Change-Id: I87815da4f2f96c476fcdfdb3361d0f43b895e909

Jeff Sharkey   authored and   android-build-merger   commited 2017-08-12 00:45:19 +00:00
f0066db17f
Rename API to match StorageStats.
Since they're both measuring app code (APKs), name this API
consistently with StorageStats.getAppBytes().

Bug: 64331226
Test: builds, boots
Change-Id: I1b00427b619a78c043b1b5fac2d0e6406b51d454

Jeff Sharkey   commited 2017-08-11 15:10:38 -06:00
63ee528005
Merge "NetworkStats: more robust subtraction for deltas" into oc-dr1-dev am: 5e24152e33
am: 2dbba02e4b

Change-Id: I67d5dc4b52b254748ff17fe1e16c2eeb1d03c30d

Hugo Benichi   authored and   android-build-merger   commited 2017-08-08 16:10:52 +00:00
6edce91978