Commit graph android_packages_modules_Co.../tests/net/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
ddac24c12b
Merge "IpSec - API Tweak for removeTransportModeTransform"
nharold   authored and   Gerrit Code Review   commited 2018-01-17 19:07:10 +00:00
dc88d02119
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
2c97b2e3af
Merge changes from topic "ipsec-oneway-transform"
* changes:
  Update IpSecService UnitTests
  Make Transforms Unidirectional

nharold   authored and   Gerrit Code Review   commited 2018-01-17 08:40:37 +00:00
6987ca3620
Update IpSecService UnitTests
The IpSecService Unit tests relied on the
directionality of the IpSecConfig and previously
did not specify a source address. Unit tests
updated without functional change other than to
address these two requirements.

Bug: 71717213
Test: runtest frameworks-net
Change-Id: Iedbed735bc50fd4fdfe985f9e173956062a7b0d1

Nathan Harold   commited 2018-01-16 19:38:10 -08:00
e0d099dfb3
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
a47ac2bb32
Merge changes I0d0c0fac,Ifb9b00b6
* changes:
  Split updateCapabilities into two methods.
  More strictly check NetworkCapabilities callbacks.

Treehugger Robot   authored and   Gerrit Code Review   commited 2018-01-16 14:25:13 +00:00
b29d74c625
Merge "Update netId to nethandle mapping in NetworkTest."
Treehugger Robot   authored and   Gerrit Code Review   commited 2018-01-16 12:23:02 +00:00
42293ba74d
Update netId to nethandle mapping in NetworkTest.
Bug: 63052780
Test: NetworkTest now passes
Change-Id: I5f1cb3055b7042a19afb5dd62f082912157612ba

Lorenzo Colitti   commited 2018-01-16 17:19:04 +09:00
9499a55b90
MacAddress: add @NonNull annotations
This patch adds to the MacAddress class:
  - getAddressType() method which replaces addressType(), for naming
  consistency
  - @NonNull annotations on all input and output reference values for
  all public methods (@hide and public).

TYPE_UNKNOWN, which currently cannot be observed with a non @hide
method, is also removed from the public api.

Bug: 71866627
Test: $ runtest frameworks-net
Change-Id: I2af70408d46f431b7b32183e6b48ddae9a261a2c

Hugo Benichi   commited 2018-01-16 13:32:59 +09:00
5e5c4b40f9
More strictly check NetworkCapabilities callbacks.
This change more strictly accounts for onCapabilitiesChanged
callbaks and their values. It exposes several cases where we the
callbacks we send are spurious.

Test: ConnectivityServiceTest continues to pass
Change-Id: Ifb9b00b6f0cae48f8ed41a525100d1744b5f429b

Lorenzo Colitti   commited 2018-01-16 00:25:13 +09:00
23f3676c79
Extract DNS setting logic into DnsManager class
In future, managing DNS-over-TLS hostname lookup and netd programming
can be encapsulated here.

Test: as follows
    - built
    - flashed
    - booted
    - runtest frameworks-net passes
Bug: 64133961
Change-Id: I47ccfa99c30c780524c45c4af605e720ccba34a0

Erik Kline   commited 2018-01-11 18:16:50 +09:00
cca88b079c
Add minimal test for setting DNS properties
Test: as follows
Change-Id: I5db1de3ee8e179edd56c93988b821242b81c2387

Erik Kline   commited 2018-01-11 18:16:20 +09:00
3fce4e528d
Merge "Move more core networking tests to framework/base/tests/net."
Lorenzo Colitti   authored and   Gerrit Code Review   commited 2018-01-11 03:09:40 +00:00
7571202ce2
Move more core networking tests to framework/base/tests/net.
Test: "runtest frameworks-net" passes except for already-failing IpConnectivityMetricsTest
Change-Id: I2a20d546089699ac67bc819f10a8fcd50c637ac4

Lorenzo Colitti   commited 2018-01-10 23:35:16 +09:00
640bec275d
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
48db30d4c7
[ipsec-doze] Add fchown to IpSecService to support doze
Encap sockets are currently created as the system server, and should be
fchown'd to the user for whom it was created on behalf of.

Bug: 62994731
Test: New tests added and run to IpSecService
Change-Id: Icc49e709ae588981e69765fdb77537d7ffbac5fe

Benedict Wong   commited 2017-12-18 16:01:58 -08:00
3e4e37a38b
Merge "[ipsec-qtaguid] Tag sockets upon creation of encap sockets"
Benedict Wong   authored and   Gerrit Code Review   commited 2017-12-18 23:50:52 +00:00
12045eafe6
[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
768c332e51
MacAddress: address api review comments
1) toSafeString() is renamed to toOuiString()
2) toOuiString() returns a String that only contains the first 3 bytes
   of the mac address.

Bug: 70336442
Test: runtest frameworks-net
Change-Id: I798d8fec32dbff5687a682028e5d90eb941f81c1

Hugo Benichi   commited 2017-12-18 09:22:47 +09:00
b41f870464
Fix broken test due to API rename
A race condition during an Api rename has caused
the name change from reserveSecurityParameterIndex
to allocateSecurityParameterIndex to be wrong in
a test. Fixing.

Bug: 69128142
Test: runtest frameworks-net
Change-Id: I12fb9832cb938dc19f463b1f1124127435d7b173

Nathan Harold   authored and   nharold   commited 2017-12-14 23:04:42 +00:00
55bd2e0e92
Merge "Use consistent naming for allocating SPI."
nharold   authored and   Gerrit Code Review   commited 2017-12-14 21:10:16 +00:00
624b2c1541
Convert IpSecService resources to use refcounting
This is part 2 of 2 of the refcounting refactor for IpSecService
resources.

Switched ManagedResources to use RefcountedResource structure for
managing reference counts and eventual cleanup. Further, resource arrays
and quota management have been aggregated into a UserRecord for better
isolation. UID access checking has been similarly moved into the
UserRecordTracker, and resourceId checking has been rolled into
RefcountedResourceArray's accessor methods.

Bug: 63409385
Test: CTS, all unit tests run on aosp_marlin-eng, new tests added
Change-Id: Iee52dd1c9d2583bb6bfaf65be87569e9d50a5b63

Benedict Wong   commited 2017-12-13 23:28:41 +00:00
1cb5dabc65
Merge "Add reference counted resources to IpSecService"
Benedict Wong   authored and   Gerrit Code Review   commited 2017-12-13 21:33:38 +00:00
42ae264bc8
Add reference counted resources to IpSecService
This patch adds (but does not enable the usage of) RefcountedResource
objects to IpSecService, with tests to ensure correct function. This is
patch 1 of a series of patches to refactor the resource management
systems in IpSecService.

RefcountedResource objects allow for management of acyclical dependency
trees, ensuring eventual cleanup when resources are no longer used. This
cleanup may be triggered by binder death or by explicit user action.

Bug: 63409385
Test: New tests written in IpSecServiceRefcountedResourceTest,
explicitly testing the RefcountedResource class

Change-Id: Ib5be7482b2ef5f1c8dec9be68f15e90d8b3aba6d

Benedict Wong   commited 2017-12-12 23:40:52 -08:00
c926bdefee
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
298643506a
Merge "Cleanup of resource limit tests"
am: 5bb84059ba

Change-Id: Ifcbc61ad8003c43ba1baff6d4d534192f6498206

ludi   authored and   android-build-merger   commited 2017-12-06 03:29:35 +00:00
6cd30fe9d5
Merge "Cleanup of resource limit tests"
Treehugger Robot   authored and   Gerrit Code Review   commited 2017-12-06 02:58:41 +00:00
5bb84059ba
Merge "Fix bug in MacAddress.fromString()"
am: cdb84d2fc7

Change-Id: If4c85f0a5ea259f53f9cffa6eacb58fcde1fd1df

Hugo Benichi   authored and   android-build-merger   commited 2017-12-05 09:47:50 +00:00
7d3ce34445
Fix bug in MacAddress.fromString()
Test: runtest frameworks-net
Bug: 69390696
Change-Id: I83f01e4915092e08ed201d9b6738bb02498d3bba

Hugo Benichi   commited 2017-12-05 13:14:08 +09:00
06d9bd1560
Merge "Validate IpSecAlgorithm Length"
am: b592c42328

Change-Id: I23f7612c119e67f9a1647568aeefde38a365f8da

nharold   authored and   android-build-merger   commited 2017-12-05 02:28:10 +00:00
ae3d30d148
Merge "Validate IpSecAlgorithm Length"
nharold   authored and   Gerrit Code Review   commited 2017-12-05 02:13:55 +00:00
b592c42328
Merge "MacAddress: light refactors and improve documentation"
am: d871cab32d

Change-Id: I51bb8786ecd7f53e3342625c7a2625007eedfc0f

Hugo Benichi   authored and   android-build-merger   commited 2017-12-04 23:38:27 +00:00
2c7122d826
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
22ac4e5300
MacAddress: light refactors and improve documentation
This patch does some light refactoring in MacAddress to prepare for
exposing MacAddress in the public api:
 - documention is improved
 - some method names are renamed
 - a toSafeString method is added
 - a padding bug in the conversion methods outputting strings for
   mac addresses is fixed

Bug: 69390696
Test: runtest frameworks-net
Change-Id: I399a97dabc2dfa8df9c5518c8b12484e43ca05c9

Hugo Benichi   commited 2017-12-04 22:34:43 +09:00
e9667249da
Cleanup of resource limit tests
Test: runtest frameworks-net
Bug: 65688605
Change-Id: Ice3ff2624b83c833a99559485c1e782d36c54ae3

ludi   commited 2017-11-28 10:21:18 -08:00
126c2f71bf
Merge "Add test case for user quota management in IpSecService"
am: 9faa64ff17

Change-Id: Ib1887b2395f0b1391711a9df9bebe224b6be1643

Di Lu   authored and   android-build-merger   commited 2017-11-15 20:23:14 +00:00
86c137bdd0
Merge "Add test case for user quota management in IpSecService"
Di Lu   authored and   Gerrit Code Review   commited 2017-11-15 20:12:38 +00:00
9faa64ff17
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
3fa5c2b1a8
Add test case for user quota management in IpSecService
Test: runtest frameworks-net
Bug: 65688605
Change-Id: I3210c4920d0ac1d09fecb56c25e392e2bcba641f

ludi   commited 2017-11-13 14:14:11 -08:00
20e1c8af67
IP connectivity metrics: NetworkEvents have transports
Also removes netId field from inside NetworkEvent and stop populating
the network_id field of the NetworkEvent field, deprecating it.

Bug: 34901696
Test: runtest frameworks-net,
      manually looking at $ adb shell dumpsys connmetrics

Change-Id: I2c36860f976898883714f72f4d18e06da250c6a6

Hugo Benichi   commited 2017-11-13 14:15:51 +09:00
c3b3c5345a
Add L2~L4 information to packet wakeup logs and metrics
Example of $ adb shell dumpsys connmetrics list:
...
WakeupStats(wlan0, 21851s, total: 85, root: 0, system: 4, apps: 63, non-apps: 0, no uid: 18, l2 unicast/multicast/broadcast: 85/0/0, ethertype 0x800: 23, ethertype 0x86dd: 62, ipNxtHdr 6: 74, ipNxtHdr 17: 1, ipproto 58: 10)
...
WakeupEvent(06:55:54.094, wlan0, -1, eth=0x800, dstHw=10:e:7e:26:3f:c1, ipNxtHdr=6, srcIp=216.58.200.110, dstIp=100.112.108.29, srcPort=443, dstPort=46878)
WakeupEvent(06:57:14.379, wlan0, -1, eth=0x86dd, dstHw=10:e:7e:26:3f:c1, ipNxtHdr=58, srcIp=ff02::1, dstIp=fe80::fa00:4:fd00:1)
WakeupEvent(06:57:52.786, wlan0, 1000, eth=0x800, dstHw=10:e:7e:26:3f:c1, ipNxtHdr=6, srcIp=172.217.27.67, dstIp=100.112.108.29, srcPort=80, dstPort=49360)
WakeupEvent(06:58:02.919, wlan0, 10004, eth=0x86dd, dstHw=10:e:7e:26:3f:c1, ipNxtHdr=6, srcIp=2401:fa00:4:fd00:a585:13d1:6a23:4fb4, dstIp=2404:6800:4006:809::200a, srcPort=443, dstPort=46197)
WakeupEvent(06:58:05.586, wlan0, 10004, eth=0x86dd, dstHw=10:e:7e:26:3f:c1, ipNxtHdr=6, srcIp=2401:fa00:4:fd00:a585:13d1:6a23:4fb4, dstIp=2404:6800:4006:803::200a, srcPort=443, dstPort=46096)

Bug: 66869042
Test: runtest frameworks-net
      + manual testing by monitoring $ dumpsys connmetrics list
Change-Id: I03215c0c9fb7feda3e6ceb1b916f61f4ffb15344

Hugo Benichi   commited 2017-11-12 18:51:28 +09:00
b57b87637c
Merge "MacAddress follow-up: define the core of the class"
Hugo Benichi   authored and   Gerrit Code Review   commited 2017-11-09 12:22:17 +00:00
812a753069
MacAddress follow-up: define the core of the class
Test: new unit test parts of $ runtest frameworks-net
Change-Id: I08c57d2d656802f7bdd7a93fde711a7e77247583

Hugo Benichi   commited 2017-11-09 16:36:45 +09:00
87c1532773
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
b772a466c4
Define MacAddress class
Test: new unit tests part of $ runtest frameworks-net
Change-Id: I5a6a868ff86e9bffdc551d4e2bb486b585525c30

Hugo Benichi   commited 2017-11-08 11:09:49 +09:00
1881890778
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
698bd80129
Merge "DefaultNetworkEvent metrics: rehaul"
Hugo Benichi   authored and   Gerrit Code Review   commited 2017-11-06 07:09:49 +00:00
37a0df93a0
DefaultNetworkEvent metrics: rehaul
This patch changes instrumentation of default networks and default
network events:
- stop logging events for default network transitions,
  but instead consistently log one event per continuous segment
  when one given network was the default, including logging an
  event for when there is no default network.
- keep a separate rolling buffer of DefaultNetworkEvent for
  dumpsys and bug reports.

These changes allow to simplify post aggregation of default network
event metrics by removing any need to do time series processing.
Instead, metrics and counters can be implemented withouth any ambiguity
by following the recipe:

% of x = sum(duration | x = true) / sum (all durations)

where x can be various conditions such as:
- the default network was validated
- the default network was WiFi
- the default network was IPv6
- there was no default network
- ...

Most importantly, this new logging scheme allows to measure much more
reliably:
- the % of the time that a device had Internet, in the sense that the
default network was validated.
- the time transitions between default networks, keyed by previous and
new transports/link layer, which allows to derive wakelock durations
and wakelock power costs from default network switches.

This patch also simplifies the dumpsys interface of the connmetrics
service and reduces the commands to three:
- "flush" for metrics upload.
- "proto" for printing buffered event in text proto format.
- "list" for listing all events and statistics.

Bug: 34901696
Bug: 65700460
Test: runtest frameworks-net
Change-Id: I0521f1681a60cca07ac3bfd5741d64ce44de4cdd

Hugo Benichi   commited 2017-11-06 09:04:02 +09:00
6d7c63fa64
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
1a1cba8b46