Commit Graph

732 Commits

Author SHA1 Message Date
Lorenzo Colitti
7b0732fff7 Change Nat464Xlat lifecycle.
Currently, NetworkAgentInfo keeps a Nat464Xlat object only on
networks where we're starting clatd (i.e., IPv6-only networks).
Simplify this code by making the Nat464Xlat object final and
always non-null. This allows us to use Nat464Xlat to store
information, such as the NAT64 prefix, even if the clat daemon
has not been started yet.

Also, remove the STOPPING state which waits for the interface to
be removed. Instead, when stop() is called, immediately enter the
IDLE state.
- This is necessary in order to be able to call start() again
  before the interface removal notification has arrived.
- It's also arguably more correct than the current code,
  because when stop() returns clatd has already terminated
  (ClatdController::stopClatd calls waitpid), and thus the tun
  fd is already closed and the tun interface is gone.

Also, now that Nat464Xlat objects are reused after stop(), add
test coverage for calling start() after stop, in both cases:
- The notification that the previous interface was removed
  arrives before the second start().
- The notification that the previous interface was removed
  arrives after the second start() but before the notification
  that the second interface was added.

Also fix a couple of lint warnings.

Test: builds, boots
Test: atest FrameworksNetTests
Test: clatd stops when IPv4 address added
Test: clatd restarts after "adb shell killall clatd"
Change-Id: I3dc66d155aa27606681f3473daf2170434d8c6d0
2019-02-25 11:42:00 +09:00
Lorenzo Colitti
c11592ce7c Minor improvements to verifyTcpBufferSizeChange.
1. Remove "throws Exception" from the signature so it can be used
   in tests that do not already throw Exception.
2. Update comment to reflect the fact that TCP buffer sizes are
   set on default network switch, not on connect.
3. Move into the method a class-level static constant that is
   only used in that method.

Test: atest ConnectivityServiceTest
Change-Id: Ic2e4fbedc23065efc20e45ea84996b577a8e94b6
2019-02-25 11:41:50 +09:00
Treehugger Robot
c7702baa80 Merge "Update VPN capabilities when its underlying network set is null." 2019-02-15 11:33:27 +00:00
Remi NGUYEN VAN
4616612b6b Merge "Move NetworkStack to services.net" 2019-02-15 10:52:03 +00:00
Remi NGUYEN VAN
ef59a21ff4 Move NetworkStack to services.net
NetworkStack is only used in services.net or clients of services.net. It
cannot stay in framework.jar because it needs to depend on AIDL
interfaces, which would conflict with app implementations if they were
in framework.jar.

Test: atest FrameworksNetTests NetworkStackTests
Bug: 124033493
Change-Id: Ib1d08a3669983640119d008db7e2990fa798724f
Merged-In: I501b125a388c1100c2182bde4670944c2f0d7a02
2019-02-15 12:20:17 +09:00
Varun Anand
df56995870 Update VPN capabilities when its underlying network set is null.
Previously, they were only updated when underlying network set was
non-null.

This change also ensures that all the calls b/w ConnectivityService and
Vpn that leads to updating capabilities are on ConnectivityService
handler thread.

Additionally, it also ensures that capabilities are propagated after VPN
enters connected state. This was previously done from establish which
could potentially lead to race between VPN getting connected and
capabilities getting updated.

This change also updates VPN capabilities inline from
ConnectivityService handler thread. Previously, there was an additional
loop where Vpn would update capabilities via NetworkAgent thru
AsyncChannel which posts back to CS handler thread, which could
potentially lead to delays in updating VPN capabilities.

Bug: 119129310
Bug: 118856062
Bug: 124268198
Test: atest FrameworksNetTests
Test: manual - verified VPNs capabilities are getting updated and
DownloadManager is working correctly.

Change-Id: Id0abc4d304bb096e92479a118168690ccce634ed
2019-02-14 18:50:56 -08:00
Remi NGUYEN VAN
9a9e288607 Merge "Fix flaky testNattSocketKeepalives" 2019-02-14 03:29:00 +00:00
Remi NGUYEN VAN
b76f9ee4e6 Fix flaky testNattSocketKeepalives
The test did not wait for the WifiNetworkAgent to disconnect, and there
are reports of flakes where it is still connected in
connectKeepaliveNetwork.

Test: atest FrameworksNetTests
Bug: 124319553
Change-Id: I85968806885c8853ec4f4dbea356366c1af0ea1c
2019-02-14 03:28:48 +00:00
Remi NGUYEN VAN
794c7f2ee3 Remove hard-coded NetworkStack package name
Have the network stack pass its package name in
showProvisioningNotification instead.

Bug: 124033493
Test: flashed, WiFi and captive portal works
Test: atest FrameworksNetTests NetworkStackTests
Change-Id: I1f3312768ba1fb34e99a827e1fcdaf7510e318a8
2019-02-08 12:12:57 +09:00
junyulai
80d0356311 [KA03.5] Add stable AIDL parcelable for TcpKeepalivePacketData
Bug: 114151147
Test: atest FrameworksNetTests
Change-Id: I057dde79013b9eda5037b9a44f8eee06cc07352e
2019-02-06 14:07:39 +09:00
markchien
e5591ce2fa [KA03] Support tcp keepalive offload
When offload is starting, socket will be switched to repair
mode. Read and write on the socket will not be allowed until
repair mode is turned off. If remote packet arrives, repair
mode will be turned off automatically and a callback will
be raised to indicate that socket is ready to read from.

Bug: 114151147
Test: -atest FrameworksNetTests
      -manual

Change-Id: I0c335865912e183e7ad32a8ea12188f02ccde5fd
2019-02-06 12:22:22 +09:00
junyulai
011b1f15c2 [KA02] internal cleanup and refactor for SocketKeepalive
In previous change, the new SocketKeepalive API was exported.
But internally, old PacketKeepalive names and structures are
still used.

This change rename them properly for code consistency and also
refactor KeepalivePacketData to support different types of
KeepalivePacketData.

Bug: 114151147
Test: 1. atest FrameworksNetTests
      2. atest FrameworksWifiTests
      3. atest FrameworksTelephonyTests

Change-Id: Ia9917d12987e91e87e34ffb3f126e7bc7c9c187e
Merged-In: Ia9917d12987e91e87e34ffb3f126e7bc7c9c187e
2019-02-05 20:13:47 +09:00
Varun Anand
35200a3b8a Merge "Add an API that allows VPNs to declare themselves as metered." 2019-01-31 02:43:25 +00:00
Varun Anand
83759ee94b Add an API that allows VPNs to declare themselves as metered.
For VPN apps targeting Q and above, they will by default be treated as
metered unless they override this setting before establishing VPN.

Bug: 120145746
Test: atest FrameworksNetTests
Test: On device tests verifying meteredness setup correctly for apps
targeting Q and apps targeting P.
Change-Id: Ia6d1f7ef244bc04ae2e28faa59625302b5994875
2019-01-30 14:09:03 -08:00
Remi NGUYEN VAN
6e82be4e4a Remove last NetworkStack usage of hidden APIs
Includes various small changes to stop using hidden APIs

Test: make NetworkStack
Test: flashed, booted, WiFi and tethering working
Bug: 112869080
Change-Id: Id2830795a444f484b377ed6437435a1cd833697a
2019-01-30 10:23:24 +09:00
Pavel Grafov
76e3e0052c Merge "Whitelist packages from VPN lockdown." 2019-01-28 20:15:49 +00:00
Remi NGUYEN VAN
8f8deae60f Merge "Move NetworkUtils used by NetworkStack" 2019-01-28 09:06:20 +00:00
Remi NGUYEN VAN
e167e117c1 Move NetworkUtils used by NetworkStack
Depending on usage move into NetworkStackUtils or shared
Inet4AddressUtils.

Test: atest FrameworksNetTests NetworkStackTests
Bug: 112869080
Merged-In: Ie20dcee375b377236004a7689890729493aca857
Change-Id: Ib8d000529872796022706a35050fdc2c7141f2ab
2019-01-28 13:45:17 +09:00
Remi NGUYEN VAN
8bd18cff9a Add NetworkStack networking deps to SystemApi
Cherry-pick with conflicts fixed in CaptivePortalLoginActivity imports.
Test: atest FrameworksNetTests
Bug: 112869080
Merged-In: Id59dc06fb85e4ac88098f56b621ec880610759ce
Change-Id: I3c05e8fdd70497426d4fa433295c4fbdad07d9c9
2019-01-28 13:28:35 +09:00
Pavel Grafov
3aeb3f3455 Whitelist packages from VPN lockdown.
Bug: 77468593
Test: atest com.android.server.connectivity.VpnTest
Change-Id: I9119c139ab07a761ce5dfd1365b70eb905fd32dc
2019-01-25 19:59:03 +00:00
Dan Albert
7e81ae73b4 Merge "Revert "Whitelist packages from VPN lockdown."" 2019-01-24 21:08:46 +00:00
Dan Albert
45f1a24661 Revert "Whitelist packages from VPN lockdown."
This reverts commit f1a610a1c2.

Reason for revert: broke pi-dev-plus-aosp

Change-Id: Iaf5c8aa4a8720eb2852da8cd91c81a77ccb92b68
2019-01-24 21:05:39 +00:00
Treehugger Robot
b11e29d4b3 Merge "Add API for proxy configuration over VPN." 2019-01-24 17:52:22 +00:00
Pavel Grafov
bec7854508 Merge "Whitelist packages from VPN lockdown." 2019-01-24 17:34:55 +00:00
Pavel Grafov
f1a610a1c2 Whitelist packages from VPN lockdown.
Bug: 77468593
Test: atest com.android.server.connectivity.VpnTest
Test: atest MixedDeviceOwnerTest#testAlwaysOnVpn
Test: MixedDeviceOwnerTest#testAlwaysOnVpnAcrossReboot
Change-Id: I7f6c5b9172063b588feacd6b9930a6cb88f764ab
Merged-In: I7f6c5b9172063b588feacd6b9930a6cb88f764ab
2019-01-24 16:17:11 +00:00
Irina Dumitrescu
de132bb6d6 Add API for proxy configuration over VPN.
Test: runtest -x
frameworks/base/tests/net/java/com/android/server/ConnectivityServiceTest.java
&& atest HostsideVpnTests
Bug: 76001058
Change-Id: Id4dde4a4103fd93bfbbacc52d0e5ade56ae67a6a
Merged-In: Id4dde4a4103fd93bfbbacc52d0e5ade56ae67a6a
2019-01-24 16:07:20 +00:00
Lucas Lin
01eeab4954 Merge "Popup a notification after logging in the captive portal network" 2019-01-24 11:06:12 +00:00
lucaslin
b1e8e385dd Popup a notification after logging in the captive portal network
Captive portal app will be auto dismissed after user login the
captive portal network. In order to improve the user experience,
popup a notification to notify user that the captive portal
network is connected.

Bug: 113629026
Test: 1.atest FrameworksNetTests:NetworkNotificationManagerTest
      2.Connect to a captive portal network and login, check if
      there is a notification popup.

Change-Id: Id54d12268e107af2f213c2bb348c5f7908e880f4
2019-01-24 15:55:30 +08:00
junyulai
d05a192fbe [KA05] Export keepalive offload api for IpSec Nat-T file descriptor
Adds system api of createSocketKeepalive to take file descriptor,
so privileged apps could use it without the need of IpSecService.

Bug: 114151147
Test: atest FrameworksNetTests
Change-Id: If926c21704b6ed73a0adfcadad732b97b42bacae
2019-01-24 00:40:25 +08:00
junyulai
4c95b08a23 [KA01] export SocketKeepalive API for NAT-T keepalive
The new set of API replace the PacketKeepalive system API
which is only specific for IPsec NAT-T keepalive packet. Allows
applications to request different types of keepalives through
the same set of API.

By using keepalives, applications could request system to
periodically send specific packets on their behalf, using
hardware offload to save battery power.

This change would only address interface change and test part of
original functionality. After all reference of PacketKeepalive
are removed, another change would be submitted to remove old
API.

Bug: 114151147
Test: atest FrameworksNetTests
Change-Id: I3367666810acc44d5ad20e19acd4bf936e8b5d9c
2019-01-23 23:17:17 +08:00
Lorenzo Colitti
bb5952107d Merge "Stop depending on the ConnectivityService default request." 2019-01-23 12:29:40 +00:00
Lorenzo Colitti
0d1aaee1dd Stop depending on the ConnectivityService default request.
This avoids the need to expose ConnectivityService implementation
details as @SystemApi and the complexities that would be required
to make NetworkCapabilities parcelable in stable AIDL.

Bug: 112869080
Test: atest FrameworksNetTests NetworkStackTests
Change-Id: Icd5d25b9b8e9b7a7d1899b000c92dc4976c3b3d7
2019-01-23 18:10:06 +09:00
Chalard Jean
2b428221cb Merge changes If71fadd2,I42047185
* changes:
  [MS10] Address leftover comments on MS03 and MS07
  [MS09] Implement isSameNetwork.
2019-01-22 22:50:21 +00:00
Pavel Grafov
5e135e2bdc Merge "Add API for VPN apps to query always-on and lockdown." 2019-01-22 14:43:06 +00:00
Chalard Jean
7f8be9f6ca [MS09] Implement isSameNetwork.
Test: Old tests pass, new tests pass too.
Bug: 113554482

Change-Id: I420471853f3fab7725cba7ae500cebdce1912e43
2019-01-22 19:10:48 +09:00
Remi NGUYEN VAN
bda2c4fe17 Merge "Add NetworkStack metrics to system API" 2019-01-22 07:48:39 +00:00
Lorenzo Colitti
4433025623 Properly expect all callbacks in testStackedLinkProperties.
Currently testStackedLinkProperties accounts for some of the
NetworkCallbacks that are fired, but not all of them. The test
passes because it only ever expects LinkProperties changed
callbacks (and not, e.g., lost callbacks), because it uses
waitForIdle(), and because at the end, when the callback is
unregistered, it does not call assertNoCallback().

Add the missing callback expectation and expect a LOST callback
at the end. Also add an assertNoCallback, even though it's not
strictly necessary. Remove all the waitForIdle statements, which
are no longer necessary because every assertion happens after
waiting for a callback.

Making the expectations more precise in a separate CL will help
ensure that upcoming changes to this code don't break anything,
and will make said changes easier to review.

Bug: 65674744
Test: atest FrameworksNetTests
Test: ConnectivityServiceTest#testStackedLinkProperties passes 400 times
Change-Id: I73cda0dd029a0e6546f7272beedf841ce5a4c0dc
2019-01-22 10:53:00 +09:00
Remi NGUYEN VAN
c8bf99d5d9 Add NetworkStack metrics to system API
Test: atest FrameworksNetTests NetworkStackTests
Bug: 112869080
Change-Id: Ie52c55f248c173e2a5ee603ecd004fbac9004ac1
2019-01-21 23:24:41 +00:00
Pavel Grafov
e87b7ceaa6 Add API for VPN apps to query always-on and lockdown.
Test: atest MixedDeviceOwnerTest#testAlwaysOnVpn
Bug: 72628179
Change-Id: I73cb0888f7049b12ab0cdfa62678c3846e074d3b
2019-01-21 13:48:45 +00:00
Chalard Jean
b8997229ad [MS08] Read back attributes and blobs.
Test: New tests in IpMemoryStore
Bug: 113554482

Change-Id: I2ddfef0c2ed37459c038f75d1dfc92fdefbf58f5
2019-01-21 15:21:09 +09:00
Josh Gao
5ceb563f51 Merge "Avoid calling ParcelFileDescriptor.fromSocket on new Sockets." 2019-01-18 22:25:35 +00:00
Etan Cohen
107ae95001 [CS] Add an option to block sensitive network specifier
Network specifiers are used for 2 purposes:

- As part of network requests to specify more information on the type
  of requested networks.
- On network agents to specify information about their networks.

The network specifiers of the requests and agents are matched to each
other. However, the agent network specifier may contain sensitive
information which we do not want forwarded to any app.

This CL adds an option to strip out this agent network specifier before
the network capabilities are forwarded to the app.

Bug: 122160111
Test: atest ConnectivityServiceTest (frameworks/base/tests/net)
Test: atest frameworks/base/tests/net
Test: atest frameworks/opt/net/wifi/tests/wifitests
Test: atest frameworks/opt/telephony/tests/telephonytests
Test: atest frameworks/opt/net/ethernet/tests
Test: atest android.net.cts - some flakiness!
Test: act.py ThroughputTest
Test: act.py DataPathTest
Test: atest SingleDeviceTest (cts)
Change-Id: If08d312ff814bdde1147518f923199e6349503d5
2019-01-17 16:30:05 -08:00
Lorenzo Colitti
1d3bf3d90c Test parceling empty LinkProperties.
Test: atest FrameworksNetTests
Change-Id: Iec53a9fdce1ba1db86751ea5f14a11d28be543eb
2019-01-15 12:53:59 +09:00
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
Lorenzo Colitti
981b34f6b8 Add the NAT64 prefix to LinkProperties.
Currently we support exactly one NAT64 prefix. This matches what
other components in the system (Dns64Configuration, clatd, etc.)
support.

Test: atest FrameworksNetTests
Change-Id: I45a11cebe43a5e1c60d50eca7889cb317565b598
2019-01-12 02:16:34 +09:00
Chalard Jean
6dd2486300 [MS02] Write the skeleton for the IP memory store.
This implements a minimal contract for the IP Memory Store
feature.

Test: Created new tests for parcelable code. For the rest, created
      empty tests, but there is no logic, it's boilerplate day
Bug: 116512211
Change-Id: I15dc6275b370d671385ddfdb058a8b8d39952d6e
2019-01-11 15:01:00 +09:00
Chalard Jean
d3829de504 [MS01] Add the IP memory store service.
Bug: 116512211
Test: Added initial tests
Change-Id: I9d9af4097e3e2d7afd9956b9cbfa29a9f9558ae0
2019-01-11 15:00:36 +09:00
Remi NGUYEN VAN
b35979db6b Merge "Move NetworkMonitor to NetworkStack" 2019-01-11 05:08:52 +00: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
Chalard Jean
a99e1eeb9d Merge "Add PCSCF to LinkProperties." 2019-01-10 05:55:05 +00:00