Commit Graph

636 Commits

Author SHA1 Message Date
Lorenzo Colitti
ae53ea1874 Delete the clatd functions from NetworkManagementService.
Make Nat464Xlat talk to netd directly instead of through
NetworkManagementService. The methods in NetworkmanagementService
don't really provide any value: since the only thing they do is
call into netd, we might as well have the callers talk to netd
directly,

In order to do this, pass INetworkManagementService and INetd to
the NetworkAgentInfo constructor, and update callers appropriately.

Bug: 65674744
Test: builds, boots
Test: atest FrameworksNetTests
Change-Id: Iac4cfe709c6279e4d9682b6754963e533707bd12
2019-01-15 11:13:07 +09:00
Remi NGUYEN VAN
8539129ad9 Move NetworkMonitor to NetworkStack
Bug: b/112869080
Test: atest FrameworksNetTests NetworkStackTests
Change-Id: I1b8b6a3f4390adbabf92fb9e48da61c47b08b2ec
2019-01-11 09:59:11 +09:00
junyulai
879dbfa624 Ignore ipv6 tx traffic on clat uid.
Currently, 464xlat counts its ipv6 tx traffic into root uid.
When user is making ipv4 upload over ipv6-only network, ipv4
tx traffic may sometimes be counted faster then ipv6 tx
traffic.

Thus, NetworkStatsService may detect non-monotonic values due
to 464xlat adjustment.

So the solution is that: for clatd, make ipv6 tx traffic counts
into clat uid, and then ignore it in the framework side.

Bug: 118602783
Test: 1. manually verify clatd traffic on clat uid.
      2. runtest frameworks-net

Change-Id: Ifb478b79e3e281918c70e16d1f90682c78f33db1
2018-12-10 15:19:03 +08:00
Treehugger Robot
a3713ac30d Merge "Call netd to update the tcp buffer size" 2018-12-06 19:01:24 +00:00
Luke Huang
a904fab046 Use ParcelFileDescriptor instead of FileDescriptor in INetd.aidl
Stable aidl won't support FileDescriptor but ParcelFileDescriptor.
In order to migrate to stable aidl, replace all FileDescriptor in
INdetd.aidl.

Test: runtest frameworks-net passes
Change-Id: Icdf37aed0e0cce0352070a437066e77c0f2fd85a
2018-11-28 13:41:58 +08:00
Chenbo Feng
1541629a3f Call netd to update the tcp buffer size
The system server is controlling the tcp buffer now by writing to
/sys/kernel/ipv4/tcp_{rmem,wmem}_{min,def,max}. Those files are
basically the same as /proc/sys/net/ipv4/tcp_{rmem,wmem} except those
latter ones contain all three values in one file. Netd can directly write
to those files so we no longer need to depend on these android specific
files.

Test: netd_integration_test
Bug: 118572798
Change-Id: I588b48be29ecf61fd5bbf94f97f63738be4eae25
2018-11-27 15:37:52 -08:00
Junyu Lai
687cb5a0ed Merge "PermissionMonitor: Move intent receiver to ConnectivityService." 2018-11-27 01:48:59 +00:00
Benedict Wong
12b70569f9 Add XFRM-I support to IpSecService
This change adds support for XFRM-I to all IpSecService netd calls.
Fallback logic is in netd, and thus both VTI and XFRM-I parameters are
always passed down to IpSecService.

Bug: 78589502
Test: All java, CTS tests passing
Change-Id: Ie4186f0ad7e50763b21831f6fa411b5ee436de78
2018-11-21 08:34:54 -08:00
junyulai
df46b35279 PermissionMonitor: Move intent receiver to ConnectivityService.
Currently, PermissionMonitor listen to user add/remove and
package add/remove intent respectively, and so does VPN.
Thus, races might occurr between them.

This commit refactor PermissionMonitor part by using
ConnectivityService to listen to intents and dispatch events
to PermissionMonitor.

Bug: 118811303
Test: 1. atest FrameworksNetTests
      2. manually add/remove package

Change-Id: I6e45b5870d5b1300cad252d25bdb4da78f9bf70e
2018-11-21 12:17:10 +09:00
Josh Gao
bc2208a2a2 Avoid calling ParcelFileDescriptor.fromSocket on new Sockets.
Previously, we were calling ParcelFileDescriptor.fromSocket on a newly
initialized Socket, which doesn't actually create a file descriptor
until the Socket is bound or connected.

Bind the Socket to a random port to force the file descriptor to be
allocated.

Test: treehugger
Change-Id: Id92a3e1316881d1c5382485aa2d6a41fc37e9651
2018-11-09 14:10:40 -08:00
Junyu Lai
e666ae6ee5 Merge "Use spy in PermissionMonitorTest." 2018-11-09 08:47:03 +00:00
junyulai
4ae90ee86e Use spy in PermissionMonitorTest.
Bug: 118811303
Test: runtest frameworks-net
Change-Id: Id61a9efecf1d1ed5a9045b78ecfec9239e13967b
2018-11-09 12:37:16 +08:00
soma, kawata
4d041d5caa Add skip464xlat test in Nat464XlatTest
Bug: 69949375
Test: Nat464XlatTest, ConnectivityServiceTest

Change-Id: Ibc66d9c2dc8e3d1f118e5f6940e7b3fd4646efd1
2018-11-06 06:02:50 +00:00
paulhu
8e38c05bb3 Support backward compatibility for restricted network permission
Some native daemons legacy design work with SYSTEM_UID. If none of
SYSTEM_UID apps declare the restricted network permission, it will
result in permission denial in daemons. Allow SYSTEM_UID in the
devices shipped before Q to support backward compatibility.

Bug:114245686
Test: 1. runtest frameworks-net
      2. atest FrameworksNetTests
      3. Native daemons with SYSTEM_UID can work normally

Change-Id: I6f3f0d83bcae74ef5389535b528af3baf649fa48
2018-11-01 10:38:11 +08:00
junyulai
e06923946c No-op refactoring of VPN lockdown status check.
Currently, if VPN lockdown is disabled, the blocking judgement
inside VPN will return false immediately. It will make
ConnectivityService hard to check blocked status by a given
VPN lockdown status.

Thus, move this check into ConnectivityService and check it
externally.

Bug: 117814902
Test: 1. manual test with 3rd-party vpn app
      2. runtest frameworks-net

Change-Id: Ia8319b1a1a12f1058c24badf2431f2ec69bc78e7
2018-10-25 16:43:50 +08:00
Mike Yu
96612aedb1 Add tests for the network blocked status change
onBlockedStatusChanged is intruduced for network blocked status.
The changes in this patch are:
  - Test onBlockedStatusChanged which tells apps whether the
    network is blocked.
  - Fixed the tests which is affected by the order changed in
    onAvailable.

Test: as follows
    - runtest frameworks-net
    - runtest -x NetworkPolicyManagerServiceTest.java
Bug: 74575553
Change-Id: I383c037ed895ef69c478dc3cff69fb1e27c42845
2018-10-19 19:52:50 +08:00
evitayan
e54eee0130 Check to ensure UDP-encap is used only for IPv4
This commit checks if UDP-encapsulation is used
for unsupported address family and throws
IllegalArgumentException when it happens.

Bug: 74213459
Test: Tests added in testCreateTransportModeTransformWithEncap
      and testCreateTunnelModeTransformWithEncap.
      Command: runtest frameworks-net
      Verified on taimen.
Change-Id: I10c01f2bad6aca23430849ea9ef6c1eb157ae131
2018-10-04 11:44:00 -07:00
evitayan
1ab508d361 Add UDP encapsulation tests for IpSecService.
This commit adds tests to ensure that IpSecService properly
handles UDP-encapsulation transforms correctly.

Bug: 76110065
Test: Added: testCreateTransportModeTransformWithEncap,
             testCreateTunnelModeTransformWithEncap.
      Command: runtest frameworks-net
      Verified on taimen.
Change-Id: Ie05bc5354266806c2d03b0b3d73a4696a89eccf2
2018-10-04 10:37:47 -07:00
Treehugger Robot
75e74f759d Merge "Allow wifi and ethenet connected at same time." 2018-10-02 17:09:16 +00:00
Leif Hendrik Wilden
838c66128f Allow wifi and ethenet connected at same time.
This will improve the user experience on Android TV devices,
see bug for details.

In addition when connecting adb to the device by ethernet
for cts, wifi will not connect, causing lots of tests to fail.
For example:
[CTS7.1]android.net.wifi.cts.WifiInfoTest#testWifiInfoProperties
[CTS7.1]android.net.cts.ConnectivityManagerTest#testConnectivityChanged_
manifestRequestOnlyPreN_shouldReceiveIntent

Use command:settings to put global wifi_data_always_on 1 to enable it.

Bug: 26102779
Test: Manual, CTS.
Change-Id: I711d93061a6bc7164d98a858912f781e1b967406
2018-10-01 09:12:10 -07:00
Chiachang Wang
c8019ecef2 Merge "Fix idle timer rule leakage" 2018-10-01 02:20:23 +00:00
Chiachang Wang
087fd275f9 Fix idle timer rule leakage
Idle timer rule is not cleared as expected if there is a
default network replacement.

Bug:37080406
Test: 1.run frameworks-net
      2.check iptables rule with default network replacement

Change-Id: I6bd29d79e4ca3e8de4b867c4fcb5f81d02ba6de4
2018-09-28 22:42:48 +08:00
Remi NGUYEN VAN
b7c67f8e24 Call clearSettingsProvider before and after test
FakeSettingsProvider requires this method to be called before and after
use. Without this, the settings value or content provider may be cached
statically, so the test will be affected by code accessing settings
before it is run.

Bug: b/116668105
Test: atest FrameworksNetTests
Change-Id: I1480f3f3bbb17791752582a70327bb5c7c348d7c
2018-09-28 14:46:34 +09:00
Benedict Wong
c268c30491 Use UID as requestID
This change makes all requestIDs use the UID of the creator, ensuring
that rekeys always use the same requestID. This also has the nice
property of separating app's resources from each other, and allowing for
identification of which app/UID allocated the resources from
command-line dumps (eg ip xfrm state show)

Bug: 111841561
Test: Updated tests & passing taimen
Change-Id: I4f1eadcdb795766ae4682b15e41727359c52fa38
2018-09-04 14:25:13 -07:00
paulhu
c7a3a56e57 PermissionMonitor: Limit preinstalled apps network permissions
Not all preinstalled apps should have access to background
networks or restricted networks. But we give them all network
access permissions currently, it's not a good design. So we
shall limit preinstalled apps permissions, they should just
request the appropriate permission for their use case from
the network permissions.

Bug:19610688
Test: runtest frameworks-net
Change-Id: I184ae3197208c979847ca134c8f01b32528badf1
2018-08-29 13:49:33 +08:00
Remi NGUYEN VAN
5dd7f07260 Fix testRegisterUsageCallback failure in setUp
LocalServices.addService in NetworkStatsService is currently failing
with IllegalStateException "Overriding service registration". Setting up
LocalServices in the test to avoid this issue might be possible, but
moving the registration to the only non-test caller of that constructor
as done here solves the issue and avoids side-effects from a constructor.

Test: atest FrameworksNetTests does not choke on this test
Bug: b/78487385
Bug: b/80082746
Change-Id: I5dba98fc79aec0800c8b71e6c7e23d1cfbcae852
Merged-In: I884a7a8bd7db3fcd220b785ba9914ac8c77720f0
(Clean cherry-pick of go/ag/4061255)
2018-08-14 18:14:09 +09:00
Remi NGUYEN VAN
6ee63e03dc Merge "Add tests for NetworkMonitor isCaptivePortal" 2018-08-08 04:59:12 +00:00
Remi NGUYEN VAN
de25687203 Add tests for NetworkMonitor isCaptivePortal
Bug: b/79499239
Test: added tests, ConnectivityService tests pass

Change-Id: I98d503b8f92d7f35e59dd1621a90f2eca8c7a63c
2018-08-07 08:57:35 +00:00
Remi NGUYEN VAN
86bbc9e887 Merge "Increase network request timeouts"
am: dab690a61a

Change-Id: Iaae31d7eaa5e5ccccdcf63ba39dd3fdc729161a5
2018-07-27 06:08:08 -07:00
Remi NGUYEN VAN
68225bc676 Merge "Use timeout consts in all ConnService tests"
am: bbba1f7f9f

Change-Id: Ie62b9893c5b5f4e7b24197c1308d33e06a6c8f71
2018-07-27 00:11:06 -07:00
Remi NGUYEN VAN
524ea05e39 Increase network request timeouts
With recent performance degradations on apct, the current timeouts are
too short and some requests trigger onUnavailable() before networks are
validated.

Test: runtest -x ConnectivityServiceTest.java
Bug: b/111778226
Change-Id: I083f529787f108065637a0aff3e5bb88e05e6510
2018-07-27 15:37:13 +09:00
Remi NGUYEN VAN
626885b750 Use timeout consts in all ConnService tests
Fix some timeouts that were forgotten in parent CL.

Bug: b/111778226
Test: runtest --no-hidden-api-checks -x ConnectivityServiceTest.java
Change-Id: Ib848eaba8c69c07ac596aa4386a741c9a2a87fc9
2018-07-27 11:47:25 +09:00
Remi NGUYEN VAN
3b498060f6 Merge "Increase linger delay and test callback timeout"
am: 0544dfde7e

Change-Id: I088de7dae4191a65e75feb9e071dcf18c30dcf21
2018-07-26 04:10:02 -07:00
Remi NGUYEN VAN
b6bd15ac29 Increase linger delay and test callback timeout
Tests appear to have become much slower on apct in recent runs, although
local runs do not seem to be affected. As a first measure, increase our
timeouts to eliminate flakyness.

Bug: b/111778226
Test: runtest --no-hidden-api-checks -x ConnectivityServiceTest.java
Change-Id: I7a3bfb646eb554bcd9d50d026142f2a2cff74beb
2018-07-26 16:43:58 +09:00
Remi NGUYEN VAN
6cbacfa17e Merge "Increase TEST_LINGER_DELAY_MS"
am: 9a783699cc

Change-Id: Iff68ee39ead571293877464c03ab98ab594dfcca
2018-07-24 22:05:37 -07:00
Remi NGUYEN VAN
50cb7dbc11 Increase TEST_LINGER_DELAY_MS
The current timeout is short enough that lingered networks are torn down
before assertions can be run, causing flakyness in testMultipleLingering.
This CL sets the timeout to 300 in that particular test.

Verified that 300ms is enough with 500 successful runs on Sailfish.

An alternative would be to mock firing of the lingering timer, but
keeping the WakeupMessage logic realistic has already proven useful in
detecting races.

Bug: b/110673602
Test: runtest --no-hidden-api-checks frameworks-net
Change-Id: I6f9a656190bcff0b071ae2584d0f5fa74158472b
2018-07-19 17:12:38 +09:00
Chalard Jean
e71a3833fe Merge "Add StackedLinkProperties test case"
am: faf31f8638

Change-Id: I33d75bf593708317dca4ba6cec035b7f035cfa86
2018-06-20 21:23:17 -07:00
junyulai
74f9a8b52a Add StackedLinkProperties test case
Change access level of getNetworkAgentInfoForNetwork in ConnectivityService to get
better testability. And add test case to verify clat state transition and make sure
linkProperties are updated correctly.

Bug: 80261579, 109913107
Test: runtest frameworks-net -c com.android.server.ConnectivityServiceTest \
          -m testStackedLinkProperties
Change-Id: I72fce594d74bd349f65557edca03640e1b86317c
2018-06-19 16:53:08 +08:00
Nathan Harold
1db89848ab Disable the AppOp Restriction for IpSec Tunnels
This CL temporarily removes the AppOp restriction
that disallows creation of IpSec tunnels due to
the lack of the appropriate AppOp in AOSP/master.
When the relevant framework merges out to master,
this CL should be reverted.

Manually merging this due to skipping a merge
conflict at 9fe9ec18c1

Bug: none
Test: compilation
Change-Id: Ic06c193f85f6bcdd0ead4238825c1add78703cde
2018-06-08 23:23:04 +00:00
nharold
ff904be7a9 Merge changes from topic "ipsec-sync-with-pi"
* changes:
  Disable the AppOp Restriction for IpSec Tunnels
  Rework Exception Handling for IpSecManager
  Update IpSecManager to use InetAddress and prefixLen
  Add AppOps Checks for MANAGE_IPSEC_TUNNELS
  Add MANAGE_IPSEC_TUNNELS Permission
2018-06-08 17:07:11 +00:00
Nathan Harold
71fc014f00 Disable the AppOp Restriction for IpSec Tunnels
This CL temporarily removes the AppOp restriction
that disallows creation of IpSec tunnels due to
the lack of the appropriate AppOp in AOSP/master.
When the relevant framework merges out to master,
this CL should be reverted.

Bug: none
Test: compilation
Change-Id: Ic06c193f85f6bcdd0ead4238825c1add78703cde
2018-06-07 18:44:34 -07:00
Nathan Harold
2a9b2c8165 Add AppOps Checks for MANAGE_IPSEC_TUNNELS
Adds support for a new AppOp to permit services to
use IpSec tunnel mode. The IpSecService now needs
a context so change the service mode to a cached
service rather than a static service.

Bug: 66955045
Test: runtest frameworks-net
Merged-In: I17a4a286225b432c3e15ea1587d946189931b4f4
Change-Id: I17a4a286225b432c3e15ea1587d946189931b4f4
(cherry picked from commit 68a7edf1cb)
2018-06-07 18:42:52 -07:00
Chalard Jean
ec3d62faa5 Unify behavior of various cases of "no underlying networks"
Before this change, VPNs having no underlying networks would be
marked as metered as the safe option, but VPNs having only
disconnected underlying networks would be marked as unmetered.
Fix this discrepancy.

Clean cherry-pick of ag/4113809

Bug: 79748782
Test: runtest frameworks-net
Change-Id: Ie6ace6bd95139605ffcfa8cd6c15cf28f8fa28c8
Merged-In: If19b85325e7d684e645470293b3c8a674084c641
Merged-in: I22f80a6a39d4a19ff74aa61fcbd66f1a041b1003
2018-06-06 08:25:10 +00:00
Chalard Jean
22670f9b93 Fix: VPNs update caps upon underlying network disconnect.
Clean cherry-pick of ag/4083954

Bug: 79748782
Test: ConnectivityServiceTests still pass
Change-Id: I21e866c723099e5c3dee54ff13e830d44427fc7a
Merged-In: I12c948ebeb2b74290908f8320ff77220dc4a9fb9
2018-06-06 08:25:02 +00:00
Chalard Jean
32f9daa029 Add tests for setUnderlyingNetworks.
Fixes come later. This is complex enough as it is.

Clean cherry-pick of ag/4083953

Bug: 79748782
Test: new test passes, old tests still pass
Change-Id: If7276fe1f751be7b9c18f689e97699e566e5bde0
Merged-In: I12c948ebeb2b74290908f8320ff77220dc4a9fb9
2018-06-06 08:24:51 +00:00
Chalard Jean
818f6b5c6a Make sure getActiveNetwork is consistent with default callbacks
Almost clean cherry-pick of ag/3889538.

Bug: 77737389
Test: runtest framework-net
      new test don't pass without the main code change, but they
      do with it
Change-Id: I0cd83a935ab0b349aa47e065b830e5a43ab9a091
Merged-In: Iaa0285825735d3f16bba6e4946723a437fd9b0b9
Merged-In: Ia8f985b448251f911484e6bd63fa562bffc1b0e4
2018-06-06 08:24:21 +00:00
Chalard Jean
d94e48ff95 Add tests for getActiveNetwork.
Clean cherry-pick of ag/3918295
One-line adjustment for ag/3638326 which has not been put in AOSP.

Bug: 77737389
Test: runtest frameworks-net
Change-Id: I03ae2bbb08559f2cd44979e291c1f5d50eb215da
Merged-In: Iaa0285825735d3f16bba6e4946723a437fd9b0b9
Merged-In: Ia8f985b448251f911484e6bd63fa562bffc1b0e4
2018-06-06 08:24:12 +00:00
Remi NGUYEN VAN
bbfe4d043f Merge "Migrating remaining core networking tests to Junit4" 2018-05-25 03:27:39 +00:00
Remi NGUYEN VAN
3f6d2b08ad Merge changes I3b3bcbbd,I18b3f263,I3c416c1a
* changes:
  Use CaptivePortalProbeSpec method in portal app
  Add configurable captive portal probes
  Move CaptivePortalProbeResult to its own file
2018-05-24 07:53:00 +00:00
Hugo Benichi
e17657c0f1 Migrating remaining core networking tests to Junit4
Bug: 62918393
Test: runtest frameworks-net
Merged-In: I30f7eaa0307b8fad5a8de7a0da235a4f76c18677
(clean cherry-pick of I30f7eaa0307b8fad5a8de7a0da235a4f76c18677)

Change-Id: I272fea0bb4a9e7f6252bb3bd14a6b769a082039e
2018-05-24 16:24:47 +09:00