Commit Graph

364 Commits

Author SHA1 Message Date
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
Sudheer Shanka
278d074254 Track some event history and include it in netpolicy dump.
Bug: 66921847
Test: manual
Change-Id: I0c473790f83076def807308fe44db9cb9365769e
2017-11-28 11:33:43 -08: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
Jeff Sharkey
92675a966e Merge "Define NOT_ROAMING network capability." am: 8f380ab29c am: 3fe1ae29cd
am: 47ad296f75

Change-Id: I04220ff55fc87dbf8d417a30f15a06a877b412d4
2017-11-03 23:18:45 +00:00
Jeff Sharkey
47ad296f75 Merge "Define NOT_ROAMING network capability." am: 8f380ab29c
am: 3fe1ae29cd

Change-Id: Ib511f7af82c80fd4e95f4da9de1fdce200deb987
2017-11-03 23:07:03 +00:00
Jeff Sharkey
07e19362de 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
2017-11-01 19:05:42 -06:00
Manoj Boopathi Raj
7b76b5f4ac Merge "Fixed NullPointerException in IpSecService-Netd binder layer" am: 626046b7f5 am: a096e8d177
am: 6e94f3f675

Change-Id: I8c51bfa708622dfb47ae55438f08b98f04c1d6c6
2017-10-27 18:21:48 +00:00
Manoj Boopathi Raj
6e94f3f675 Merge "Fixed NullPointerException in IpSecService-Netd binder layer" am: 626046b7f5
am: a096e8d177

Change-Id: I23ea94140ac3e34fc92fdc6a2c0d694396489e03
2017-10-27 18:06:09 +00:00
Manoj Boopathi Raj
626046b7f5 Merge "Fixed NullPointerException in IpSecService-Netd binder layer" 2017-10-27 17:32:56 +00:00
Manoj Boopathi Raj
03bb7d9304 Fixed NullPointerException in IpSecService-Netd binder layer
Replaced null with empty byte array in createTransportModeTransform
for null auth.getKey, crypt.getKey() and authCrypt.getKey()

Test: Ran CTS test
Bug: 68052730
Change-Id: I5110b1297b4bfbb5766e8ecfd3d64f8110b52945
2017-10-26 13:10:22 -07:00
Hugo Benichi
efc9cdb106 Merge changes I59b6e04f,I55694d89 am: bccc497249 am: 93134fea64
am: 2eca2c0e3a

Change-Id: I61f321ebd67432e02b5621fa1c662953295999fd
2017-10-26 06:34:27 +00:00
Hugo Benichi
2eca2c0e3a Merge changes I59b6e04f,I55694d89 am: bccc497249
am: 93134fea64

Change-Id: I923fe9cc37463e695182c7a279d201ba7e9d6518
2017-10-26 06:23:31 +00:00
Hugo Benichi
7e86f2e10f Remove Parcelable interface from DefaultNetworkEvent
This patch takes advantage of the direct DefaultNetworkMetrics interface
between ConnectivityService and IpConnectivityMetrics and removes the
Parcelable interface from DefaultNetworkEvent.

IpConnectivityMetrics, IpConnectivityEventBuilder and associated tests
are updated as necessary.

Bug: 34901696
Test: runtest frameworks-net
Change-Id: I59b6e04fc126051320d08a422cfbd4d27042123e
2017-10-25 12:40:13 +09:00
Hugo Benichi
cd8d58c405 Extract logging of default network events
This patch extracts the logging of DefaultNetworkEvent from inside
ConnectivityService and move it to a new DefaultNetworkMetrics class.

The DefaultNetworkMetrics is a singleton owned by the
IpConnectivityMetrics singleton implementing the metrics service for
core networking. ConnectivityService has access to this singleton via
LocalServices.

This class layout will allow to remove the Parcelable interface of
DefaultNetworkEvent and will instead let the IpConnectivityMetrics
service grab metrics from the DefaultNetworkMetrics directly.

Bug: 34901696
Test: runtest frameworks-net
Change-Id: I55694d89124272732aba114198776462372de18b
2017-10-25 12:36:29 +09:00
Benedict Wong
396f1030d3 Merge "Return a port from bindToPort() in IpSecService" am: 51de41dea2 am: 0d4a1ae642
am: a52b3a7775

Change-Id: I0d1c17c3740983ab0cbc24c2cd0d3a530b56ca99
2017-10-24 17:09:28 +00:00