Commit Graph

557 Commits

Author SHA1 Message Date
Chenbo Feng
ef57c37338 Merge changes from topic "bpfStats" am: e339107631 am: a0b44c329f
am: a79ac6a66b

Change-Id: I672efa1221e17d0962ca5702330fc83d75fcac81
2018-01-24 05:46:52 +00:00
Chalard Jean
515b2e9434 Merge changes I3b16caad,Iaf5ea7ab,I09a94042,I69a39039,I35300309, ...
* changes:
  Let network requests see VPNs.
  Move constants into a new file.
  Make sure listen requests from VPN apps see their own networks
  Add a test for new UID checking code.
  Remove UID_RANGES_ADDED and REMOVED.
  Move VPN allowed UIDs into NetworkCapabilities.
  Pre-import to remove a conflict.
2018-01-24 04:09:44 +00:00
Treehugger Robot
e339107631 Merge changes from topic "bpfStats"
* changes:
  Use /proc/net/dev to get stats summary
  Add bpf support for NetworkStatsFactory
  Add BPF support for NetworkStatsService
2018-01-24 04:08:29 +00:00
Benedict Wong
c3153bd028 Merge "Add checks to ensure SPIs are not reused" am: e9f609ee76 am: 567ecd6790
am: 7c66896fa8

Change-Id: I13738ac37710ec7934998ef269681ae7c41c612e
2018-01-23 20:40:39 +00:00
Benedict Wong
e9f609ee76 Merge "Add checks to ensure SPIs are not reused" 2018-01-23 18:00:06 +00:00
Chalard Jean
fd3a4ae0fe Let network requests see VPNs.
Test: runtest frameworks-net
Test: also tested with VPN app
Test: also cts passing
Change-Id: I3b16caad7787c3c1f2921ca1583815c89efbadc5
2018-01-23 21:38:00 +09:00
Chalard Jean
92a116d264 Add a test for new UID checking code.
Test: manual, this is a new test and it passes
Change-Id: I69a39039647ec05f970700e36c5f1e1e6e110f4a
2018-01-23 21:38:00 +09:00
Lorenzo Colitti
c4ba57cadd Disable IpConnectivityMetricsTest.
This test has been failing for a while, and we are do not have
bandwidth to fix it during the next week.

Test: make -j64 FrameworksNetTests RUN_ERROR_PRONE=true
Test: atest FrameworksNetTests:IpConnectivityMetricsTest
Test: runtest -x frameworks/base/tests/net/java/com/android/server/connectivity/IpConnectivityMetricsTest.java
Change-Id: I59d73c1773e160a726996f3ab4ad20312decc127
Merged-In: I59d73c1773e160a726996f3ab4ad20312decc127
2018-01-23 18:38:48 +09:00
Chenbo Feng
b25ada3657 Use /proc/net/dev to get stats summary
If the qtaguid proc file is no longer exist, the device is running new
eBPF module to do traffic accounting. So the NetworkStatsFactory need to
use the proc/net/dev interface to get the per interface traffic stats
summary. Also, adding a test to verify the helper function work properly

Bug: 30950746
Test: run NetworkStatsFactoryTest
Change-Id: Ia36808bf02f1637dd41a3e7c50917b91b1a77524
2018-01-23 00:35:02 -08:00
Chenbo Feng
7224ab835a Add bpf support for NetworkStatsFactory
Add the native method used to read the detail information of network
stats from bpf maps. The native method of NetworkStatsFactory should
choose the correct implementation to get the stats detail depending on
the kernel version. Currently the bpf result is printed as a reference
and the actual behavior of NetworkStatsFactory should not change.

Test: NetworkStatsFactory related cts test should not fail.
Bug: 30950746
Change-Id: I4715a23559b5b2306bd556cea0431f0ed172a993
2018-01-23 00:34:53 -08:00
Benedict Wong
bb31e20bcd Add checks to ensure SPIs are not reused
This change adds an additional check in CheckIpsecConfig to prevent
users from using the same SPI twice. This allows for a more granular
error message.

Bug: 70642141
Test: Tests added in IpSecServiceParameterizedTest
Change-Id: I9621fb05c6b162bd8ae8db4ac1e64feaa9d0ac73
2018-01-22 21:09:47 -08:00
Benedict Wong
22087fd1c3 Merge "Address comments and final cleanup from refcounting integration" am: 3dcee3120b am: 9b1dfec3de
am: 36efbd03c2

Change-Id: I0612286b8d95b0ae10c1337214f9c3b4e570fbac
2018-01-23 00:19:05 +00:00
Benedict Wong
3dcee3120b Merge "Address comments and final cleanup from refcounting integration" 2018-01-22 20:32:18 +00:00
Benedict Wong
c3d749e0a5 Merge "Rename create/delete transform methods" am: 77883ceedc am: 2af9354354
am: 2ec160eb05

Change-Id: Ie07b0b608b3dfcbfc4228a15e26fe6f6559315f9
2018-01-22 20:03:48 +00:00
Benedict Wong
77883ceedc Merge "Rename create/delete transform methods" 2018-01-22 17:57:15 +00:00
Lorenzo Colitti
d6aa30a780 Disable IpConnectivityMetricsTest.
This test has been failing for a while, and we are do not have
bandwidth to fix it during the next week.

Test: make -j64 FrameworksNetTests RUN_ERROR_PRONE=true
Test: atest FrameworksNetTests:IpConnectivityMetricsTest
Test: runtest -x frameworks/base/tests/net/java/com/android/server/connectivity/IpConnectivityMetricsTest.java
Change-Id: I59d73c1773e160a726996f3ab4ad20312decc127
2018-01-22 21:41:20 +09:00
Benedict Wong
01e9f19d7b Rename create/delete transform methods
CreateTransportModeTransform and DeleteTransportModeTransform are both
agnostic as far as which mode of transform it creates/deletes. As such,
to facilitate the implementation of tunnel mode, this patch renames them
to CreateTransform and DeleteTransform, along with all test names.

Bug: 63588681
Test: frameworks/base unit tests and CTS tests run, passed
Change-Id: I1f015eb7ad0e85fca966658a9402485ca2b44091
2018-01-19 10:43:01 -08:00
Lorenzo Colitti
e31ae2650d Merge changes Id8776d14,Ifa291c62,I5ea9d200 am: 5087f93c36 am: 69a42fa9c5
am: 6eb22572ce

Change-Id: I12108d96e29bfe71406106c2af950a6d6a9f8351
2018-01-19 16:46:11 +00:00
Treehugger Robot
5087f93c36 Merge changes Id8776d14,Ifa291c62,I5ea9d200
* changes:
  Track and persist in stats whether traffic is on the default network.
  Add the default network to NetworkStats and NetworkStatsCollection.
  Pass all default networks to NetworkStatsService
2018-01-19 14:48:52 +00:00
Lorenzo Colitti
9d93e1a453 Track and persist in stats whether traffic is on the default network.
This change adds the defaultNetwork to the ident based on current
system networking state, and persists that value to flash.

Bug: 35142602
Test: runtest frameworks-net
Test: downloaded files using default/non-default networks while watching dumpsys netstats
Change-Id: Id8776d149b2977548a9eb455ad4926af55e25aba
2018-01-19 19:49:16 +09:00
Lorenzo Colitti
cd969ef97c Add the default network to NetworkStats and NetworkStatsCollection.
This allows us to maintain NetworkStats entries that track
whether the traffic was on the default network.

At the moment, the stats collection code always passes in
DEFAULT_NETWORK_NO. However, this value is a no-op, since it is
not persisted to disk. Only the ident, the uid/set/tag, and the
packet/byte/operation counters are persisted.

A future change will add defaultNetwork to the ident and start
persisting it.

Bug: 35142602
Test: runtest frameworks-net
Change-Id: Ifa291c62c0fa389b88e5561086a29dcd7cee2253
2018-01-19 19:49:16 +09:00
Lorenzo Colitti
2486188d7b Pass all default networks to NetworkStatsService
This will allow NetworkStatsService to treat traffic on these
networks differently from traffic where the app selects a network
that is not the default.

Bug: 35142602
Test: runtest frameworks-net
Change-Id: I5ea9d200d9fb153490c6108bb9390bf152f297da
2018-01-19 16:40:10 +09:00
Di Lu
fcf78b1727 Add xfrm mark in IpSecConfig
Bug: 63589600
Test: runtest frameworks-net
Change-Id: I2d38d781b8b31d8bf39fd4e9a7e31509f15a9e16
2018-01-18 15:23:56 -08:00
Jeff Sharkey
d86a06f7b4 Merge "Add "not congested" network capability." am: 8a06cca651 am: 944a9864a2
am: f22a540007

Change-Id: I836fedeab34f34a43e0257e395fca1f735bc6d61
2018-01-18 04:20:44 +00:00
Jeff Sharkey
8a06cca651 Merge "Add "not congested" network capability." 2018-01-18 03:28:34 +00:00
nharold
718944eeac Merge "IpSec - API Tweak for removeTransportModeTransform" am: 656040874d am: eee6875535
am: e3ba80104d

Change-Id: I479c24d9ac5d4b022ec6310395fdb4274cfd5598
2018-01-17 20:50:14 +00:00
Benedict Wong
1142483151 Address comments and final cleanup from refcounting integration
Added some extra comments on reference counting and moved a few methods
around. No significant logical changes made in this CL

Bug: 63409385
Test: CTS, Unit tests (both frameworks-base and netd) and binder tests
all pass

Change-Id: I89f1f4a021db48ae406fefefa6aca7406045736c
2018-01-17 12:10:49 -08:00
nharold
656040874d Merge "IpSec - API Tweak for removeTransportModeTransform" 2018-01-17 19:07:10 +00:00
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
Jeff Sharkey
b04d5111ec Add "not congested" network capability.
Can be used by a network to indicate when it's congested, meaning that
apps should defer network traffic that could be done at a later time.

Test: bit FrameworksNetTests:android.net.,com.android.server.net.,com.android.server.connectivity.VpnTest,com.android.server.ConnectivityServiceTest
Bug: 64133169
Change-Id: I8a60b6f02dd0f42268b59690556c16335d34e220
2018-01-17 02:27:04 -07:00
Nathan Harold
dd2ed2bbe7 IpSec - API Tweak for removeTransportModeTransform
Because IpSecTransforms are now unidirectional,
and because the only mechanism for removing Transforms
removes it from both directions, the API can no longer
use the Transform parameter to meaningfully validate
that the caller had applied a transform. Since that
functionality was as-yet unimplemented and is now
infeasible, the transform parameter is removed.

Bug: 72079356
Test: cts - IpSecManagerTest; runtest frameworks-net
Change-Id: If19b0d34bdc6daf31a40d6d62bff326dcbca08c0
2018-01-17 01:11:46 -08: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