Commit Graph

844 Commits

Author SHA1 Message Date
Nathan Harold
19b99d998a Input Validation for IpSecService
All of the input to IpSecService over the Binder
interface needs to be validated both for sanity
and for safety.

-Sanity check all the parameters coming from binder.
-Added setters for IpSecConfig to decouple the test
 from the IpSecManager. This was needed because the
 input validation caused the tests to fail due to a
 null parameter that was previously un-tested.
-Added the mode flag to the IpSecConfig bundle this
 oversight was found during testing.
-Expose the getResourceId() methods for testing in
 UdpEncapsulationSocket, SecurityParameterIndex, and
 IpSecTransform classes.
-Remove the unneeded getIpSecConfig() from
 IpSecTransform: unneeded now that we can synthesize
 configs.

Bug: 38397094
Test: runtest frameworks-net
Change-Id: I5241fc7fbfa9816d54219acd8d81a9f7eef10dd4
2017-10-03 19:45:55 -07:00
nharold
61cf7b284e Merge changes from topic "re-enable-ipsec"
* changes:
  Re-Expose IpSecService API Surface
  Re-Enable Starting of the IpSecService
2017-09-26 21:46:39 +00:00
Treehugger Robot
aa8608db31 Merge "Abort connecting to native daemon during shutdown" 2017-09-13 22:09:54 +00:00
Nathan Harold
69cb0af0a8 Re-Expose IpSecService API Surface
Note, This reverts commit 7194bb9bf9.

Bug: 64800246
Test: compilation
Change-Id: I709d4c476647cfe9f6b982fc373f8d76018b3922
2017-09-12 19:25:13 -07:00
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
e941c8a497 Merge "NetworkStats: more robust subtraction for deltas" 2017-09-08 07:13:37 +00: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
Treehugger Robot
31cb4583e5 Merge changes I325b13d5,I89719fe7
* changes:
  Add tether offload traffic to interface stats as well.
  Tell the system when tethering offload hits a limit.
2017-08-19 03:05:14 +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
Di Lu
318ca31081 Merge "Add user quota information into the IpSecService dump"
am: fedd856546

Change-Id: I1f64ab03918ece154fe31a07b698825315d39c0f
2017-08-16 16:33:18 +00:00
ludi
529fdecc4c Add user quota information into the IpSecService dump
Bug: 64093788
Test: runtest frameworks-net
Change-Id: I6c5fc9e2db4ba57e0db4f6380a1251c4e444951b
2017-08-14 16:10:55 -07:00
nharold
b1d39a7aff Merge "Add UserQuotaTracker to IpSecService"
am: a0c97b3ddb

Change-Id: I43a9617b077ecd5fc2b445a1ade8b76c00562640
2017-08-09 17:49:42 +00:00
Nathan Harold
6e4681c7e2 Add UserQuotaTracker to IpSecService
Add a small tracking object to enforce maximum
quotas for SPIs, Transforms, and Encap sockets. The
current quota limits are intentionally conservative
with the expectation that we can relax them more
easily than we can shrink them.

Bug: 37688603
Test: tbd
Change-Id: Iee59ac59ef9f4a7ab75a2e04f9ca72da82fc3229
2017-08-08 18:28:47 -07:00
Tetsutoki Shiozawa
a00d4b0bf4 Abort connecting to native daemon during shutdown
Symptom:
System_server crashed due to unsolved "netd" service.

Root cause:
Init intentionally killed services when shutdown was triggered.
NativeDaemonConnector unnecessarily tried to reconnect the killed
daemon and NetworkManagemantService got a callback of connection.
Finally, NetworkManagemantService failed to get netd service and it
crashed with NPE.

Solution:
Do not retry connecting to the target native daemon when the device
is in the middle of shutdown.

Bug: 64237349
Change-Id: I2514cdc47b3eea785b5ffe5bd8bb27609bcc1726
2017-08-01 08:40:22 +00: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
nharold
e18d235c28 Merge "Launch NetD in a different thread"
am: 3608598388

Change-Id: I0edeac83cc31b7ff9b264c35e225707ebb8418f2
2017-07-18 20:18:10 +00:00
nharold
3608598388 Merge "Launch NetD in a different thread" 2017-07-18 17:56:35 +00:00
Nathan Harold
12accd0d1b Launch NetD in a different thread
Calling run() launches in the current thread;
we want to call start() to launch in a separate
thread to unblock system initialization.

Bug: none
Test: compilation
Change-Id: Ia85059100add6a44a5e3262500b00ba8ca21e125
2017-07-17 20:22:35 -07:00
nharold
83dee33162 Merge "Check ManagedResource is NonNull before Checking Owner"
am: 0d1e9bb5b8

Change-Id: I2e8cde8a7be8bdbdeebb00df053fdc621d30cdec
2017-07-17 17:52:25 +00:00
nharold
0d1e9bb5b8 Merge "Check ManagedResource is NonNull before Checking Owner" 2017-07-17 16:57:01 +00:00
Di Lu
84aa41dae2 Merge "Remove return value of ipSecAddSecurityAssociation"
am: 36acf01d58

Change-Id: I3cf6dbc44af4934c34b074dccdfff77dede6a693
2017-07-12 04:02:24 +00:00
Di Lu
36acf01d58 Merge "Remove return value of ipSecAddSecurityAssociation" 2017-07-12 03:53:57 +00:00
Andreas Gampe
50f53691de Merge "IpSecService: Actually throw exception"
am: 3eff26449f

Change-Id: I415b249d564c5ffdd2d9381b53a31dd6f6c18eab
2017-07-12 01:29:47 +00:00
Andreas Gampe
afb01e2317 IpSecService: Actually throw exception
Add a missing throw.

Bug: 19797138
Test: m
Test: Device boots
Change-Id: I6c6058ecc95a5b85da43a42bac2846c31cefc038
2017-07-11 14:52:37 -07:00
Nathan Harold
5291cb6004 Check ManagedResource is NonNull before Checking Owner
If an invalid Resource Id is provided to the Managed Resource
Array getter, we should just return null rather than asserting
the owner of the resource.

Bug: none
Test: tbd
Change-Id: I407a96e4e82e9d6bf68e89380a88d3851efe4305
2017-07-06 21:12:38 -07:00
ludi
bdd5ab8874 Remove return value of ipSecAddSecurityAssociation
Bug:38350493

Test: runtest frameworks-net

Change-Id: I48f8462d94e8c4e95d6766c1ce7f24b8a596b743
2017-06-07 15:26:50 -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
Jack Yu
47ab7cc247 Merge "Added video calling data usage per-uid support" am: 4a98eb7208 am: 2f74c02826
am: ce10610a9c

Change-Id: I0a068e0eb7e833ad28611cf2be1a8bc18d99830a
2017-06-01 05:53:47 +00:00
Treehugger Robot
4a98eb7208 Merge "Added video calling data usage per-uid support" 2017-05-31 21:33:57 +00:00
Jack Yu
955599c547 Added video calling data usage per-uid support
Now the VT call data usage will be counted under
current dialer's data usage as well as the total
device data usage.

Test: Manual
bug: 37671326

Merged-In: I8351e9ae17c84210f7ca6c319d3bddcbb0043341
Change-Id: I8351e9ae17c84210f7ca6c319d3bddcbb0043341
2017-05-31 12:37:24 -07:00
Hugo Benichi
2b9c0de7d3 Merge changes If4deb106,Ib25d7658 am: 0388f0e47b am: 41a57af66a
am: ae278410f5

Change-Id: I4fa34b647e7b2408d4493cfb148ae7d8c24bd6e8
2017-05-26 00:58:27 +00:00
Hugo Benichi
f60833507e NsdService: do not use ContentResolver directly
This patch changes NsdService to call registerContentObserver in the
ContentResolver class indirectly through NsdSettings.

This allows to easily intercept it and mock it in unit tests, and solves
test failures on the internal master branch where
registerContentObserver uses final or static methods that cannot be
worked around.

Bug: 32561414
Bug: 62044295
Test: runtest -x frameworks/base/tests/net/../NsdServiceTest.java
Change-Id: If4deb106de551746babb70196b20f21ece478850
2017-05-26 07:18:15 +09: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
f2daafb681 Merge "NetworkStatsFactory: fix double accounting on IPv6 only networks" into oc-dev
am: f37b271894  -s ours

Change-Id: I28f139b2bc5a42eed4caf01bea7a1a9426a91625
2017-05-10 08:38:56 +00:00
Hugo Benichi
b884b37cea Merge "NetworkStatsFactory: no double looping on stats + stacked interfaces" 2017-05-10 08:19:33 +00:00
Hugo Benichi
9e0bb312f8 Merge "NsdService: more cleanups" am: cfd9a290ef am: 49bc06d0f9
am: ea0d4a65f9

Change-Id: I547138d0f45e621b583cbcc8a4ed5ab334bd4471
2017-05-10 01:15:30 +00:00
Android Build Merger (Role)
5a015facd7 Merge "Merge "NetworkStatsFactory: fix double accounting on IPv6 only networks" am: ce730270bc am: 76dc14ec88 am: 1697d48faf" into oc-dev-plus-aosp 2017-05-10 00:47:39 +00:00
Hugo Benichi
bca6c822ff Merge "NetworkStatsFactory: fix double accounting on IPv6 only networks" am: ce730270bc am: 76dc14ec88
am: 1697d48faf

Change-Id: I8b0cf31ef356aae9992f893ca35001d048999519
2017-05-10 00:44:51 +00:00