Commit Graph

252 Commits

Author SHA1 Message Date
Hugo Benichi
1f27dba36f Merge "NetworkStatsFactory: no double looping on stats + stacked interfaces" am: b884b37cea am: cd6537edb5
am: b323e61584

Change-Id: I0312882bb8885aaa65f99a445fd0554d6ac054b3
2017-05-10 09:20:04 +00:00
Hugo Benichi
b884b37cea Merge "NetworkStatsFactory: no double looping on stats + stacked interfaces" 2017-05-10 08:19:33 +00:00
Hugo Benichi
286734b834 Merge "NetworkStatsFactory: fix double accounting on IPv6 only networks" am: ce730270bc am: 76dc14ec88
am: 1697d48faf

Change-Id: I7dbfe3c96678e2325eb533f31523ad10d861ad02
2017-05-10 00:40:28 +00:00
Hugo Benichi
5efd907d85 NetworkStatsFactory: no double looping on stats + stacked interfaces
This patch uses the associative structure of the stacked/base interface
collection to avoid the two nested for loops over stacked/base
interfaces and all stats entries when correcting 464xlat traffic stats.

Consequently the list of stats entries is iterated only once.

Test: runtest -x frameworks/base/../NetworkStatsFactoryTest.java
Bug: 33681750
Change-Id: I84ae997fb693b909f431764697627b9957131732
2017-05-10 09:14:14 +09:00
Hugo Benichi
ce730270bc Merge "NetworkStatsFactory: fix double accounting on IPv6 only networks" 2017-05-10 00:07:29 +00:00
Hugo Benichi
6d58a32565 NetworkStatsFactory: fix double accounting on IPv6 only networks
For 464xlat scenarios on IPv6 networks, the clatd interface setup
introduces double counting of apps ipv4 traffic. NetworkStatsFactory was
accounting for this on the tx path, but not on the rx path. Also it did
not accounted for the 20 bytes added by the IPv6 header.

This patch subtract correctly the rx and tx traffic from the root uid on
the underlying interface, and also adds correctly the 20 bytes cost per
packet on the stacked interface for 464xlat traffic.

Test: added several new unit tests, based on synthetic data and real
      data also.
Bug: 33681750
Change-Id: I2675643b220acbc6110179fa937d4c313b6f5e32
2017-05-09 22:46:14 +09:00
Hugo Benichi
20f5ef9065 Merge changes I4872f8ba,I92039f29,Iaad13e13 am: 767ac317e2 am: 717238a614
am: 44e9b81c54

Change-Id: I9c38d1254f82b50f4d1e953e72bf15a46562d3b8
2017-05-09 06:30:48 +00:00
Hugo Benichi
4dd4db7720 NsdService: test coverage for client requests.
Adding coverage for:
  - NsdManager client disconnection
  - in-flight request GC

Test: new test passes
Bug: 37013369, 33298084
Change-Id: I92039f297cf99352bbf4196797933d89c0b819ff
2017-05-09 10:49:33 +09:00
Hugo Benichi
f2c64f8725 NsdManager: remove duplicated argument validation
This patch simplifies argument validation in NsdManager public api and
regroup duplicated validation into common methods.

This makes stack traces more actionable as now specific errors will
cause the api to throw exception from specific methods, whereas before
IllegalArgumentException would be thrown from inside the same api method
for different reasons.

This patch also includes a couple of other small cleanups.

Test: $ runtest -x frameworks/base/tests/net/../NsdManagerTest.java
Bug: 37013369
Change-Id: Iaad13e13976e9bf8f508d7188f823f8184ac414b
2017-05-09 10:49:33 +09:00
Hugo Benichi
284ecaa201 Merge "NsdManager: add test coverage for discoverServices()" am: 3e21b1745c am: 60182dbe4e
am: 27b0eebb4d

Change-Id: I46acfd104ac3457126c3ccef5041788e4146321c
2017-05-02 09:04:59 +00:00
Hugo Benichi
459c68c725 Merge "NsdManager: unit test coverage for servive registration" am: b0e408450c am: bc57faa1ac
am: 9a3e69d9b6

Change-Id: Ideabb1c929ddd4307e66831cddb20e2feac2c6d9
2017-05-02 06:49:52 +00:00
Hugo Benichi
287730e764 NsdManager: add test coverage for discoverServices()
Test: added new tests
Bug: 37013369, 33298084
Change-Id: If6c1113ee1bd4690db90abd5a61c3e229c827aec
2017-05-02 15:26:33 +09:00
Hugo Benichi
3ec710f6f0 NsdManager: unit test coverage for servive registration
This patch adds test coverage for NsdManager#registerService() and
NsdManager#unregisterService(). This test shows a potential defect in
the api: if unregisterService() fails, the associated listener is always
unregistered from NsdManager. If the service initially registered is
still registered, this potentially make it impossible to unregister.

Test: added new unit test
Bug: 37013369, 33298084
Change-Id: Ia089b6d2f2a349907a8b29d9a3acd7f59e177887
2017-05-02 13:31:24 +09:00
nharold
ee588f0304 Merge "Hide IpSecManager, IpSecTransform, and IpSecAlgorithm" am: 01e368f26d am: 939528045a
am: 52dab83f7a

Change-Id: I3bf240b35c3d509c4e016ffe20519c1bda5ab0b3
2017-04-26 17:38:58 +00:00
Nathan Harold
185f2ccd1c Hide IpSecManager, IpSecTransform, and IpSecAlgorithm
These classes, originally planned to be part of the
public API, are not ready for public consumption.
They are planned to be un-hidden in a future release.

Bug: 37681043
Test: make update-api and make
Change-Id: I8caccd3f8455341cb56a2256354eacbadedff047
2017-04-26 06:50:54 +00:00
Hugo Benichi
3b40687000 Merge "NsdManager: add unit tests" am: dc54ad7fc3 am: 40ab8401b2
am: d2181235b9

Change-Id: I7a5202be0e6a6274f3bd11737f30fee0ef947235
2017-04-22 00:57:48 +00:00
Hugo Benichi
0b1540e40d NsdManager: add unit tests
This prepares some refactoring and the addition of a timeout to
resolveService.

Test: new tests pass
Bug: 37013369, 33298084
Change-Id: Ie8277bd5983278507bfa70495b4ce7d13895b24b
2017-04-21 05:16:37 +00:00
nharold
d19fe145b9 Merge changes from topic 'ipsec-hide-overloads' am: fe358c6adf am: 8508bc52d2
am: 6eab2ee093

Change-Id: Iaa713ba4b20bab12331bd996288ed2440c349db2
2017-04-18 22:12:54 +00:00
Nathan Harold
31af88727b Consistenly Throw IOExceptions from IpSecManager am: a64b019f94 am: 5db180bbb7
am: 7883c5d460

Change-Id: I04198299d43da4c9c91f705acc5520f734ad9249
2017-04-18 22:11:18 +00:00
Nathan Harold
4b909c85f6 Hide Socket+DatagramSocket IpSecTransform methods
These methods do not currently work for IPv4 sockets,
so they need to be hidden until the underlying kernel
code can be made to work properly in a dual-stack
environment.

Bug: 36073210
Test: compilation
Change-Id: Idce367f638a42da374a7f1dc5ebb8931c9555e06
2017-04-17 19:41:08 -07:00
Nathan Harold
a64b019f94 Consistenly Throw IOExceptions from IpSecManager
Bug: 36073210
Test: api-update
Change-Id: Ia3825e85b09b6330f1326a26cf9e1cadf9dacf71
2017-04-17 17:57:41 -07:00
nharold
acdb1a217c Merge changes from topic 'ipsec-api-tweaks' am: fddf677b8b am: 176bfb58c6
am: a237a34085

Change-Id: Ie868985d20535f35b869730a4ddaa00dc88a352d
2017-04-12 20:53:17 +00:00
Nathan Harold
480aa304dd IpSecManager and IpSecAlgorithm API Tweaks am: 0540679eb4 am: 9c2428ad4d
am: 99c50add4f

Change-Id: I49641308cd0f2ce3e8a7545c8b03108d69287c64
2017-04-12 20:51:41 +00:00
Nathan Harold
0072e19c8e Add FileDescriptor Versions of applyTransportModeTransform()
Because there is no way using the Java sockets API to actually
get a socket of AF_INET on mode machines, it is necessary to
provide a way to apply transforms to sockets made using the
native wrapper API, which uses POSIX APIs and will create a
socket that is AF_INET.

Bug: 36073210
Test: b/34811227
Change-Id: I28ac7cc4f36045ce523a54111e5be975b0331356
2017-04-11 10:14:11 -07:00
Nathan Harold
0540679eb4 IpSecManager and IpSecAlgorithm API Tweaks
-Add a reserveSecurityParamterIndex() function that allows the
 system to select an SPI.
-Disallow INVALID_SECURITY_PARAMETER_INDEX from being passed as
 an explicit SPI request.
-Remove the ALGO_ prefix from constants in IpSecAlgorithm

Bug: 36073210
Test: Updated CTS tests still pass on bullhead
Change-Id: Ic94809996076b0718f153f550b82192fe7048a2e
2017-04-11 10:14:10 -07:00
Hugo Benichi
0a336978a8 Merge changes I9ad4ce81,I360d539e am: f34d09ac30 am: 4062ac81be
am: 84c878ecc8

Change-Id: Ieeb3222246c63292a75ad91e9c867eaedcad8f90
2017-04-06 02:13:07 +00:00
Hugo Benichi
32be63d083 Nsdmanager/NsdService: add logging
This patch adds basic logging to NsdManager and NsdService, and improves
the facilities for pretty printing the event ids defined in NsdManager.

It also includes a few minor cleanups:
  - adding 'final' on effectively final instance variables of NsdManager
  and NsdService.
  - similarly, adding 'static' on effectively static class fields.
  - regrouping instance variables together.

Test: no functional changes
Bug: 33074219
Change-Id: I360d539e73cc8e4b45d4e0d20b2e345455fdb10c
2017-04-05 15:05:44 +09:00
nharold
6ca64c9dbe Merge changes from topic 'ipsec-transport-impl' am: 464dc5c07e am: 38e47af3ef
am: 8108bef16d

Change-Id: Ie820478fc01f42b5143a63a3422380ce7ec74847
2017-04-02 00:35:08 +00:00
Nathan Harold
426d6f088f IpSecManager and IpSecTransform API Cleanup am: 55e8910aa8 am: 91b516e78b
am: 37f260f5d8

Change-Id: Ie84a720356466000930030de6f7a9182500afadb
2017-04-02 00:33:17 +00:00
Nathan Harold
031acb850f Add Initial IPsec APIs to IpSecService
-Plumb IpSecManager APIs to NetD
-Add Resource Management to IpSecService

Bug: 33695893
Test: CTS verifies nearly all of these paths
Change-Id: Ic43965c6158f28cac53810adbf5cf50d2c54f920
2017-03-31 18:11:27 -07:00
Nathan Harold
55e8910aa8 IpSecManager and IpSecTransform API Cleanup
-Remove Int-based SPI usage from the IpSecTransform.Builder
 This is essentially a less-safe method overload, and it is both
 unnecessary and difficult to implement: the cross-validation
 between SPI and Transform is actually useful, and the kernel
 requires two different mechanisms to use an unreserved vs a
 reserved (alloc'd) SPI: CREATESA vs UPDATESA, which makes this
 hard to support. API Council has questioned the value of this,
 and they are right: everything points to "remove this". In the
 future, if we find that SPI reservation is overhead, we can
 always add it back.

-Hiding the TunnelMode builder method and application/remove
 methods. These will not land by the time the next API
 stabilizes, so better to hide them now that this is a
 near-certainty. Expectation is to un-hide them in the subsequent
 API bump.

Bug: 36073210
Test: Compilation, verified nobody is calling these stubs
Change-Id: Ic1a3f2cf7128633318ac175d6b56b45eb8d21cab
2017-03-31 11:21:10 -07:00
Nathan Harold
abf3bde466 Merge "Change reserveSecurityParameterIndex() to take a remoteAddress" am: d118826971 am: d083810c0b
am: 81d48a99e0

Change-Id: I941ee00099df0afdbce94b73c1bd81c246fac1e8
2017-03-30 03:48:20 +00:00
Nathan Harold
909d66e80a Change reserveSecurityParameterIndex() to take a remoteAddress
To make the SPI reservation more semantically consistent with the
transform creation API, and to ensure that we always create SPI
reservations relative to a well-known remote, we should take the
SPI request relative to a remote (rather than to a destination).
This necessitates that we now consider direction separately, which
is used for keying the SA-Id.

Bug: 36073210
Test: compilation
Change-Id: I81e955c20128c1f8e04fd68eb26669561f827a78
2017-03-29 17:46:47 -07:00
Nathan Harold
7e854f1b82 Merge commit 'e45e328821ba' into oc-dev-plus-aosp
Change-Id: I30ad9038be8faee57e5d6b1391d9e70a966a9a77
2017-03-29 17:05:10 -07:00
Nathan Harold
d2a1dad9a8 Add a Skeleton IpSecService
-Add IpSecService with the necessary glue to connect to netd
-Add code to retrieve IpSecService from System Server

Bug: 34811227
Test: Service boots (and dumpsys works), more via b/34811227
Merged-In: I4cdcb643421141202f77a0e2f87a37012de0cd92
Change-Id: I4cdcb643421141202f77a0e2f87a37012de0cd92
2017-03-29 11:31:27 -07:00
Nathan Harold
fab5eff9a6 Merge "Add API Surface for creating IpSec Transforms" am: 7645fa2816 am: 5466fbdc27
am: 3ddaf3e6b0

Change-Id: Idceae0e5a1af2f357378b03fc0d257dab605b217
2017-03-01 14:22:57 +00:00
Nathan Harold
b1f605fc33 Add API Surface for creating IpSec Transforms
This CL adds an API to set up an IPSec Security Association
and Security Policy to perform Transport-Mode and Tunnel-Mode encapuslation
of IP Packets.

Bug: 30984788
Bug: 34811752
Test: 34812052, 34811227
Change-Id: Ic9f63c7bb366302a24baa3e1b79020210910ac0a
2017-02-28 22:01:20 -08:00
Jeff Sharkey
289eac11a2 StrictMode to detect untagged network traffic.
Network usage is tracked by the kernel at the UID level, which is
granular enough for normal apps, but large components (such as the
system server) are impossible to debug without adding additional
socket tagging to help identify subsystems within a UID.

To help ensure that system components tag all their network traffic,
this change offers a new StrictMode option to detect and report
untagged sockets.

Test: builds, boots, all common traffic tagged
Bug: 30943431, 30414041
Change-Id: I825c7941076054732264690247de2863342638e2
2017-01-19 20:52:05 -07:00
Makoto Onuki
feb5df9814 Support protofied dumpsys for NetStats
Bug 34228873
Test: manual tests with "incident_report netstats"

Change-Id: I359b364c64d9798fd4229018a905658d5d46ea5c
2017-01-17 14:16:01 -08:00
Stephen Chen
92b6175069 DO NOT MERGE: Implement metered tracking for NetworkStats summary queries.
Dependent on ag/1550196 where API is defined.

Bug: 31015360
Bug: 26545374
Test: runtest --path
frameworks/base/core/tests/coretests/src/android/net/NetworkStatsTest.java,
other test classes.

(cherry picked from commit 357f8fabc8)

Change-Id: I46da93ba4afa968facf98f7c3d844fd0c469095a
2016-12-09 13:59:33 +09:00
Stephen Chen
ebace40092 DO NOT MERGE: Define API for metering network stats buckets.
This is a continuation of b/26545374, since now we can also set the
metered bit with NetworkScorer. The tracking of metered state changes
will be implemented in a seperate CL.

Bug: 31015360
Bug: 26545374
Test: N/A

(cherry picked from commit ed7fcb4d26)

Change-Id: I6a2fcc8577d62daa8823dff9e0128a5cf39ede7b
2016-12-09 13:59:17 +09:00
Jeremy Joslin
b135f1d5a8 DO NOT MERGE: VPN network stat accounting changes.
Properly account for VPN apps that make heavy use of the tun
interface. Prior to this change a VPN app could be incorrectly charged
for more data than it actually used if it sent more traffic through
the tun interface than the underlying interface.

This change excludes VPN app traffic on the tun interface from the
adjustment pool and doesn't redistribute traffic to the VPN app.
Instead all of the redistributed traffic is deducted from the VPN app
which effectively represents any overhead incurred by the VPN app.

BUG: 30557871

(cherry picked from commit 12255e3655)

Change-Id: I06f01aa8fe5fdc06b2d36cfb9c68feb244c2e5de
2016-12-09 13:42:29 +09:00
Philip P. Moltmann
2838d9bb56 DO NOT MERGE: Indicate the NsdServiceInfo attributes are only filled in for a resolved service.
Fixes: 28530428

(cherry picked from commit 79a3c031a0)

Change-Id: If2bfc06589adb361f11b89cd5923cb5c255cb680
2016-12-09 13:42:09 +09:00
Jeff Sharkey
931afb110d Merge "StrictMode to detect untagged network traffic." am: 0bb7880e77 am: bc9c6a91b9 am: 8cbc5e3eac
am: 55727aaede

Change-Id: I272964fc9c2a9e350bacc0586dd6b2d4a23c5f51
2016-11-21 23:05:12 +00:00
Jeff Sharkey
8cbc5e3eac Merge "StrictMode to detect untagged network traffic." am: 0bb7880e77
am: bc9c6a91b9

Change-Id: Id6ce5cfedab250f25c0eb8b0c49971e9e20cbeb2
2016-11-21 21:48:31 +00:00
Jeff Sharkey
bc9c6a91b9 Merge "StrictMode to detect untagged network traffic."
am: 0bb7880e77

Change-Id: I52cdce87d87ec503294e431c8f22e87235bdbf79
2016-11-21 21:43:58 +00:00
Jeff Sharkey
66dca17fe7 StrictMode to detect untagged network traffic.
Define some constants for early use in AOSP code.

Test: builds, boots, all common traffic tagged
Bug: 30943431
Change-Id: Ia58a8933bccfddbc027afb78c63ae65bd71ce562
2016-11-21 12:15:16 -07:00
Stephen Chen
4f1700dd16 Fix documentation for NetworkStatsManager methods.
Test: N/A
Change-Id: I054ce104e561ece8e414c7ddad718665e51a692e
2016-11-07 11:31:24 -08:00
Stephen Chen
357f8fabc8 Implement metered tracking for NetworkStats summary queries.
Dependent on ag/1550196 where API is defined.

Bug: 31015360
Bug: 26545374
Test: runtest --path
frameworks/base/core/tests/coretests/src/android/net/NetworkStatsTest.java,
other test classes.

Change-Id: I968b9e3352d7880e3fc438f12de628a2da057e0a
2016-11-04 09:55:21 -07:00
Stephen Chen
ed7fcb4d26 Define API for metering network stats buckets.
This is a continuation of b/26545374, since now we can also set the
metered bit with NetworkScorer. The tracking of metered state changes
will be implemented in a seperate CL.

Bug: 31015360
Bug: 26545374
Test: N/A
Change-Id: I0eccd10c0316357abb03af4d9cf0c4191a66abfb
2016-10-25 18:16:15 -07:00