Commit Graph

1189 Commits

Author SHA1 Message Date
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
Di Lu
3fef704896 Add xfrm mark in IpSecConfig
Bug: 63589600
Test: runtest frameworks-net
Change-Id: I2d38d781b8b31d8bf39fd4e9a7e31509f15a9e16
2018-01-18 15:23:56 -08: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
002831b7c0 Merge "IpSec - API Tweak for removeTransportModeTransform" am: 6725ff729b am: d58b237445
am: a2411eb8ee

Change-Id: I479c24d9ac5d4b022ec6310395fdb4274cfd5598
2018-01-17 20:50:14 +00: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
77af60dd1d Merge "Prevent Closure of Underlying Socket FDs" am: 3cff120fcb am: 31f05d66ca
am: 5a653d2ec7

Change-Id: I3ab796cc17d5ee2e4a2c8838bac2ada4831c755f
2018-01-17 10:14:43 +00:00
Nathan Harold
ff097d9e93 Make Transforms Unidirectional am: 5a19b9500d am: f4fc2714c2
am: ab40c5ac15

Change-Id: I608be255a307891ec3fe2d97cda817d75240c95c
2018-01-17 10:03:31 +00: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
3de5545763 Merge "Add validation to IpSecConfig algorithm setters" am: 53e5d21924 am: c93df5ca1c
am: c135035ab6

Change-Id: I7ff85771945c68025ce8d66ca85313bac087b3a5
2018-01-09 21:23:35 +00: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
8dddc0d093 Merge changes from topic "ipsec-resource-id-cleanup" am: 2b36299c73 am: d7319df4d0
am: f81e9dcf6a

Change-Id: Ib96b30bcb1b47c23d0a18cf043dd042409c61322
2018-01-08 20:29:11 +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
Jeff Sharkey
a6886af481 Add DataUnit to clarify SI-vs-IEC units.
Mirrors the design of TimeUnit and ChronoUnit which many developers
are already familiar with, making it easy to pick up and use.

Yes, this is an enum.

Bug: 70915728
Test: bit FrameworksCoreTests:android.util.DataUnitTest
Change-Id: Id0cfdac5c81ed89c3c9ece23c964acba4a4f8471
2018-01-07 19:06:01 -07: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
c080279fe4 Merge "Fix CTS Test Dual Stack Test Passing Issue" am: ae81e15c9c am: a19acb6ac8
am: 3e4af1dfe7

Change-Id: I39839d144f75340c1b327ed0af180e66db770914
2018-01-04 19:07:19 +00: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
Tetsutoki Shiozawa
47c245b6e9 Definitely abort reconnecting to native daemon during shutdown
Symptom:
System_server crashed due to unsolved "netd" service.

Root cause:
My previous patch was not enough for avoiding this crash.
a00d4b0 Abort connecting to native daemon during shutdown

listenToSocket loop can be finished without throwing exception.

Solution:
It's better to test shutdown condition before reconnection even
though listenToSocket is finished without exception.

Bug: 68742327
Change-Id: Ifdfe43d52bef891f55bd7b07cc1aa0fa248a6030
2017-12-26 17:10:33 +09:00
Chenbo Feng
fa05f2bf30 Merge "Use NetworkStatsService to get stats for apps" am: 8469cd614d am: fa7f4015fc
am: 2e6aabced1

Change-Id: I90ce68a72afbf596e28d987e925795709d24dd52
2017-12-21 19:49:25 +00: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
7f98793aa7 Merge "[ipsec-doze] Add fchown to IpSecService to support doze" am: 4edb4c8ec4 am: 5949912523
am: ad2180c3ba

Change-Id: Id6a5ff71ead4566b9a91b9e9b6c78d81f1ac0f54
2017-12-20 18:58:30 +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
0ee0b691f7 Merge "[ipsec-qtaguid] Tag sockets upon creation of encap sockets" am: cd534c6990 am: 8caa274ade
am: 073572a677

Change-Id: I4140f386687c579044f9b5fe59dd7e05f86000fe
2017-12-19 00:41:55 +00: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
Android Build Merger (Role)
e3ccb35df6 Merge "Merge "[CHERRY-PICK] API for apps to tag sockets with their own UID." am: 476398c50d am: 826657a9c2" into oc-mr1-dev-plus-aosp
am: 11448df5a1  -s ours

Change-Id: I3289c409e2014c898cba8ba14768ea174937ffed
2017-12-18 22:14: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
Benedict Wong
476398c50d Merge "[CHERRY-PICK] API for apps to tag sockets with their own UID." 2017-12-18 21:32:10 +00:00
Benedict Wong
083faee14a [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
Jeff Sharkey
1fb74318cf [CHERRY-PICK] API for apps to tag sockets with their own UID.
This enables app A to create a socket, pass it to app B, and have
app B accept blame for the traffic performed on that socket.

Also adds helpful public APIs for tagging raw FileDescriptor sockets
instead of making developers go through shady SocketImpl wrappers.

Test: cts-tradefed run commandAndExit cts-dev -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.AppSecurityTests#testAppFailAccessPrivateData
Bug: 63932076
Change-Id: I08925c843974675fc82e4080cec2eaab9ab7cd41
Merged-In: I08925c843974675fc82e4080cec2eaab9ab7cd41
(cherry picked from commit 4e164f9e94)
2017-12-18 19:44:40 +00:00
nharold
05e99ef743 Merge "Use consistent naming for allocating SPI." am: 816f0ebaab am: 4753ed4b1b
am: 63f6a5625f

Change-Id: Ib6845ab0d7f385fbd1d59c0179771542e12c8be0
2017-12-14 21:48:58 +00:00
nharold
63f6a5625f Merge "Use consistent naming for allocating SPI." am: 816f0ebaab
am: 4753ed4b1b

Change-Id: Ib5d89044313341790b1ee9271642072ddce181af
2017-12-14 21:36:32 +00:00
nharold
816f0ebaab Merge "Use consistent naming for allocating SPI." 2017-12-14 21:10:16 +00:00
TreeHugger Robot
4f47e565a9 Merge "Add more IntDef prefixes for auto-documenting." 2017-12-14 07:17:52 +00:00
Jeff Sharkey
f95fb35f01 Add more IntDef prefixes for auto-documenting.
Test: builds, boots
Bug: 70177949
Exempt-From-Owner-Approval: annotation-only changes
Change-Id: I76dde6054e06f52240bd4b1a0f196dcb74623608
2017-12-13 20:05:36 -07:00
Benedict Wong
d49373feb3 Merge "Convert IpSecService resources to use refcounting" am: 670db0329b am: 8698b33cc2
am: 8d32535eec

Change-Id: Ib18839d7dff8e25898f81e877337fbb8cb24cc7b
2017-12-14 02:41:28 +00:00
Benedict Wong
8d32535eec Merge "Convert IpSecService resources to use refcounting" am: 670db0329b
am: 8698b33cc2

Change-Id: I9645df5304d7f11068d190cbdaccfe83ca0580bc
2017-12-14 02:20:20 +00:00
Benedict Wong
670db0329b Merge "Convert IpSecService resources to use refcounting" 2017-12-14 01:45:15 +00:00