561 Commits

Author SHA1 Message Date
Mark Chien
634c6a512f Merge "[Tether03] Migrate IpServer into module" 2019-10-25 06:41:49 +00:00
Mark Chien
72d5460dda Merge "[Tether02] Migrate TetheringConfiguration into module" 2019-10-24 13:10:24 +00:00
Mark Chien
8c26c38984 Merge "[Tether01] Add Tethering App" 2019-10-24 13:10:04 +00:00
Chiachang Wang
0825500b27 Merge "Extend netlink class to fit the data structure" 2019-10-24 07:31:53 +00:00
markchien
08cc03051a [Tether03] Migrate IpServer into module
Add IpServer which is used to serve ip configuration, dhcp, dns proxy
and nat for downstream interface.

Bug: 136040414
Test: -build, flash, boot
      -atest TetheringTests
      -atest FrameworksNetTests

Change-Id: I23652ae0b9509abe7d38da96d523eb22ab00a343
2019-10-24 14:20:52 +08:00
markchien
a6ba54d59d [Tether02] Migrate TetheringConfiguration into module
TetheringConfiguration is a utility class to encapsulate the various
configuration elements.

Bug: 136040414
Test: -build, flash, boot
      -atest TetheringTests

Change-Id: I9434ab213bc5e0fca59f14a6c8cea554abefc3a4
2019-10-24 14:00:05 +08:00
markchien
017fef23a0 [Tether01] Add Tethering App
This is initial patch that don't contain any service for now.

Bug: 136040414
Test: -build, flash, boot
Change-Id: I0b49d7e9c3fcba5af3025163f9cc9eafb0778116
2019-10-24 13:35:41 +08:00
Chiachang Wang
5d62167efc Extend netlink class to fit the data structure
In order to get the tcp_info via netlink socket from kernel,
NetworkStack needs to use netlink class to pack and parse the
InetDiagReq. Current design hardcodes ididag_ext field in
InetDiagReqV2. The structure is also not allowed to take null
id to not to specify certain socket. Update the constructor and
backward support exising constructor.

Bug: 136162280
Test: atest FrameworksNetTests NetworkStackTests
Change-Id: Id66da1797da183ae3d99073f80bad1df929946dc
2019-10-23 21:52:36 +09:00
Jimmy Chen
8a9a9adaeb Merge "p2p: mirgrate p2p into tethering modes" 2019-10-18 05:42:31 +00:00
Jimmy Chen
bcd86d0c9b p2p: mirgrate p2p into tethering modes
Bug: 137602441
Bug: 139783330
Test: atest FrameworksNetTests
Test: atest FrameworksWifiTests
Test: CtsVerifier - Wi-Fi Direct
Test: Enable hotspot when P2P GO is running
      * P2P GO is terminated
      * hotspot is running
Test: Enable P2P GO when hotspot is running
      * hotspot is intact
      * P2P GO could not be launched
Test: Verify P2P functions with legacy WifiP2pService

Change-Id: Icb2e2b106ae52b19af29b7a1ebc55d3cdf80db9c
2019-10-08 14:37:19 +08:00
Jeff Vander Stoep
59940afb16 Fix FD leak in ConnectivityManager.getConnectionOwnerUid
Add unit tests to verify that bug has been fixed.

Re-enable testGetConnectionOwnerUid() unit tests in presubmit. These
were disabled due to test flakiness caused by expected failures passing
as a result of other sockets on the system. This is fixed by checking
that failures do not have the UID of the calling process instead of
INVALID_UID since previously some Qualcomm telephony sockets were
causing lookup successes.

Test: atest InetDiagSocketTest#testGetConnectionOwnerUid
Test: ls -1 /proc/<pid of system_server>/fd | wca
Test: atest --generate-new-metrics 200 InetDiagSocketTest#testGetConnectionOwnerUid
   To verify flakes have been cleaned up.
Bug: 141603906
Bug: 141459241
Change-Id: Ib76674f10e4bd24952c557bac7b9c65fba42fdb2
2019-09-30 12:46:03 +02:00
Remi NGUYEN VAN
ee27a94773 Move NetworkStack AIDLs to NetworkStack folder
The AIDLs and ipmemorystore-client were already statically linked
libraries, so their location in the source tree does not change anything
(they were already built into the NetworkStack module and the
framework). It makes more sense to have them in the NetworkStack module
folder however, as changes to these files will be released with the same
cadence as the module, not the framework.

Bug: 139106271
Test: built, flashed, WiFi working
Change-Id: I886acae850a5e8a9a7bc3ca8aac8690d681ca2cd
2019-09-05 17:55:48 +09:00
Treehugger Robot
288c75d055 Merge "Refactor Module connectors for testing" 2019-09-02 03:41:32 +00:00
Remi NGUYEN VAN
91e39d9a45 Refactor Module connectors for testing
Move getModuleServiceIntent to a dependencies object to allow clients to
create test versions of the class that return test intents and avoid the
permissions checks.

Refactor dependencies in NetworkStackClient in a dependencies object for
the same test purposes.

Test: manual: built, booted, WiFi working
Change-Id: I9b115f4cd26f36eee5c669226ea6296b8d7d2d06
2019-08-30 15:15:34 +09:00
Luke Huang
6fecb94292 Merge "Support enable/disable dns forwarding of dnsmasq when start tethering" 2019-08-28 12:53:16 +00:00
Remi NGUYEN VAN
341c0f026a Fix spacing in NetworkStackClient
This makes the file match other branches, which should eliminate merge
conflicts.

Test: m
Merged-In: I673581b0067b9a3f72dd68a3ab622c18183ebd2e
Change-Id: Ida685159cb4afd6eceac6941e7126886518c8570
2019-08-28 10:59:34 +09:00
Roshan Pius
15b5a03ef6 NetworkStackClient: Refactor network stack process interaction
Refactor NetworkStackClient class to move the module service binding &
network stack process death monitoring to a separate class. This class
will only instantiated in the SystemServer process.
The new class |SystemServerToNetworkStackConnector| will be used from
the client classes corresponding to each module running on the network
stack process (NetworkStackClient, WifiStackClient, etc)

This has 2 main advantages:
a) Reduces code duplication (Otherwise the various Client classes need
to replicate the service bindding & process death monitoring).
b) Central crash recovery for the network stack process (Otherwise the
various Client classes will trigger multiple recovery for a single
network stack process crash).

Bug: 135679762
Test: Device boots up & connects to wifi networks.
(cherry-picked from 7e6f5f5e080f2d2ae3ef0397c21bd666f5ce4d31 & applied
aosp/977048)

Change-Id: I673581b0067b9a3f72dd68a3ab622c18183ebd2e
Merged-In: I673581b0067b9a3f72dd68a3ab622c18183ebd2e
2019-08-23 10:40:07 -07:00
Luke Huang
b0d52464f1 Support enable/disable dns forwarding of dnsmasq when start tethering
Bug: 128782815
Test: built, flashed, booted
Change-Id: Ic6ee985b42cbe77e8f2208fba62108604fc7bbcf
2019-08-20 20:42:13 +08:00
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