Commit Graph

741 Commits

Author SHA1 Message Date
Treehugger Robot
ed62eb3a5b Merge "Skip bpf offload if upstream interface is VCN" am: 097d65b0f3 am: 9743c8165e
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1764307

Change-Id: Id3546b8888439ee9228fb2b5687b117165fdbbd7
2021-07-13 17:45:37 +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
5cdd98b850 Merge "[CTT-7] Delete the rules while half-closing tcp state entered" am: f7c8cec604 am: d0b818fa8a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1755173

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

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

Change-Id: Idf2680669d1c881f3d1846f379f5a8163c4ac274
2021-07-13 12:31:10 +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
af3d38bea3 Merge "[CTT-4] Improve conntrack timeout update logging" am: 8d2e46aec3 am: ae7fb09d69
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1760690

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

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

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

Change-Id: Ie0b8eee8dd649432835ef89369d3ac2e6166d8da
2021-07-13 02:44:53 +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
2cff18c9f5 Merge "Remove catch clause on compat shim" am: 5b37955322 am: 19122edbc5
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1760688

Change-Id: I962a30ce497292d4bc65d6724251d2a16a98d995
2021-07-12 04:19:04 +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
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
Lorenzo Colitti
25423d4f5e Merge "Load ncm regexs config to tetherableUsbRegexs if isUsingNcm=true" am: 844ca1290e am: 51f5f61742
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1755176

Change-Id: Iceb3d25f31da76f4f12115a7ceabd68a81faebfa
2021-07-06 04:04:42 +00:00
Lorenzo Colitti
86d7e6bbb4 Merge "Enable and disable usb IpServer according to ACTION_USB_STATE" am: d479e694f0 am: 736df2cb2f
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1731453

Change-Id: I334710d0bbbe18a769a79fb58d10a558dd8f7b37
2021-07-06 04:04:36 +00:00
Lorenzo Colitti
844ca1290e Merge "Load ncm regexs config to tetherableUsbRegexs if isUsingNcm=true" 2021-07-06 03:39:31 +00:00
Lorenzo Colitti
d479e694f0 Merge "Enable and disable usb IpServer according to ACTION_USB_STATE" 2021-07-06 03:39:15 +00:00
markchien
b28740ec89 Load ncm regexs config to tetherableUsbRegexs if isUsingNcm=true
If config_tether_ncm_regexs is configured, load it to
tetherableUsbRegexs if ncm is used for TETHERING_USB. Load it to
tetherableNcmRegexs if ncm is used for TETHERING_NCM.

Bug: 185649441
Test: atest TetheringTests
Change-Id: I0c542560bd04e8c0a6a78d632da5a00a34d9a3fa
2021-07-05 23:11:50 +08:00
markchien
b41a00e778 Enable and disable usb IpServer according to ACTION_USB_STATE
Before this change, usb IpServer would be created if corresponding
interface is available even there is no enable tethering attempt. And
usb IpServer only be disabled when interface is removed. Usb tethering
could not be stopped if interface is always avaialbe.
After this change, usb IpServer would be enabled and disabled according
to ACTION_USB_STATE.

Bug: 185649441
Test: atest TetheringCoverageTests
      atest MtsTetheringTestLatestSdk
      atest CtsTetheringTest
Change-Id: I8375e3f998d677dc658370b2553facaec0d5ff7c
2021-07-05 22:53:07 +08:00
Nucca Chen
64aab1a2a3 Merge "Dump the protocol of IPv4 offload rule" am: 3746fdd293 am: 68657e4e99
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1753608

Change-Id: I9847a5c00e9e2ca5ccaa0325016c26028c233784
2021-07-01 07:55:27 +00:00
Hungming Chen
3004f0d8d9 Dump the protocol of IPv4 offload rule
Print the protocol {tcp, udp} of v4 rules in dumpsys.

Format:
proto [inDstMac] iif(iface) src -> nat -> dst [outDstMac] age
  udp [00:00:00:00:00:00] 14(rmnet0) 74.125.10.156:443
  -> 30(30) 10.254.92.123:60262 -> 192.168.128.240:60262
  [0a:bd:b5:e0:41:53] 96067ms

Bug: 190783768
Test: dumpsys tethering
Change-Id: Idae1042cfb454cc97b9b103587f11bc0700e0787
2021-07-01 11:52:12 +08:00
Hungming Chen
a2a34a90d7 Dump the unused IPv4 BPF rule age correctly am: e7dff2f955 am: e9deba21ad
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1751022

Change-Id: I3704db91381858a88f51972692af78f14e6d2e0c
2021-06-29 16:22:38 +00:00
Hungming Chen
e7dff2f955 Dump the unused IPv4 BPF rule age correctly
Print a dash for the unused "lastUsed" of the rule.

The age should not equal the bootime if the rule has never been
updated the "lastUsed" field.

Format:
[inDstMac] iif(iface) src -> nat -> dst [outDstMac] age
[00:00:00:00:00:00] 14(rmnet0) 140.112.8.116:443
-> 30(30) 10.170.56.233:43720
-> 192.168.45.236:43720 [be:34:40:28:33:5f] -

Test: dumpsys tethering
Change-Id: Ie771becd2f72518cf02a86e5ae228315785752a5
2021-06-29 16:21:49 +08:00
Treehugger Robot
aad77e7ce4 Merge "Make "dumpsys tethering" print the number of registered callbacks." am: 1e50b3ea24 am: 2d4eb7e18d
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1749480

Change-Id: Ia2351cde37d919b7dba7b609b556c08533a978ff
2021-06-28 10:15:26 +00:00
Treehugger Robot
1e50b3ea24 Merge "Make "dumpsys tethering" print the number of registered callbacks." 2021-06-28 09:50:04 +00:00
Treehugger Robot
bb8f070cb3 Merge "Remove wigig support from S tethering" am: 0b44491744 am: 8027e83cf1
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1744652

Change-Id: I80b9877ef5d0bc21a2bdb31d506214d5823d5dc6
2021-06-28 08:16:56 +00:00
Treehugger Robot
0b44491744 Merge "Remove wigig support from S tethering" 2021-06-28 07:51:07 +00:00
Mark Chien
4114bb1a2a Merge "Fix and test usb function configuration change" am: 840e2efd7f am: 717c8ff590
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1740778

Change-Id: Iac2ab9a589c878bee92179956df7802ea51c7a3e
2021-06-28 04:39:21 +00:00
Mark Chien
840e2efd7f Merge "Fix and test usb function configuration change" 2021-06-28 04:16:14 +00:00
Lorenzo Colitti
ced68f5993 Make "dumpsys tethering" print the number of registered callbacks.
Test: manual
Bug: 177265744
Change-Id: I07f56459125d5629dcafe5683eecb42d0ef9e2bd
2021-06-28 12:46:37 +09:00
markchien
34f7857b07 Fix and test usb function configuration change
Allow stop TETHERING_NCM no matter ncm is used for TETHERING_USB or
TETHERING_NCM.

Add a test:
1. NCM is started for TETHERING_NCM
2. The config changes to use NCM for TETHERING_USB.
3. Then the config changes to use RNDIS for TETHERING_USB.

Also let some logs not only print in dumpsys, but also in logcat to
easiler debug unit test.

Bug: 185649441
Test: atest TetheringTests
Change-Id: Ia8d76a29646f36941cbb16cd68ae6887100ec8ec
2021-06-28 02:59:33 +00:00
Nucca Chen
2791e3fe11 Merge "Refresh conntrack entry timeout" am: a569410667 am: a729b103ff
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1566871

Change-Id: I5508b5b47d17c01d2ce95fb30d9dfc14e279f932
2021-06-25 18:55:47 +00:00
Nucca Chen
8516b3f120 Merge "Clear IPv4 offload rules when tethering stopped" am: 7238b31c15 am: 70504b2f6b
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1579873

Change-Id: Ibfea3e14e0e06a59c3b29534ab5ffbf4d4bd2148
2021-06-25 18:55:09 +00:00
Nucca Chen
a569410667 Merge "Refresh conntrack entry timeout" 2021-06-25 18:34:22 +00:00
Nucca Chen
7238b31c15 Merge "Clear IPv4 offload rules when tethering stopped" 2021-06-25 17:56:21 +00:00
markchien
8f9705126a Remove wigig support from S tethering
Bug: 176520801
Test: atest TetheringTests
Change-Id: Id0bf02c01419e0c69a1d0b6a41789826538444d3
2021-06-25 00:31:43 +08:00
junyulai
991433d8c8 [SP35] Pass data warning to tethering offload
This is supported by:
  1. Utilize the new API from both NetworkStatsProvider
     and IOffloadControl to send data warning quota to hardware.
     And pass the warning reached notification back to NPMS.
  2. Disable software solution introduced in R release for
     V1.1+ hardware, since now we can fully offload data warning
     and limit notification to hardware.

Test: atest TetheringTests
Fix: 149467454
Merged-In: Ie49461694d77ab7f25a549433b01b5b0167bd489
Change-Id: Ie49461694d77ab7f25a549433b01b5b0167bd489
  (cherry-picked from ag/13981692)
2021-06-24 08:33:28 +00:00