543 Commits

Author SHA1 Message Date
Remi NGUYEN VAN
5488c56b98 Fix interfaceVersion in DhcpServerCallbacks
The getInterfaceVersion method was missed when freezing the AIDL
interface version.
This causes Q devices to return 0 instead of 3 on this interface.

Bug: 139110717
Test: toggle tethering, dumpsys network_stack version
Change-Id: If587cc9ead4191b9c2ad2ae65473bd89e7c37b5c
2019-08-08 17:45:24 +09:00
Remi NGUYEN VAN
6dcffa0c77 Fix leak of DhcpServer on tethering stop error
Tactical, minimal fix to make sure the DhcpServer is stopped when
disabling tethering. The current code may throw if the interface is gone
when calling mNMService.setInterfaceConfig() on teardown. Make sure DHCP
is stopped regardless of what happens.

A longer term fix will be to figure out the right flow to teardown the
interface and avoid errors on setInterfaceConfig().

Bug: 124520692
Test: Manual: no more socket leaked when stopping USB tethering
Change-Id: Ib87d89a2e5fdb64b8f3dfae48d82c970f3ae6161
2019-06-24 23:28:06 +09:00
Roshan Pius
4c854cfb8e NetworkStackClient: Allow modules with network_stack uid
The wifi service will start running with network_stack uid, so allow
modules with the same uid to use the network stack interfaces.

Note: Only modules signed with the same certificate (same as network_stack
APK) can share the uid, so this is restricted to Google signed modules.

Bug: 113174748
Test: Local wifi stack testing
Change-Id: I83263770e5c17dd28e4423e46d82ac8067e98f3a
(Cherry-picked from 51e9edae314f5ef758fff0bf42e12325f8a55362)
2019-06-18 09:57:22 -07:00
Remi NGUYEN VAN
870c267b6c Merge changes I399d3e37,Ia3fdd80c,Iad90c7a4
* changes:
  Remove DeviceConfig usage from NetworkStackClient
  Simplify crash conditions in NetworkStackClient
  Proper handling of NetworkStack crash
2019-06-10 01:19:24 +00:00
Xiao Ma
4b5c8e1076 Merge "Fix the potential NullPointerException." 2019-06-08 11:21:44 +00:00
Xiao Ma
a66de9c21e Fix the potential NullPointerException.
The networkAttributesParcelable retrieved from IpMemoryStore might be
null, it might cause crash with NullPointerException when attepmting
to read from the field on a null object reference.

Bug: 122710829
Test: atest FrameworksNetTests NetworkStackTests
Change-Id: Id7527199424e55f1e14836e81a5d1965d13013a2
2019-06-07 20:30:16 +09:00
Remi NGUYEN VAN
f75f9d7925 Remove DeviceConfig usage from NetworkStackClient
DeviceConfig API is not yet submitted. Use Settings.Global instead, to
still allow writing tests against AOSP code (a test would try to use
adb shell device_config, and fallback to adb shell settings).

This is not merged anywhere else, the merged-in is here to ensure this
does not end up in branches that use DeviceConfig. This change should be
lost when AOSP is updated.

Test: flashed, force-crashed NetworkStack with different setting values:
      observe rate-limited crash
Bug: 133725814
Merged-In: I423ca6ebb328f49b170baae0da9b8409a6429fcb
Change-Id: I399d3e37f1faaecb8a30428c1989fac8821379d8
2019-06-07 14:38:43 +09:00
Remi NGUYEN VAN
714b313903 Merge "Add comments to frozen AIDL API files" 2019-06-07 01:55:52 +00:00
Remi NGUYEN VAN
2ee0c6b5f2 Add comments to frozen AIDL API files
Generated by re-freezing the API with the new aidl_interface code, and
replacing the previous API with the new files. This only adds comments.

Test: comments only, builds
Bug: 134452637
Change-Id: I6b3072e91170c97818c5fdb688d06fc612991ea1
2019-06-06 18:56:06 +09:00
junyulai
02abbfde57 Fix cannot create Nat-T keepalive on mobile data
Currently phone process fail to unparcel NattKeepalivePacketData
since it is not in framework. Moves NattKeepalivePacketData to
framework to make it can be utilized by telephony.

This change also removes the error feedback triggered by calling
add keepalive packet filter to an unsupported network agent. This
is misinterpreted by KeepaliveTracker that start keepalive is
failing.

Bug: 134048171
Test: 1. atest android.net.cts.ConnectivityManagerTest#testSocketKeepaliveLimitTelephony
      2. atest android.net.cts.ConnectivityManagerTest
      3. atest FrameworksNetTests
      4. atest FrameworksTelephonyTests
Change-Id: If630d5b339aa722717258c721daa8ead8c431e2d
2019-06-04 18:22:15 +08:00
Remi NGUYEN VAN
cfde948e4f Simplify crash conditions in NetworkStackClient
The previous model could have impact on boot time to read/write from/to
disk, and could potentially fail in some scenarios where the device does
full reboots instead of framework restarts.

The current design most simply avoids crashing in the first 30mins after
a full reboot, and optimistically checks the wall clock to rate-limit
the crashes to every 6h.

Test: manual as below, without IS_DEBUGGABLE condition
Test: Install new NetworkStack, force crash, observe rollback
Test: Set min_uptime_before_crash to 100, force crash, observe crash
Test: min_uptime_before_crash still 100, install new NetworkStack, force
      crash: observe rollback (there was already a recent crash)
Test: Set min_crash_interval to 10, force crash: observe crash
Bug: 133725814
(Clean CP from I3fd5ba7047d7ac991cb62a7cab16a40f4ee731a3)

Merged-In: Ic6b2bb13b488f46cd4b8d87caa78342f622181c3
Change-Id: Ia3fdd80c85cde45452c8e9b877836dfa4204e83d
2019-06-04 16:29:50 +09:00
Remi NGUYEN VAN
c8b197598f Proper handling of NetworkStack crash
Instead of always crashing on userdebug builds, do the following on all
builds:
 - If the device did not observe a NetworkStack crash in the last 6h
   crash the system server. This is to handle spurious crashes of the
   NetworkStack, so that the system can recover instead of staying
   without connectivity.
 - Otherwise, the device has had a recent crash. Notify the listeners
   (watchdog listener to be added) that something is seriously wrong,
   but do not crash to avoid bootlooping the device. This allows the
   watchdog to do its job, and avoids bricking the device in
   situations where the user could need to make emergency calls.

Bug: 133725814
Test: Killed the network stack, observe reboot of framework.
Test: Kill network stack again, observe nothing.
Test: Wipe data, install new network stack, kill it twice: rollback.
      (with patch on top applied)
(Clean CP from If1fa00bed769eb60ca4832609006bdf15ceddb80)

Merged-In: Ic6b2bb13b488f46cd4b8d87caa78342f622181c3
Change-Id: Iad90c7a4e416257dfe63d215274866bb25cf3d85
2019-06-04 16:26:46 +09:00
Lorenzo Colitti
836f6a4a05 Add a wrapper for INetworkMonitor.
Generated using:
./wrap_aidl.sh frameworks/base/services/net/aidl/networkstack/3/android/net/INetworkMonitor.aidl > frameworks/base/services/net/java/android/net/NetworkMonitorManager.java

Bug: 133725814
Test: builds, boots
Test: atest FrameworksNetTests
Change-Id: I9f3f2588d498a05e2405129cf58bfcdd30f45e3b
2019-05-31 19:22:32 +09:00
Xiao Ma
d91ec0907e Wipe the data in IpMemoryStore database upon network factory reset.
Bug:128499160
Test: manual
Test: atest FrameworksNetTests NetworkStackTests
Change-Id: Ib563463a861a5d27b1e9b5fbb92342249b573802
2019-05-27 15:05:09 +09:00
Lorenzo Colitti
fe0c38aed5 Properly use versioned interfaces.
Our stable AIDL interfaces need to use versioned build targets,
otherwise getVersion will always return 0, which makes it
impossible to support different components at different versions.

List generated with:
find . -name Android.bp -exec egrep \
    -H "(netd|dnsresolver|ipmemorystore|networkstack).aidl.interface(s?)-(java|cpp)" {} \;

Bug: 133124190
Test: m
Change-Id: Id175c99daa77507847673777a8dcce51897ab17b
2019-05-22 03:12:59 +00:00
Lorenzo Colitti
91dd063172 Add a factoryReset method to IIpMemoryStore, and freeze api.
Currently unimplemented. Implementation will be in a future CL.

Test: m
Bug: 128499160
Change-Id: Ia11ecd33f528d01667b1baeb8671b7213a31eef5
2019-05-20 16:43:23 +09:00
Lorenzo Colitti
80986d9a53 Support strict mode private DNS on VPNs that provide Internet.
Currently, strict mode private DNS does not work on VPNs because
NetworkMonitor does not validate VPNs. When a VPN connects, it
immediately transitions to ValidatedState, skipping private DNS
hostname resolution.

This change makes NetworkMonitor perform private DNS hostname
resolution and evaluation even on VPNs.

In order to ensure that the system always immediately switches to
the VPN as soon as it connects, remove the unvalidated penalty
for VPN networks. This ensures that the VPN score is always 101
and the VPN always outscores other networks as soon as it
connects. Previously, it would only outscore other networks
when no-op validation completed.

Bug: 122652057
Test: atest FrameworksNetTests NetworkStackTests
Test: manually ran a VPN with private DNS in strict mode
atest android.net.cts.ConnectivityManagerTest com.android.cts.net.HostsideVpnTests
Change-Id: Iaa78a7edcf23755c89d7b354edbc28d37d74d891
2019-05-10 14:30:54 +09:00
Xiao Ma
b340a6988b Merge "adopt non-blocking method to obtain the IpMemoryStore service." 2019-05-09 11:30:56 +00:00
Lorenzo Colitti
e9da42203f Add a simple wrapper for IpClient.
This takes care of boilerplate tasks such as clearing calling
identity, catching RemoteExceptions, and converting to stable
parcelable objects.

Bug: 131206163
Test: builds, boots, wifi works
Test: atest FrameworksNetTests
Change-Id: I7cbe5fc105503d0983cba2bf77fb0097bd20d9ba
2019-05-09 17:58:48 +09:00
Xiao Ma
a489a8d495 adopt non-blocking method to obtain the IpMemoryStore service.
Test: atest FrameworksNetTests
Change-Id: I7de4f23370bdf9c9df5e74ed074c794080d93d95
2019-05-09 10:39:50 +09:00
markchien
ca5ebb6234 Freeze networkstack-aidl-interfaces as version 3.
IIpClient#addNattKeepalivePacketFilter is the only difference
between version 2 and 3.

Generated with: m networkstack-aidl-interfaces-freeze-api

Test: -builds, boots
      - atest NetworkStackTests
      - atest ConnectivityServiceTest
Bug: 128803828

Change-Id: I22333c3c5930415cc43d83bc8cc6f566d0acb1f2
Merged-In: I22333c3c5930415cc43d83bc8cc6f566d0acb1f2
(cherry picked from commit a9690c1f66c63ce4dd22f622cc9980d89ad40d20)
2019-05-01 00:47:51 +00:00
Mark Chien
d157594a2a Merge "Support adding NATT keepalive packet filter" 2019-04-29 15:59:16 +00:00
Aaron Huang
9eeaa3aa9e Support adding NATT keepalive packet filter
Support adding NATT keepalive packet filter to APF
filter.
Generating APF program will be addressed in another CL.

Bug: 33530442
Test: - atest NetworkStackTests
      - atest FrameworksNetTests

Change-Id: I4961d5da343d8700600269632787c28112f0f9f1
2019-04-29 19:33:45 +08:00
Lorenzo Colitti
791dd86528 Freeze {ipmemorystore,networkstack}-aidl-interfaces as version 2.
Generated with:
m networkstack-aidl-interfaces-freeze-api \
    ipmemorystore-aidl-interfaces-freeze-api

Test: builds, boots
Bug: 128803828
Change-Id: I079018679766738a97b827bc87a6903655f308dd
2019-04-29 19:34:05 +09:00
Mark Chien
6d7ed60834 Merge "Add AIDL parcelable for NattKeepalivePacketData" 2019-04-29 10:26:35 +00:00
Lorenzo Colitti
681f33cc6a Additional code for server name in DHCP packets.
- Add the hostname to DhcpResultsParcelable.
- Don't store the server hostname if option overload is in use,
  as this is not valid.
- Add unit tests.

Bug: 120584519
Bug: 127423755
Test: atest NetworkStackTests
Test: atest FrameworksNetTests
Change-Id: I47d9d53d1fb58968322cc8b071a44fbc8f7156e1
2019-04-27 16:36:10 +09:00
Chiachang Wang
f914b77414 Add validation type definition to support multiple probe result
In order to allow NetworkMonitor to tell ConnectivityService
if the network is either parital, validated or both.
NetworkMonitor could update the probe result by passing the
bitmask to ConnectivityService.

Bug: 130078798
Bug: 130683832
Test: build
Change-Id: I429ccbd9b9afae3eafaf73b3c9eb835213c1f64d
2019-04-25 16:03:43 +00:00
Aaron Huang
76985bd9a5 Add AIDL parcelable for NattKeepalivePacketData
Bug: 33530442
Test: atest FrameworksNetTests

Change-Id: I9b9a51dc5dc06c90229fb36c34c24258991c4146
2019-04-24 16:19:54 +08:00
Aaron Huang
833edcbb1b Merge "Move NattKeepalivePacketData out of the framework" 2019-04-24 04:00:56 +00:00
Remi NGUYEN VAN
1232fe37be Freeze the networkstack-aidl-interfaces interface
This freezes the interface as of the latest beta build, not the tip of
tree. IIpClient#setL2KeyAndGroupHint is not in the frozen definition in
particular.

Generated with:
m networkstack-aidl-interfaces-freeze-api \
    ipmemorystore-aidl-interfaces-freeze-api

Test: flashed, booted, WiFi and captive portal working
Bug: 128803828
Change-Id: Ideabe73fc93bbefca2d624ee9ca190cf31419424
2019-04-23 06:49:58 +00:00
Chalard Jean
1ad99fb064 Merge changes Id598ae1d,I475bd011
* changes:
  Fix a possible crash when the listener is null
  Straighten AIDL interface for the memory store
2019-04-22 02:15:04 +00:00
Chalard Jean
f38a99dbe4 Fix a possible crash when the listener is null
Test: manual
Bug: 129930804
Change-Id: Id598ae1d98154b19d156e52973cf379669e7060c
Merged-In: I325fd3eda6e89228353342f00a49f50b22b17071
Merged-In: Id8151886ab1d26101e02f9abe9e21c58c7236623
(cherry picked from commit 28671455229a7a1b74b54fa183c6ba4cc225099f)
2019-04-22 00:40:49 +00:00
Chalard Jean
da3421e6e5 Straighten AIDL interface for the memory store
Some names were still wrong somehow, and the wrappers were
missing.

Test: NetworkStack & FrameworkNetTests
Change-Id: I475bd011ad9bc714a07021a9dfd85c4876f8e9ad
Merged-In: I475bd011ad9bc714a07021a9dfd85c4876f8e9ad
2019-04-22 00:40:28 +00:00
Aaron Huang
77e4e527a0 Move NattKeepalivePacketData out of the framework
For implementing parcelable interface for NattKeepalivePacketData.
Move this class out of framework.jar and move to services.jar

This class is used in telephony-common.jar and it also loads
service.jar.

Bug: 33530442
Test: - build pass
      - atest NetworkStackTests
      - atest ConnectivityServiceTest

Change-Id: Id2fdec5c4015d2cefd8a93e0cfdcc3c304fc9b64
2019-04-20 00:37:19 +08:00
Chalard Jean
896245a1e2 Move TrafficStats tags for the network stack constants
As per API council feedback, these constants should live in
a place that is private to the network stack, only with a
range defined in system API.

Bug: 129433383
Test: m
Change-Id: I84a90f84a9af6fef4667ee4d512ebd0413222086
Merged-In: I4882686a86e7c6d42f4b0619b921d02619ed6d4c
Merged-In: I9b648ed6c687d56db61a54570c7880c51c1bae51
2019-04-17 05:45:40 +00:00
Remi NGUYEN VAN
825181be4c Merge "Crash the system server if network stack is lost" 2019-04-10 01:41:20 +00:00
Chalard Jean
fb08776087 Merge "Move the latest AIDL update to the bottom" 2019-04-09 12:06:03 +00:00
Remi NGUYEN VAN
06f39168df Crash the system server if network stack is lost
Crash the system server if it cannot bind to the network stack, or if
the network stack crashes. This is better than keeping the system
running in a bad state where all networking would be broken.
Before the network stack was moved to a different process, the whole
system would go down when it encountered a crash.

Test: added crash in NetworkStack, verified system_server restart
Bug: 130028724
Change-Id: Ia8ee7699c4b15ba4b1116c7ba9171bf6034b52c3
2019-04-09 18:17:45 +09:00
Niklas Lindgren
afc5f9bd3d Expose captive portal urls for configuration
Carriers in Mainland China need to customize certain captive portal
urls. The main issue is that google servers are not accessible in
Mainland China.

Added the following captive portal resources to be targeted for overlay.
- config_captive_portal_http_url
- config_captive_portal_https_url
- config_captive_portal_fallback_urls (string-array)
- config_captive_portal_fallback_probe_specs (string-array)

These values can be customized for e g diffent countries

Bug: 111819230
Test: atest FrameworksNetTests NetworkStackTests
Test: Add a product RRO that targets a specific country code,
insert a SIM card that matches that country code and check the log
what URL is used.
Change-Id: I38a294a5e14417f65e96e76235ea153c53c4d7cc
2019-04-09 10:23:53 +09:00
Chalard Jean
45ff048d40 Move the latest AIDL update to the bottom
Test: m
Change-Id: I3818eb8abb5a410663a6da633d5516cef4ecad8e
2019-04-05 16:38:21 +09:00
Remi NGUYEN VAN
66d744ba74 Merge "Add a mechanism to pass the L2Key and group hint to IpClient" 2019-04-05 07:30:02 +00:00
Chalard Jean
3cab290648 Add a mechanism to pass the L2Key and group hint to IpClient
Test: IpClientTest
Change-Id: I399b20ce29a385a74971b7a7248a48cb4d66deb6
2019-04-05 12:51:04 +09:00
Remi NGUYEN VAN
fecb63075b Remove SocketUtils#setSocketTimeValueOption
This API was added in Q but is not necessary anymore as
Os#setsockoptTimeval was exposed as public API.

Test: m
Fixes: 129433363
Change-Id: Ifd04c0314f7f7c0dbd0ed89dbaf69b9c152d3330
2019-04-04 18:02:49 +09:00
Chalard Jean
e0ef7ce4f7 Merge "Cleanup SystemReady in the network stack" 2019-04-01 23:28:47 +00:00
Xiao Ma
17ea70c6d3 Merge "Add DHCP address lease expiry in IpMemoryStore." 2019-04-01 12:59:20 +00:00
Chalard Jean
d74219ba4a Cleanup SystemReady in the network stack
The system server (in SystemServer.java) defines the boot
sequence, during which an event called SystemReady happens.
This corresponds to a time when critical system services
that are depended upon by other components in the system
server are ready to handle requests from their dependencies.
Some system services are listening to this event to defer
initializations that depend on the critical services.

Because the network stack is only started after SystemReady,
there is no way any NetworkMonitor may be started before
SystemReady. Remove the associated mechanism.

Fix: 129376083
Test: FrameworksNetTests
Change-Id: I071eeb10d0b7c4f71af6653d322c7b442b2cc7ee
2019-04-01 13:32:25 +09:00
Remi NGUYEN VAN
78454f3c46 Merge "Fix race when starting NetworkMonitor" 2019-04-01 03:54:03 +00:00
Remi NGUYEN VAN
3962f678c3 Fix race when starting NetworkMonitor
NetworkMonitor obtained LinkProperties and NetworkCapabilities via
synchronous calls to ConnectivityManager after receiving an asynchronous
notification, which is prone to races: the network could be gone before
the LinkProperties/NetworkCapabilities can be fetched.

Fix the race by passing LinkProperties/NetworkCapabilities directly to
NetworkMonitor in the asynchronous notifications.

Test: atest FrameworksNetTests NetworkStackTests
Test: booted, WiFi works
Bug: 129375892
Change-Id: I200ac7ca6ff79590b11c9be705f650c92fd3cb63
2019-04-01 11:33:10 +09:00
Luke Huang
b9ef4dd299 Merge "Use IDnsResolver instead of INetd for resolver related binder commands" 2019-03-29 08:45:19 +00:00
Xiao Ma
385ccb05c8 Add DHCP address lease expiry in IpMemoryStore.
Bug:122710829
Test: atest FrameworksNetTests
Change-Id: I643fe1231edcd18923514ab66c64a6cf83e69443
2019-03-29 16:51:47 +09:00