Commit Graph

281 Commits

Author SHA1 Message Date
Nathan Harold
81f54633f0 Re-Enable Starting of the IpSecService
This reverts commit 41004ff4113dc9175c993638a47af602af6d8a98.

Bug: 64800246
Test: compilation
Change-Id: I4f5e3cd23001b9d94b3f6dc9fcfe731a90650e6e
2017-09-12 19:25:09 -07:00
Hugo Benichi
624e54f225 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 d78311f267)

Change-Id: Ic86b65a65a2517c871221f8784088ec1de18f534
2017-09-08 13:39:44 +09:00
Hugo Benichi
fa8a0bb61f Network Service Discovery test: properly release resources
Bug: 32561414
Bug: 62918393
Bug: 62044295
Test: runtest frameworks-net
Change-Id: If23993b5e391947ecbdc01677f0a643144794b2b
2017-09-02 14:54:29 +09:00
Lorenzo Colitti
d1800f3e6f Merge changes I325b13d5,I89719fe7
am: 31cb4583e5

Change-Id: Iaced543ab17ea87c8f701975764d957bc1b17fc7
2017-08-19 03:15:08 +00:00
Lorenzo Colitti
c2f8a8dda3 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 f31c942e89)

Bug: 29337859
Bug: 32163131
Test: runtest frameworks-net
Test: runtest frameworks-telephony
Change-Id: I325b13d50e88841dfb0db4c35e7e27f163ee72fe
Merged-In: I4e8e923d68dce1a4a68608dbd6c75a91165aa4ee
2017-08-19 10:12:05 +09:00
ludi
b47cb8b03c Merge "Add dump info to IpSecService"
am: ec5fc4872e

Change-Id: Idd4c051e4536d32504718fdfd201c7effdeb62e3
2017-07-25 03:07:00 +00:00
ludi
89194d6e45 Add dump info to IpSecService
Bug:38350824

Test: runtest frameworks-net

Change-Id: Ifa11d55e9d337016ad865baada627db3aa8c2db3
2017-07-24 16:03:33 -07:00
Di Lu
8cdceb2fed Merge "Add unit test for IpSecService"
am: 9e3f886dca

Change-Id: I16fb89239e641ac39a8a7adeafd72b7fe03935ed
2017-07-20 07:36:19 +00:00
ludi
5e623eaa02 Add unit test for IpSecService
Test: runtest frameworks-net

Bug:38259578
Change-Id: I4a049d5fdec79e36692e3b12306bd0758c19ad75
2017-07-20 04:26:24 +00:00
Steven Moreland
4f846495a4 Merge "frameworks/base: use proper nativehelper headers"
am: 826eafd958

Change-Id: I36f10ff4d963284a313f1cc5b368f82549a4adb2
2017-07-20 02:50:53 +00:00
Steven Moreland
881296fa45 frameworks/base: use proper nativehelper headers
libnativehelper exports headers under nativehelper. These were
available before incorrectly as global headers in order to give
access to jni.h.

Test: modules using frameworks/base find headers
Bug: 63762847
Change-Id: I0f9f231acdebe460f279135462f43d3e32eff64d
2017-07-19 10:06:40 -07:00
Jeff Sharkey
4786aec7cc Merge "Annotate @SystemApi with required permissions." into oc-dev
am: c1406978a4

Change-Id: I305967cad945a807c3f8234efabaad0ef8b591d1
2017-06-05 22:28:21 +00:00
Jeff Sharkey
ad1cebe58e Annotate @SystemApi with required permissions.
Most @SystemApi methods should be protected with system (or higher)
permissions, so annotate common methods with @RequiresPermission to
make automatic verification easier.

Verification is really only relevant when calling into system
services (where permissions checking can happen on the other side of
a Binder call), so annotate managers with the new @SystemService
annotation, which is now automatically documented.

This is purely a docs change; no logic changes are being made.

Test: make -j32 update-api && make -j32 offline-sdk-docs
Bug: 62263906
Change-Id: I2554227202d84465676aa4ab0dd336b5c45fc651
2017-06-05 13:27:11 -06:00
nharold
834637a824 Merge "Add UDP Encap Socket Support to IpSecManager" am: 4f6ec3d11d am: c530c01744
am: 3c1484c715

Change-Id: Idc082c1ab2aac63ad61e5fc74be7fa75cf6e686f
2017-06-03 00:04:41 +00:00
Nathan Harold
8086539071 Add UDP Encap Socket Support to IpSecManager
-Implement the UdpEncapsulationSocket
-Convert all ManagedResources to use resourceIds
-Rework ManagedResource to track resourceIds

Bug: 30984788
Test: cts - IpSecManagerTest#testUdpEncapsulation()

Change-Id: I7b1099c487051a8d951c1485791c4b6cef2deb1d
2017-06-02 03:18:56 +00:00
Hugo Benichi
ca4c03dbb0 Merge "NsdServiceInfo: move test to tests/net" am: 48859e01d5 am: 1b0f4bf606
am: e8c2700519

Change-Id: I44cae417fcddad72c13938b6fb751de6ed784046
2017-05-25 01:12:51 +00:00
Hugo Benichi
298ac9487e NsdServiceInfo: move test to tests/net
This patch also
  - adds a license plate to NsdServiceInfoTest
  - fixes some formatting and style issues
      package name
      uses of canonical junit asserts
  - update NsdServiceInfoTest to not use the deprecated AndroidTestCase

Bug: 62044295
Bug: 32561414
Test: $ runtest frameworks-net passes
Change-Id: Ie5ebb00172aef4eec19e6ecd2b41c4467901b93d
2017-05-24 16:03:43 +09:00
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
b15ed2c488 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: I4867fe181938d94b5594b3d88896a3c4e01d895c
Merged-In: I2675643b220acbc6110179fa937d4c313b6f5e32

(cherry picked from commit e1bb3a14d1ee1aba2f92e5bccf659774699eaffe)
2017-05-10 09:19:12 +09: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
Nathan Harold
7194bb9bf9 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
Merged-In: I8caccd3f8455341cb56a2256354eacbadedff047
Change-Id: I8caccd3f8455341cb56a2256354eacbadedff047
(cherry picked from commit e38565fc74ee19e27175782be3cf2f0dffefd3a6)
2017-04-25 16:53:50 -07: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
Hugo Benichi
4a786f94c2 Merge changes Ic029cc9f,Id917f3a2 into oc-dev
* changes:
  NsdService: minor cleanups
  Nsdmanager/NsdService: add logging
2017-04-20 04:27:50 +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
b2b85df5d6 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
Merged-In: Idce367f638a42da374a7f1dc5ebb8931c9555e06
Change-Id: Idce367f638a42da374a7f1dc5ebb8931c9555e06
(cherry picked from commit da18b028f85e9a2c969c636aea6abf7f4bac3922)
2017-04-17 20:23:51 -07:00
Nathan Harold
2528c66a66 Consistenly Throw IOExceptions from IpSecManager
Bug: 36073210
Test: api-update
Change-Id: Ia3825e85b09b6330f1326a26cf9e1cadf9dacf71
Merged-In: Ia3825e85b09b6330f1326a26cf9e1cadf9dacf71
(cherry picked from commit c2fd6cfdc9dce33d57a3c2780e0527dd4b1bfeb9)
2017-04-17 20:23:34 -07: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
Hugo Benichi
b6389543d4 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

(cherry picked from commit 2183ba9b5f8eb54c74cd198a7506b21319794e99)

Merged-In: I360d539e73cc8e4b45d4e0d20b2e345455fdb10c
Change-Id: Id917f3a2085d17f277850af36a2cf859e3614a0f
2017-04-17 10:07:05 +09:00
Nathan Harold
0bb49fc68c 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-13 15:05:13 -07:00
Nathan Harold
ed0fcf1faf 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-13 15:04:47 -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