Commit Graph

36956 Commits

Author SHA1 Message Date
lucaslin
4eb7434fed Ignore checking TRANSPORT_USB when Android version is older than S am: eadb0add66
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1764733

Change-Id: Idbe4a10d48e80ebab1b98bf083d2326e6281d55d
2021-07-14 09:26:45 +00:00
lucaslin
eadb0add66 Ignore checking TRANSPORT_USB when Android version is older than S
There is a new transport type - TRANSPORT_USB(8) in Android S,
so when the test tries to add this new transport type in older
Android version, it cannot pass the transport type validation and
make test fail.

(clean cherry-pick of change in downstream branch history)
Original change ID before project move:
I38816173b04ea198d99f64f45e9271ac2641e4ac

Bug: 184158327
Test: run CtsNetTestCasesLatestSdk on Android R & Q
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Change-Id: Ib0368241771d287c09c0e4463f91122533f85a27
2021-07-14 16:28:58 +09:00
Treehugger Robot
9743c8165e Merge "Skip bpf offload if upstream interface is VCN" am: 097d65b0f3
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1764307

Change-Id: Iee7c4eeaad1aa00b47699bec2838e692ae88edcf
2021-07-13 17:31:09 +00:00
Treehugger Robot
097d65b0f3 Merge "Skip bpf offload if upstream interface is VCN" 2021-07-13 17:16:04 +00:00
markchien
7dc1b4da7b Skip bpf offload if upstream interface is VCN
Bpf offload do not support VCN network yet, don't start bpf offload
if the interface is ipsec*.

Bug: 191178945
Test: atest TetheringTests
Change-Id: I1ad8cededddec42f45b08aaa31d583c548d105f0
2021-07-13 15:35:31 +00:00
Nucca Chen
d0b818fa8a Merge "[CTT-7] Delete the rules while half-closing tcp state entered" am: f7c8cec604
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1755173

Change-Id: Ia2243c777d696e1f5bd94d8afd42d43ba1c1d48e
2021-07-13 12:17:54 +00:00
Nucca Chen
f22f935082 Merge "[CTT-6] Update TCP conntrack entry timeout while adding rules" am: db30678605
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1760692

Change-Id: Ie5b26c90bc7e7677259ce1be85ce55002cf03d2e
2021-07-13 12:17:48 +00:00
Nucca Chen
23e3eadde5 Merge "[CTT-5] Stop update TCP conntrack entry timeout" am: 69ccea4839
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1760691

Change-Id: Ib1e1c1f2ccdf85bd3a7fd2275abb7ee144207b58
2021-07-13 12:17:43 +00:00
Nucca Chen
f7c8cec604 Merge "[CTT-7] Delete the rules while half-closing tcp state entered" 2021-07-13 12:07:12 +00:00
Nucca Chen
db30678605 Merge "[CTT-6] Update TCP conntrack entry timeout while adding rules" 2021-07-13 12:07:05 +00:00
Nucca Chen
69ccea4839 Merge "[CTT-5] Stop update TCP conntrack entry timeout" 2021-07-13 12:06:55 +00:00
Hungming Chen
118b5b578a [CTT-7] Delete the rules while half-closing tcp state entered
This is fixing post-FIN state (by disabling offload post-FIN).
Once the tcp state enters half-closing tcp state (fin wait,
close wait), delete the offload rules.

From this commit, we have done the short term solution for conntrack
tcp timeout issue. Here is what we have done so far.
- Stop updating tcp timeout to avoid updating wrong tcp state
  timeout.
- Update the ESTABLISHED timeout
  nf_conntrack_tcp_timeout_established (432000) after adding
  bidirectional rules.
- Delete the tcp rules when the tcp state has left
  "established".

Here is the long term solution and need to be addressed in follow up
commits.
- Parse the tcp state from netlink conntrack event.
- Build a mapping to trace the tcp state of the tcp conntrack event.
- Update tcp state timeout for {ESTABLISHED (432000), FIN_WAIT (120),
  CLOSE_WAIT (60)}.

Bug: 190783768
Bug: 192804833
Test: atest TetheringCoverageTests

Manual test:
1. Browse on tethered device
2. Check conntrack tcp state is established.
   $ cat /proc/net/nf_conntrack
   ipv4     2 tcp      6 431995 ESTABLISHED src=192.168.207.9
   dst=140.112.8.116 sport=50697 dport=443 ..
3. Check offload rules are added via dumpsys.
   Upstream:
     tcp .. 192.168.207.9:50697 -> 14(rmnet0) 10.224.1.247:50697
     -> 140.112.8.116:443 ..
   Downstream:
     tcp .. 140.112.8.116:443 -> 30(30) 10.224.1.247:50697
     -> 192.168.207.9:50697 ..
4. Stop browsing for a few seconds.
5. Check conntrack tcp state is half-closed.
   $ cat /proc/net/nf_conntrack
   ipv4     2 tcp      6 116 TIME_WAIT src=192.168.207.9
   dst=140.112.8.116 sport=50697 dport=443 ..
5. Check offload rules are removed via dumpsys.
   Upstream:
     (not found)
   Downstream:
     (not found)

Change-Id: I07e27230bf8952acd7828d1f605167758b3bc490
2021-07-13 14:28:58 +08:00
Hungming Chen
299a81157c [CTT-6] Update TCP conntrack entry timeout while adding rules
Needed because a payload data packet may have gone through
non-offload path, before we added offload rules, and that this
may result in in-kernel conntrack state being in ESTABLISHED
but pending ACK (ie. UNACKED) state. But the in-kernel conntrack
might never see the ACK because we just added offload rules.
As such after adding the rules we need to force the timeout back
to the normal ESTABLISHED timeout of 5 days.

Issue: the timeout is set to unacknowledged 300s (countdwon to 298s)
$ adb shell cat /proc/net/nf_conntrack
ipv4     2 tcp      6 298 ESTABLISHED src=192.168.244.128
dst=140.112.8.116 sport=45694 dport=443 ..

Test: atest TetheringCoverageTests
Manual check:
$ adb shell cat /proc/net/nf_conntrack
ipv4     2 tcp      6 431988 ESTABLISHED src=192.168.40.162
dst=140.112.8.116 sport=40774 dport=443 ..

Bug: 190783768
Bug: 192804833

Change-Id: I8c34e85e26c9d976e5e2b85473db75ff46d8abd4
2021-07-13 14:28:30 +08:00
Hungming Chen
a5c742be69 [CTT-5] Stop update TCP conntrack entry timeout
This is a preparation for only update the tcp timeout while
adding rules. Also add slack time for updating UDP timeout
interval.

Bug: 190783768
Bug: 192804833

Test: atest TetheringCoverageTests
Change-Id: I3151b531e6581e257f3cfa39ad2fcf1650358b3d
2021-07-13 14:26:58 +08:00
Maciej Żenczykowski
ae7fb09d69 Merge "[CTT-4] Improve conntrack timeout update logging" am: 8d2e46aec3
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1760690

Change-Id: Ifdf2ef4dae1d295d9a27f04863efd136c4c5c808
2021-07-13 02:28:28 +00:00
Maciej Żenczykowski
9fd842569e Merge "[CTT-3] Add a string converter for TCP and UDP protocol number" am: 7d3d4eaca7
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1762187

Change-Id: I01167aa9e2754e7fd26054c62f49aa29f6201ffb
2021-07-13 02:28:23 +00:00
Maciej Żenczykowski
45805fe7f0 Merge "[CTT-2] Clean up unused {function, exception} and improve readability" am: d6ca2420bb
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1762186

Change-Id: Iebbf79ab6e45dbbc9f9523f40c54c1f501244d67
2021-07-13 02:28:18 +00:00
Maciej Żenczykowski
d85fc83e41 Merge "[CTT-1] Rename conntrack related function, variable and constant" am: 2c2eccac73
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1762185

Change-Id: I9da178744d3a276ac3a26058eb5fd95240882beb
2021-07-13 02:28:12 +00:00
Maciej Żenczykowski
8d2e46aec3 Merge "[CTT-4] Improve conntrack timeout update logging" 2021-07-13 02:11:59 +00:00
Maciej Żenczykowski
7d3d4eaca7 Merge "[CTT-3] Add a string converter for TCP and UDP protocol number" 2021-07-13 02:10:09 +00:00
Maciej Żenczykowski
d6ca2420bb Merge "[CTT-2] Clean up unused {function, exception} and improve readability" 2021-07-13 02:09:36 +00:00
Maciej Żenczykowski
2c2eccac73 Merge "[CTT-1] Rename conntrack related function, variable and constant" 2021-07-13 02:09:00 +00:00
Remi NGUYEN VAN
793a4424d7 Merge "Jarjar all classes in service-connectivity" am: 23c627b090
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1759589

Change-Id: I51c65720e00ab652daf8af51e74ace09347ece7d
2021-07-12 23:40:56 +00:00
Remi NGUYEN VAN
23c627b090 Merge "Jarjar all classes in service-connectivity" 2021-07-12 23:29:25 +00:00
paulhu
29797ebfae Update network preference priority value for VPN am: da7129d862
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1762867

Change-Id: I8aaea58aa38921cd354d326e074285f06d724f2b
2021-07-12 15:00:06 +00:00
Remi NGUYEN VAN
0755183fae Jarjar all classes in service-connectivity
This ensures classes are used from the service-connectivity jar, instead
of using classes from the system_server bootclasspath when there is a
name conflict.
Any developer adding a future class should do so in a subpackage of
com.android.connectivity (such as com.android.connectivity.server).
Otherwise, jarjar rules need to be added manually until b/180995093 is
fixed.

Also update current jarjar rules so that classes are jarjared to
com.android.connectivity.[original name], making it easier to find the
original source. This is consistent with the wifi module.

Bug: 193086215
Test: atest CtsNetTestCases
      dexdump on service-connectivity.jar shows no classes outside of
      com.android.connectivity and com.android.server
Change-Id: I2aadeca32751267b74d4fd2fd93bb3e8c62e46c0
2021-07-12 19:33:33 +09:00
paulhu
da7129d862 Update network preference priority value for VPN
Currently netd supports only the default value for VPN but CS
send priorty value 1 to netd. It will break the default routing
for VPN. Thus, update network preference priority value to 0 for
VPN.

Bug: 193245476
Test: atest CtsHostsideNetworkTests:HostsideVpnTests
Change-Id: I197cb358e8e30355fbf675e4c623abebe7abdb7f
2021-07-12 18:15:46 +08:00
Remi NGUYEN VAN
19122edbc5 Merge "Remove catch clause on compat shim" am: 5b37955322
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1760688

Change-Id: I9b3dea9ce41f0afb1093c9c0affb185e870c4cd3
2021-07-12 04:05:37 +00:00
Remi NGUYEN VAN
5b37955322 Merge "Remove catch clause on compat shim" 2021-07-12 03:52:54 +00:00
Remi NGUYEN VAN
3c5a0f7de9 Merge "Remove hidden ArrayUtils usage in test" am: 946da61e70
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1760689

Change-Id: If2a051f415f46544955e6646ed7d74c52d4e2d22
2021-07-12 02:31:43 +00:00
Remi NGUYEN VAN
946da61e70 Merge "Remove hidden ArrayUtils usage in test" 2021-07-12 02:21:12 +00:00
Hungming Chen
8d2bbd865a [CTT-4] Improve conntrack timeout update logging
Bug: 190783768
Bug: 192804833

Test: atest TetheringCoverageTests

Change-Id: I56792d75d12a0207e0a83a6d64e303f3bbfc3c6a
2021-07-11 15:06:22 +08:00
Hungming Chen
916ba672b7 [CTT-3] Add a string converter for TCP and UDP protocol number
Bug: 190783768
Bug: 192804833

Test: atest TetheringCoverageTests
Change-Id: I6a6452b65dd994fcf392e51917be52537a9d4cd9
2021-07-11 15:05:56 +08:00
Hungming Chen
71b85591ea [CTT-2] Clean up unused {function, exception} and improve readability
- Remove ipv4MappedAddressBytesToIpv4Address because it can be covered
  by parseIPv4Address.
- Remove IllegalArgumentException from parseIPv4Address because it has
  never happened
- Reverse the order of upstream and downstream timeout refreshing in
  refreshAllConntrackTimeouts for readability because both source and
  destination of the downstream are opposite direction to the
  upstream.

Bug: 190783768
Bug: 192804833
Test: atest TetheringCoverageTests
Change-Id: I6a1e44777a4357dd3847c2e2bb1fc6c3cf01617c
2021-07-11 15:05:39 +08:00
Hungming Chen
378bdbc2ef [CTT-1] Rename conntrack related function, variable and constant
Bug: 190783768
Bug: 192804833
Test: atest TetheringCoverageTests

Change-Id: Ib7ba480138b8aa8c6f8dffaa97787bac74a3972e
2021-07-11 15:04:37 +08:00
Remi NGUYEN VAN
bd514f4993 Merge "Rename shared utils to connectivity-module-utils" am: c5ba57ec15
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1757315

Change-Id: Ib72d1cf70e1d1842ba7563fb106fde3d30e9c4f6
2021-07-09 09:53:36 +00:00
Remi NGUYEN VAN
61cc1ac9bd Remove hidden ArrayUtils usage in test
Internal utils are generally jarjared by connectivity jarjar rules, but
ArrayUtils is not actually statically linked into the tests, so this
makes the ConnectivityCoverageTests fail. FrameworksNetTests has been
fine because it does not use jarjar, but does not exercise updated code
because of that.

Remove usage of the hidden utility, as there are reasonable alternatives
with non-hidden APIs that avoid other breakages long-term.

Bug: 187935317
Test: atest ConnectivityCoverageTests:ConnectivityServiceTest
Change-Id: I8ed85b941c3d1028771a5ac33196b1509a95789d
2021-07-09 18:52:51 +09:00
Remi NGUYEN VAN
c5ba57ec15 Merge "Rename shared utils to connectivity-module-utils" 2021-07-09 09:41:22 +00:00
Remi NGUYEN VAN
c432565460 Merge "Add new network capabilities to support automotive head unit via USB" am: 8890ead0e0
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1757322

Change-Id: If50a92d2cfbce8f91a179d73b5716b87758df8b2
2021-07-09 04:57:20 +00:00
Remi NGUYEN VAN
58cd24586c Rename shared utils to connectivity-module-utils
Rename net-module-utils-srcs to connectivity-module-utils-srcs.

This is done as the module utils are made specific to
service-connectivity to contain only classes used by
service-connectivity.

Bug: 192998401
Test: Tests prepared in next change
Change-Id: I354f4b84aa90cc12579c4db5479cf2de1dc9cf5d
2021-07-09 13:42:31 +09:00
Remi NGUYEN VAN
8890ead0e0 Merge "Add new network capabilities to support automotive head unit via USB" 2021-07-09 04:38:10 +00:00
Remi NGUYEN VAN
ca5530ed1d Remove catch clause on compat shim
registerSystemDefaultNetworkCallback no longer throws
UnsupportedApiLevelException as it has compatibility behavior down to Q,
so remove the catch clause for the checked exception.

The exception would previously not be thrown since the Tethering module
is only running on R+.

Bug: 182961265
Test: atest TetheringTests
Change-Id: I3c58235f3a59294995e5f32502fec6ccd17a3cf0
2021-07-09 10:24:44 +09:00
James Mattis
48f3878591 Merge "Only pass the NRI for removal in NRI#binderDied" am: 24fa1d7a8f
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1741953

Change-Id: Iac74fa029c1736ae5a094d80766acbb838a6e212
2021-07-09 00:05:48 +00:00
James Mattis
24fa1d7a8f Merge "Only pass the NRI for removal in NRI#binderDied" 2021-07-08 23:54:46 +00:00
Chalard Jean
b819ff4142 Merge "Remove exclusivity restriction of multiple preferences" am: 278b92f6a0
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1719390

Change-Id: Ib41c5050c389ac115221005f565ff4f59a799502
2021-07-08 04:05:45 +00:00
Chalard Jean
278b92f6a0 Merge "Remove exclusivity restriction of multiple preferences" 2021-07-08 03:50:34 +00:00
Remi NGUYEN VAN
577f3e158d Merge "Ensure wifi reconnects before waiting for metered" am: 14f0d14c14
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1757311

Change-Id: Icdf3557348e3a4f58c7e988057609cbbbd9e5e33
2021-07-08 00:54:52 +00:00
lucaslin
6f77442d76 Add new network capabilities to support automotive head unit via USB
- Add a new transport type for USB and a new network capability
to support automotive head unit.
- In order to pass DnsManagerTest#testTransportTypesEqual, Android.bp
needs to link to dnsresolver_aidl_interface-V8-java. That test checks
whether the TRANSPORT types defined in NetworkCapabilities are the
same as IDnsResolver.aidl.

(clean cherry-pick of change in downstream branch history, original
change ID before project move:
Iec2df09a776d779108f95098e01b7ffdf6f8867a)

Bug: 181742019
Test: atest FrameworksNetTests

Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Change-Id: Ie438ec68577ebdaaf990795fa27f1169b0105411
2021-07-08 09:44:39 +09:00
Remi NGUYEN VAN
14f0d14c14 Merge "Ensure wifi reconnects before waiting for metered" 2021-07-08 00:40:37 +00:00
James Mattis
8f03680fdb Only pass the NRI for removal in NRI#binderDied
When NetworkRequestInfo#binderDied is called in ConnectivityService,
only pass the NRI to handleRemoveNetworkRequest. This is to prevent a
potential crash when unlinkDeathRecipient is called twice for the same
NRI.

Also, as a cleanup, don't iterate mRequests in the log message on binderDied.

As per the bug, the chain of events leading to a potential crash are:

- `Connectivity.NetworkRequestInfo#binderDied()` is called for an NRI
tracking multiple `NetworkRequest` items. This can happen for a TRACK_DEFAULT
request filed by a UID on a different preference than the default, which
copies the request list.
- This in turn triggers multiple `EVENT_RELEASE_NETWORK_REQUEST` events
for the same NRI, one for reach `NetworkRequest` tracked.
- When handling `EVENT_RELEASE_NETWORK_REQUEST`, each `NetworkRequest`
that is passed in will then be used to look up the parent NRI that originally
sent it to be released.
- Therefore if an NRI was tracking three requests, it would trigger three
release network events, then each request would be used to look up the
same NRI again when handling said release event.
- Finally, `ConnectivityService.NetworkRequestInfo#unlinkDeathRecipient` is
called for the NRI in question. Using the scenario above, that means we could
call `unlinkDeathRecipient` multiple times for the same NRI if it was tracking
multiple network requests causing the associated crash.
- If `unlinkDeathRecipient` is called more than once for the same NRI, it will
cause the crash listed in this bug.
- The fix is to only call handleRemoveNetworkRequest for the NRI once. This
works since when removing the NRI, we iterate over all of its requests to
remove them. By only calling handleRemoveNetworkRequest once, it's ensured
`unlinkDeathRecipient` for this NRI as part of
`Connectivity.NetworkRequestInfo#binderDied()` is only called  once and not
potentially multiple times.

Bug: 185541983
Test: atest FrameworksNetTests
Change-Id: I2a2ad4ec6d415423182a1856a898779203658f8b
2021-07-07 17:16:59 -07:00