Commit Graph

313 Commits

Author SHA1 Message Date
nharold
529d025961 Merge changes from topic "ipsec-oneway-transform" am: 60a21328d5 am: ff0e4bc116
am: 00a7fde299

Change-Id: I2a90cf423a3ac9a0526831ef767ad019e7be053c
2018-01-17 10:07:33 +00:00
Nathan Harold
3da8511490 Make Transforms Unidirectional am: 3865a008e7 am: 41fe8097ed
am: 7b0b71c853

Change-Id: I608be255a307891ec3fe2d97cda817d75240c95c
2018-01-17 10:03:31 +00:00
Nathan Harold
41fe8097ed Make Transforms Unidirectional
am: 3865a008e7

Change-Id: I7e80c75b3b227fdd16479120d8b7203cc5f28d1c
2018-01-17 09:37:57 +00:00
nharold
60a21328d5 Merge changes from topic "ipsec-oneway-transform"
* changes:
  Update IpSecService UnitTests
  Make Transforms Unidirectional
2018-01-17 08:40:37 +00:00
Nathan Harold
f52a471f1a 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
2018-01-16 19:38:10 -08:00
Nathan Harold
3865a008e7 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
2018-01-16 11:08:31 -08:00
Lorenzo Colitti
963aa432c8 Merge changes I0d0c0fac,Ifb9b00b6 am: 3fbfac269b am: bfaf963337
am: f0c515477e

Change-Id: I919f21566d5caff9fb35f57c439048b9b48f0971
2018-01-16 18:59:02 +00:00
Treehugger Robot
3fbfac269b Merge changes I0d0c0fac,Ifb9b00b6
* changes:
  Split updateCapabilities into two methods.
  More strictly check NetworkCapabilities callbacks.
2018-01-16 14:25:13 +00:00
Lorenzo Colitti
7045d61b50 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
2018-01-16 00:25:13 +09:00
Erik Kline
292453458a Merge changes I47ccfa99,I5db1de3e am: f98f97fe92 am: 03f3294103
am: 420d020689

Change-Id: Ic774b944238d6df07511df8e467d66cefcd4fa81
2018-01-11 12:52:19 +00:00
Erik Kline
3212008036 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
2018-01-11 18:16:50 +09:00
Erik Kline
6e0347d6df Add minimal test for setting DNS properties
Test: as follows
Change-Id: I5db1de3ee8e179edd56c93988b821242b81c2387
2018-01-11 18:16:20 +09:00
Benedict Wong
d49e808b8e Merge "Add validation to IpSecConfig algorithm setters" am: a954f20f46 am: c93df5ca1c
am: f85202f016

Change-Id: I7ff85771945c68025ce8d66ca85313bac087b3a5
2018-01-09 21:23:35 +00:00
Benedict Wong
a708eec031 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
2018-01-04 16:56:40 -08:00
Benedict Wong
08faba25e6 Merge "[ipsec-doze] Add fchown to IpSecService to support doze" am: 4edb4c8ec4 am: 5949912523
am: a7d1b22d6d

Change-Id: Id6a5ff71ead4566b9a91b9e9b6c78d81f1ac0f54
2017-12-20 18:58:30 +00:00
Benedict Wong
6b42407013 Merge "[ipsec-qtaguid] Tag sockets upon creation of encap sockets" am: 0b8bf40ae4 am: 8caa274ade
am: b72b41b121

Change-Id: I4140f386687c579044f9b5fe59dd7e05f86000fe
2017-12-19 00:41:55 +00:00
Benedict Wong
42e3fa137d [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
2017-12-18 16:01:58 -08:00
Benedict Wong
c41067d51a [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
2017-12-18 19:46:06 +00:00
Nathan Harold
e5768f496f 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
2017-12-14 23:13:45 +00:00
Nathan Harold
bcbe3b6bf2 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
2017-12-14 23:04:42 +00:00
nharold
2079139e73 Merge "Use consistent naming for allocating SPI." am: 37303d5e94 am: 4753ed4b1b
am: b6bca5a59d

Change-Id: Ib6845ab0d7f385fbd1d59c0179771542e12c8be0
2017-12-14 21:48:58 +00:00
nharold
37303d5e94 Merge "Use consistent naming for allocating SPI." 2017-12-14 21:10:16 +00:00
Benedict Wong
882e5ed408 Merge "Convert IpSecService resources to use refcounting" am: a87a442c5a am: 8698b33cc2
am: 393a328478

Change-Id: Ib18839d7dff8e25898f81e877337fbb8cb24cc7b
2017-12-14 02:41:28 +00:00
Benedict Wong
d21105064e 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
2017-12-13 23:28:41 +00:00
Benedict Wong
9802ad3701 Merge "Add reference counted resources to IpSecService" am: 05013f3965 am: adb6437fea
am: 5dd409e76b

Change-Id: Iae17a5d33d71e8abf24211cbf2b215520f45c619
2017-12-13 22:11:20 +00:00
Benedict Wong
05013f3965 Merge "Add reference counted resources to IpSecService" 2017-12-13 21:33:38 +00:00
Benedict Wong
11c8f27e22 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
2017-12-12 23:40:52 -08:00
Jonathan Basseri
fbe3a82340 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
2017-12-12 13:50:35 -08:00
ludi
cc00bd5639 Merge "Cleanup of resource limit tests" am: 7d0a38956e am: dc7693b146
am: 5b77df1729

Change-Id: If26dc3a8a969ad63f250608427480996c3b02845
2017-12-06 04:08:23 +00:00
ludi
dc7693b146 Merge "Cleanup of resource limit tests"
am: 7d0a38956e

Change-Id: Ifcbc61ad8003c43ba1baff6d4d534192f6498206
2017-12-06 03:29:35 +00:00
ludi
de99e42cc8 Cleanup of resource limit tests
Test: runtest frameworks-net
Bug: 65688605
Change-Id: Ice3ff2624b83c833a99559485c1e782d36c54ae3
2017-11-28 10:21:18 -08:00
Di Lu
d874098ad3 Merge "Add test case for user quota management in IpSecService" am: baaa5670f5 am: 4288bb9e34
am: e8c8f6267d

Change-Id: I84e81e261c93d2199e4932431ee57b75496ea2d5
2017-11-15 20:39:53 +00:00
Di Lu
4288bb9e34 Merge "Add test case for user quota management in IpSecService"
am: baaa5670f5

Change-Id: Ib1887b2395f0b1391711a9df9bebe224b6be1643
2017-11-15 20:23:14 +00:00
Di Lu
baaa5670f5 Merge "Add test case for user quota management in IpSecService" 2017-11-15 20:12:38 +00:00
Xin Li
acae66beee Merge commit '98e12851336b7db16e583f9afac63ecc97465980' from
oc-mr1-dev-plus-aosp-without-vendor into stage-aosp-master.

Change-Id: Ia7b8da4a00d215160e4a4fa40f6044208d1297b7
Merged-In: I19846d2a3ee27aecbae2367a74ee49082eea154d
2017-11-14 12:31:11 -08:00
Hugo Benichi
919987e3d5 Merge "IP connectivity metrics: NetworkEvents have transports" am: a37e03886f am: f3ada43f6e
am: c90d3a0bbd

Change-Id: If452f742e50344e730f63b7329788b19d13280ec
2017-11-14 12:03:25 +00:00
Hugo Benichi
1920023b5f Merge "Add L2~L4 information to packet wakeup logs and metrics" am: 6ee20ca7d3 am: ab15f7fc64
am: 3f23c704ab

Change-Id: Ia0b300662d4758f31ca583c9cf05f9186b8331aa
2017-11-14 11:55:45 +00:00
Hugo Benichi
c90d3a0bbd Merge "IP connectivity metrics: NetworkEvents have transports" am: a37e03886f
am: f3ada43f6e

Change-Id: I8cd50ea805fe3e533c0fc21b220827155cb0d23b
2017-11-14 01:46:23 +00:00
Hugo Benichi
3f23c704ab Merge "Add L2~L4 information to packet wakeup logs and metrics" am: 6ee20ca7d3
am: ab15f7fc64

Change-Id: I9dba29b10c824d382b08b16313e49cc8c775f7eb
2017-11-14 01:40:06 +00:00
ludi
296907da6a Add test case for user quota management in IpSecService
Test: runtest frameworks-net
Bug: 65688605
Change-Id: I3210c4920d0ac1d09fecb56c25e392e2bcba641f
2017-11-13 14:14:11 -08:00
Hugo Benichi
d5c11bbb65 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
2017-11-13 14:15:51 +09:00
Hugo Benichi
fcccb3a36d 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
2017-11-12 18:51:28 +09:00
Benedict Wong
269470d5a0 Merge "Update documentation for AES-GCM-ESP keymat length" am: fcbbf2b939 am: 6491b03410
am: e7e7095303

Change-Id: Ia0e1538feea2ddb0982875c925705c3648e50c8a
2017-11-08 18:27:06 +00:00
Benedict Wong
e7e7095303 Merge "Update documentation for AES-GCM-ESP keymat length" am: fcbbf2b939
am: 6491b03410

Change-Id: I5e61a9c28dac49f2dca554ce2fdf755ab7be0dab
2017-11-08 18:12:25 +00:00
Benedict Wong
fcbbf2b939 Merge "Update documentation for AES-GCM-ESP keymat length" 2017-11-08 17:47:40 +00:00
Benedict Wong
720c1249bf 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
2017-11-07 17:39:35 -08:00
Hugo Benichi
0dfa4b300e Merge "DefaultNetworkEvent metrics: rehaul" am: addecd1491 am: d025358166
am: 83e05af631

Change-Id: Ia5c19bfbdf9eea553f4517f312295c14c2f02046
2017-11-06 07:41:53 +00:00
Hugo Benichi
83e05af631 Merge "DefaultNetworkEvent metrics: rehaul" am: addecd1491
am: d025358166

Change-Id: If6bf966ba547a2ce50e17340e0374dd9b75b80d9
2017-11-06 07:31:39 +00:00
Hugo Benichi
addecd1491 Merge "DefaultNetworkEvent metrics: rehaul" 2017-11-06 07:09:49 +00:00
Hugo Benichi
f123c85f29 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
2017-11-06 09:04:02 +09:00