Commit Graph

1038 Commits

Author SHA1 Message Date
Benedict Wong
ac94b41c42 Merge "Add checks to ensure SPIs are not reused" am: 66aa524a04
am: 1a2e3f3b54

Change-Id: I8c7243bc600e5f2e9abec03b5a357ed6376aa9bf
2018-01-23 19:55:47 +00:00
Lorenzo Colitti
d1e9c2795c Merge changes from topic "multipath-datausage-backport" am: 1afa23dade
am: c46c21c702

Change-Id: I45f0c69e3440e9ec69c82e81c41bea682a359389
2018-01-23 19:43:13 +00:00
Lorenzo Colitti
cc323a7179 Add metered, roaming, and defaultNetwork info to NetworkTemplate. am: 75ec1aed18
am: e383807d7f

Change-Id: I1faf95edec0e836c69016c84ad2a2c8518f8eb53
2018-01-23 19:39:18 +00:00
Lorenzo Colitti
aa2d703fd6 Add the defaultNetwork element to the netstats.proto. am: 0ba426b8a1
am: adcb94472a

Change-Id: I292e903617d3af1867529e68eb20538afb66f665
2018-01-23 19:30:57 +00:00
Lorenzo Colitti
4ee6a6fb12 Add getDefaultNetwork to the NetworkStats public API. am: 92a946d09f
am: 66eab17abc

Change-Id: If0aa0a4522df0061645d34cb3af8a33f288ed46d
2018-01-23 19:28:14 +00:00
Benedict Wong
66aa524a04 Merge "Add checks to ensure SPIs are not reused" 2018-01-23 18:00:06 +00:00
Lorenzo Colitti
1afa23dade Merge changes from topic "multipath-datausage-backport"
* changes:
  Support passing a template to NetworkStatsManager queries.
  Add metered, roaming, and defaultNetwork info to NetworkTemplate.
  Unbreak frameworks-net tests broken by missing libutilscallstack.
  Disable IpConnectivityMetricsTest.
  Add the defaultNetwork element to the netstats.proto.
  Add getDefaultNetwork to the NetworkStats public API.
2018-01-23 15:22:18 +00:00
Lorenzo Colitti
75ec1aed18 Add metered, roaming, and defaultNetwork info to NetworkTemplate.
This will allow data usage clients to query for and receive
callbacks on data usage matching these conditions.

Bug: 35142602
Test: atest FrameworksNetTests
Change-Id: I4d985a2734eeab7ee454c09cc2098b6b3c671c23
Merged-In: I4d985a2734eeab7ee454c09cc2098b6b3c671c23
2018-01-23 18:38:48 +09:00
Lorenzo Colitti
0ba426b8a1 Add the defaultNetwork element to the netstats.proto.
This is in its own commit because AOSP has diverged from internal
master.

Bug: 35142602
Test: builds, boots
Change-Id: I75fc85b961bc919e3d6c2adce6d6861c6f2c8379
Merged-In: I75fc85b961bc919e3d6c2adce6d6861c6f2c8379
2018-01-23 18:38:48 +09:00
Lorenzo Colitti
f1b197b23b Support passing a template to NetworkStatsManager queries.
Currently, NetworkStatsManager queries and callbacks only allow
selecting network traffic based on network identifiers:
networkType, subscriptionId and networkId.  The code ends up
converting these into a template under the hood.

Now that templates can express more fine-grained queries (e.g.,
select only roaming traffic, or select only traffic that's not
on the default network) add a hidden method to pass in a
template. This should have no security implications, as all the
access controls are performed in NetworkStatsService.

Bug: 35142602
Test: android.app.usage.cts.NetworkUsageStatsTest passes
Change-Id: Iab4afa26b34544299d2a9c501c1b0feb470e90a9
Merged-In: Iab4afa26b34544299d2a9c501c1b0feb470e90a9
2018-01-23 18:38:48 +09:00
Lorenzo Colitti
92a946d09f Add getDefaultNetwork to the NetworkStats public API.
This allows an app using the public API to know whether the
traffic in a particular bucket was on the default network
(i.e., the network was selected by the system), or not (i.e.,
the network was selected by the app).

Bug: 35142602
Test: builds, boots
Test: added coverage to NetworkUsageStatsTest CTS test, still passes
Change-Id: I9f6669908fa119743b9c0aa0c31a03e5ebafa7db
Merged-In: I9f6669908fa119743b9c0aa0c31a03e5ebafa7db
2018-01-23 18:28:07 +09:00
Benedict Wong
68aac2affa 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
Lorenzo Colitti
56cc2e9765 Merge "Remove obsolete NetworkStats.Entry constructor." am: ebb1d92eb8
am: cdeb50aa48

Change-Id: If60b58f95707bab3ae89050234226d54386398e8
2018-01-23 02:23:32 +00:00
Lorenzo Colitti
ebb1d92eb8 Merge "Remove obsolete NetworkStats.Entry constructor." 2018-01-23 00:15:15 +00:00
Benedict Wong
d8166b064c Merge "Address comments and final cleanup from refcounting integration" am: faa9b02efc
am: 8130c2a718

Change-Id: I7ed4a6bb90f3cf3ed5fd0e6ad20b033e588a4c90
2018-01-23 00:08:17 +00:00
Benedict Wong
faa9b02efc Merge "Address comments and final cleanup from refcounting integration" 2018-01-22 20:32:18 +00:00
Benedict Wong
f5aae7f1a3 Merge "Rename create/delete transform methods" am: da6956a702
am: 5b71c4a0a5

Change-Id: I16bfb511ac2d6094e246f79d51fe4520d3e765cd
2018-01-22 19:53:15 +00:00
Benedict Wong
da6956a702 Merge "Rename create/delete transform methods" 2018-01-22 17:57:15 +00:00
Lorenzo Colitti
9ab3929812 Remove obsolete NetworkStats.Entry constructor.
The only caller is telephony code, and it's being fixed in this
topic.

Bug: 35142602
Test: builds, boots
Change-Id: Ia77a1c2c297037f311c2355610c206cd8e3192c4
2018-01-21 23:01:35 +09:00
nharold
e7e979071c Merge "Add Tunnel Interface APIs to IpSecManager" am: a82dbcb3c7
am: 696cff166c

Change-Id: I0cd07c51e9512b7e9471e1a09c977fca2bf12e48
2018-01-19 20:16:38 +00:00
nharold
a82dbcb3c7 Merge "Add Tunnel Interface APIs to IpSecManager" 2018-01-19 19:43:17 +00:00
Benedict Wong
0fff56eae5 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
0d74e0554c Merge changes Id8776d14,Ifa291c62,I5ea9d200 am: c48f4cb7f1
am: b36b423230

Change-Id: I1ac9d349850d607c5fbf4a47760bc09de1c18043
2018-01-19 16:37:44 +00:00
Lorenzo Colitti
ab7807a5bb 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
3e85855083 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
28d1a529d5 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
Nathan Harold
67e7673adf Add Tunnel Interface APIs to IpSecManager
Add a new interface and a new management object,
IpSecTunnelInterface to the IpSecManager surface.
This object will be used to control IPsec tunnels.

-Add IpSecTunnelInterface object
-Add methods to create and use an IpSecTunnelInterface
-Update the IpSecTransform builder to create Tunnel
 mode IpSecTransform objects (usable with an IpSecTunnel)

Bug: 36033193
Test: compilation
Change-Id: Ib6948b12c15c93674234dc36288058ae44435b90
2018-01-17 16:14:17 -08:00
nharold
a2411eb8ee Merge "IpSec - API Tweak for removeTransportModeTransform" am: 6725ff729b
am: d58b237445

Change-Id: Id9e9ab09669a53f53f03e5a6e0e4757434c3f3f3
2018-01-17 20:39:29 +00:00
Benedict Wong
cbd329b14a 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
5a653d2ec7 Merge "Prevent Closure of Underlying Socket FDs" am: 3cff120fcb
am: 31f05d66ca

Change-Id: I1ecac95dc1c4be573d5411a335f94c6a6511d4bd
2018-01-17 10:02:51 +00:00
Nathan Harold
ab40c5ac15 Make Transforms Unidirectional am: 5a19b9500d
am: f4fc2714c2

Change-Id: Ie3ca37e14d977fd255a7791ae3332ddda29ab37e
2018-01-17 09:50:37 +00:00
Nathan Harold
0d483b76f3 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
Nathan Harold
3167625a15 Prevent Closure of Underlying Socket FDs
The version of applyTransportModeTransform() and
removeTransportModeTransform() that accepted
Socket and DatagramSocket were closing the underlying
FDs upon return. It's unclear whether this is due to
a behavior change elsewhere in ParcelFileDescriptor,
but either way, converting to using getFileDescriptor$
and then calling dup() explicitly rather than relying
on ParcelFileDescriptor seems like a better idea anyway.

Bug: 72047396
Test: CTS - IpSecManagerTest.testCreateTransform()
Change-Id: Ia2f02564e1289f25bf113dbb861fcfd2240537a7
2018-01-16 21:30:20 -08:00
Nathan Harold
5a19b9500d 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
Benedict Wong
c135035ab6 Merge "Add validation to IpSecConfig algorithm setters" am: 53e5d21924
am: c93df5ca1c

Change-Id: I45289bc8e8b93f7eb912a76a10b951b1a615338a
2018-01-09 19:51:19 +00:00
Benedict Wong
53e5d21924 Merge "Add validation to IpSecConfig algorithm setters" 2018-01-09 18:18:28 +00:00
nharold
f81e9dcf6a Merge changes from topic "ipsec-resource-id-cleanup" am: 2b36299c73
am: d7319df4d0

Change-Id: If6ab575e2f30fc70d73e6f8787c87f3c7a2ab09d
2018-01-08 20:16:08 +00:00
Benedict Wong
70867e55f7 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
Nathan Harold
fdafce24cf IpSecService - Convert mNextResourceId from AtomicInt to Int
The mNextResourceId variable is only accessed within synchronized
blocks, so there is no need to use an atomic integer to synchronize
it. This eliminates the misleading notion that the variable is
accessed outside of guarded blocks, which it is not.

Bug: 62279167
Test: cts
Change-Id: I815835622659f54d2d2d33b349b17c632ebced8d
2018-01-04 15:28:29 -08:00
Nathan Harold
5e8544685d IpSec Invalidate the Resource IDs on close()
To facilitate error checking we should invalidate
the resource IDs of all objects when we close() them.
Today, the resource ID is invalidated on the Transform
object but not on the SPI or Encap Socket. This CL
unifies the behavior.

Bug: 70641274
Test: cts - IpSecManagerTest
Change-Id: I28caec3e913902c748c6a50b4ef742ccef8b1b09
2018-01-04 15:28:29 -08:00
Manoj Boopathi Raj
3e4af1dfe7 Merge "Fix CTS Test Dual Stack Test Passing Issue" am: ae81e15c9c
am: a19acb6ac8

Change-Id: Ica9ded5c7bdbeb243c63a3ebb1ca273d4c8f4138
2018-01-04 18:59:41 +00:00
manojboopathi
ac927fe532 Fix CTS Test Dual Stack Test Passing Issue
CTS test should fail if IPV6 Sockets is used on IPV4 address.
Unfortunately its been passing fine due to unhandled catch
exception. This is fixed in this CL.

Bug: 64435904
Test: Ran CTS test to verify ./run_cts.sh
Change-Id: I369c1b5baaa64b64feaa3f298e61f46d1200ea17
2018-01-02 13:39:13 -08:00
Chenbo Feng
2e6aabced1 Merge "Use NetworkStatsService to get stats for apps" am: 8469cd614d
am: fa7f4015fc

Change-Id: I14f614a86214bd4f006415c48b9a8323e06c737f
2017-12-21 19:15:29 +00:00
Treehugger Robot
8469cd614d Merge "Use NetworkStatsService to get stats for apps" 2017-12-20 20:30:54 +00:00
Benedict Wong
ad2180c3ba Merge "[ipsec-doze] Add fchown to IpSecService to support doze" am: 4edb4c8ec4
am: 5949912523

Change-Id: I9036fc2768dd9664ab7407b359f3c689c7ce700e
2017-12-20 18:42:26 +00:00
Chenbo Feng
aa7ba31c8e Use NetworkStatsService to get stats for apps
Move the native implementation of TrafficStats to NetworkStatsService
and apps need to get the NetworkStatsService binder interface from
system_server in order to get the network usage stats since boot. This
implementation can hide the detail of retrieving network traffic
information from apps and the NetworkStatsService can choose which
methoed it use to get the data depending on the kernel version of the
device.

Bug: 30950746
Test: CtsNetTestCases -t android.net.cts.TrafficStatsTest
Change-Id: I53bbefd19aa0b783b9b4b42ea4d76db3e9ec07a3
2017-12-19 19:57:44 -08:00
Benedict Wong
073572a677 Merge "[ipsec-qtaguid] Tag sockets upon creation of encap sockets" am: cd534c6990
am: 8caa274ade

Change-Id: I2f27c76a1f493ff4f0bd423c06f159e629866d4d
2017-12-19 00:27:57 +00:00
Benedict Wong
1768744a3d [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
cd534c6990 Merge "[ipsec-qtaguid] Tag sockets upon creation of encap sockets" 2017-12-18 23:50:52 +00:00
Benedict Wong
59dd893f9e Merge "[CHERRY-PICK] API for apps to tag sockets with their own UID." am: 476398c50d
am: 826657a9c2

Change-Id: Ia06653e6c1cccddcd2de17dd88a9ef47263f5c79
2017-12-18 21:56:41 +00:00