Commit Graph

707 Commits

Author SHA1 Message Date
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
junyulai
da52dab266 [SP34] Adapt onSetWarningAndLimit
This is a no-op change that just adapt new API from
NetworkStatsProvider to get warning and limit bytes at the same
time. This change also stores them locally for subsequent
patches to set warning bytes to hardware.

Test: Will be included in the subsequent patch.
Bug: 149467454
Merged-In: Iec01cb01fd1ce481ce0bd736762baddde1e38084
Change-Id: Iec01cb01fd1ce481ce0bd736762baddde1e38084
  (cherry-picked from ag/13981691)
2021-06-24 08:33:28 +00:00
junyulai
37a7e620b4 [SP33] Adapt ITetheringOffloadCallback V1.1
This is a no-op change that redirect both V1.0 and V1.1 callback
events to the same handling function. Since the V1.1 callback
is extended from V1.0 callback, we can safely use V1.1
callback for both V1.0 and V1.1 control.

The change also provides interface for subsequent
OffloadController changes to set warning and limit at the
same time.

Test: atest TetheringTests
Bug: 149467454
Merged-In: I6505a04de8c57357dd1fa9ce898c13395e497816
Change-Id: I6505a04de8c57357dd1fa9ce898c13395e497816
  (cherry-picked from ag/13973147)
2021-06-24 08:33:28 +00:00
Hungming Chen
c27ec7c4a2 Refresh conntrack entry timeout
Needed because the BPF maps offloads IPv4 traffic. The kernel can't
trace the offloaded traffic to keep the conntrack entry.

Bug: 190783768
Test: atest TetheringCoverageTests
Change-Id: Idbcf686c9b2124b192944156ac5111be741744fb
2021-06-23 15:41:30 +08:00
Hungming Chen
a6e7869646 Clear IPv4 offload rules when tethering stopped
The condition for deleting IPv4 forwarding rules.
1. When the tethering client has gone, deletes the client and its
   rules.
2. When the upstream has gone, deletes all rules.
3. When the upstream has changed, deletes all rules.

Test: atest TetheringCoverageTests and check IPv4 offload rules
via dumpsys tethering in the following test cases.

Bug: 190783768

Test cases:
a. Loss upstream interface while tethering
  1. Enable WIFI tethering
  2. Disable upstream interface
  3. Check the rules are removed.
b. Loss downstream interfaces while tethering
  1. Enable WIFI tethering
  2. Enable BT tethering
  3. Disable BT tethering
  4. Check the BT tether rules are removed.
  5. Disable WIFI tethering
  6. Check the WIFI tether rules are removed.
c. Switch upstream interface while tethering
  1. Enable WIFI tethering
  2. Enable BT tethering
  3. Switch upstream interface from cellular to wifi.
  4. Check all rules are removed.
d. Enable NAT failure (manual)

Log:
The rule deletion in each case.
- IpServer#stopIPv4: case b and case d.
- BpfCoordinator#updateUpstreamNetworkState: case a and case c.

Test case a
06-23 09:58:59.245  [...] Tethering: [BpfCoordinator]
    updateUpstreamNetworkState tetherOffloadRule4Clear wlan2

Test case b
06-07 22:17:51.886  [..] Tethering: [bt-pan] cleanupUpstream bt-pan
06-07 22:17:51.888  [..] Tethering: [bt-pan] stopIPv4 bt-pan
06-07 22:18:23.769  [..] Tethering: [wlan2] cleanupUpstream wlan2
06-07 22:18:23.772  [..] Tethering: [wlan2] stopIPv4 wlan2

Test case c
06-08 11:11:48.277  [..] Tethering: [BpfCoordinator]
    updateUpstreamNetworkState tetherOffloadRule4Clear bt-pan
06-08 11:11:48.396  [..] Tethering: [BpfCoordinator]
    updateUpstreamNetworkState tetherOffloadRule4Clear wlan2
06-08 11:11:48.579  [..] Tethering: [wlan2] cleanupUpstreamInterface
    wlan2
06-08 11:11:48.808  [..] Tethering: [bt-pan] cleanupUpstreamInterface
    bt-pan

Enabling NAT failure
06-08 13:04:18.117  [..] Tethering: [wlan2] Exception enabling NAT [..]
06-08 13:04:18.234  [..] Tethering: [wlan2] cleanupUpstream wlan2
06-08 13:04:18.246  [..] Tethering: [wlan2] stopIPv4 wlan2

Change-Id: Id505a3deb277bbe0f44403234d8ca8bbf01eec80
2021-06-23 15:41:27 +08:00
Junyu Lai
69bc4fede1 Merge "[SP32] Try to get 1.1 OffloadControl hardware if available" 2021-06-22 20:31:18 +00:00
Mark Chien
0e57c7e589 Merge changes I270ff43c,Ifc7eee24 am: cec294d1b4 am: 82b26e0d1f
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1730548

Change-Id: I382f551487f70865761b4dcd0dcdcdb425538f3e
2021-06-21 13:57:31 +00:00
Mark Chien
cec294d1b4 Merge changes I270ff43c,Ifc7eee24
* changes:
  Add enable and disable ip serving common functions
  Allow to use ncm function for usb tethering
2021-06-21 10:56:45 +00:00
markchien
76e2e1c702 Add enable and disable ip serving common functions
This is a op CL which prepare for refactor.

Bug: 185649441
Bug: 189410000
Bug: 178116595

Test: atest TetheringTests
Change-Id: I270ff43c01736b9d18bd40a8e88e1379e9e4e863
2021-06-18 21:35:40 +08:00
markchien
cab01b7ebc Allow to use ncm function for usb tethering
Adding the configuration to decide using rndis or ncm for usb tethering.
If ncm is configured for TETHEIRNG_USB, then TETHERING_NCM is not
available.

Bug: 162920185
Test: atest TetheringTests
      manul testing usb tethering
Change-Id: Ifc7eee2457a950a0e2d1c3cc89a3373a7ad23c9c
2021-06-18 11:20:26 +08:00
Lorenzo Colitti
6f3e90c2e5 Merge "Correctly dump IPv4 downstream flows." am: a8afcd3b0e am: 18e6921d00
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1737399

Change-Id: If26c0f68ed30df42ff8f78a5d83b6961db32d703
2021-06-16 11:38:01 +00:00
Lorenzo Colitti
8569168eda Correctly dump IPv4 downstream flows.
The current code does not print these correctly: it prints the
public address twice and then the NAT address. Fix this to print
the src, nat, and dst addresses.

Also dump the output MAC address.

Example output:

    IPv4 Upstream: [inDstMac] iif(iface) src -> nat -> dst [outDstMac] age
      [66:f1:6f:d8:66:0a] 31(31) 192.168.146.173:48594 -> 11(rmnet_data1) 100.100.109.185:48594 -> 8.8.8.8:853 [00:00:00:00:00:00] 32305ms
      [66:f1:6f:d8:66:0a] 31(31) 192.168.146.173:45806 -> 11(rmnet_data1) 100.100.109.185:45806 -> 8.8.4.4:853 [00:00:00:00:00:00] 32305ms
    IPv4 Downstream: [inDstMac] iif(iface) src -> nat -> dst [outDstMac] age
      [00:00:00:00:00:00] 11(rmnet_data1) 8.8.8.8:853 -> 31(31) 100.100.109.185:48594 -> 192.168.146.173:48594 [0e:a8:7f:ba:76:48] 32305ms
      [00:00:00:00:00:00] 11(rmnet_data1) 8.8.4.4:853 -> 31(31) 100.100.109.185:45806 -> 192.168.146.173:45806 [0e:a8:7f:ba:76:48] 32305ms

Test: manual
Bug: 190783768
Change-Id: I93a82064c95027c7c63cb30baf8482ecddcbd09d
2021-06-15 23:11:27 +09:00
Nucca Chen
21a62c5bcb Merge "Improve dumping IPv4 map entries." am: 26f799f2d7 am: 7bd9af79a7
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1737394

Change-Id: I0d7d72aad8c3f10af402111f62f5706c0703514f
2021-06-15 08:17:11 +00:00
Treehugger Robot
5298ddbb00 Merge "Dump underlying BPF traffic stats as well as higher-level stats." am: a79b785ff0 am: 3a6c47e8ca
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1737393

Change-Id: Ia49eb7404bc856acac6f62fd3e480efd1674e66c
2021-06-15 07:34:49 +00:00
Lorenzo Colitti
70f43ee58e Improve dumping IPv4 map entries.
1. Dump both upstream and downstream rules.
2. Also dump rule last used time.

Test: manual
Bug: 190783768
Change-Id: I3fffbf4a5dea68e61349de8b41bea49b8a319f86
2021-06-15 12:54:08 +09:00
Lorenzo Colitti
704b8013f1 Dump underlying BPF traffic stats as well as higher-level stats.
This provides a better way to tell whether traffic is flowing.

Test: manual
Bug: 190783768
Change-Id: If557b0a18fc0aea1bf6a65d91547fc1930098ed0
2021-06-15 12:49:07 +09:00
Lorenzo Colitti
7d9f43c6f3 Merge "Don't send onLinkPropertiesChanged after onLost for 464xlat." am: a3f12dd52c am: b4e1b65298
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1727829

Change-Id: Iad96cfcdd5f385c084be76b3b25ffd10b080df7f
2021-06-09 08:33:36 +00:00
Lorenzo Colitti
a3f12dd52c Merge "Don't send onLinkPropertiesChanged after onLost for 464xlat." 2021-06-09 07:59:25 +00:00
Mark Chien
1f5e9d4d83 Merge changes Ib8fe719f,Ia8c05780 am: 7648833bd4 am: f9074acfa3
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1729160

Change-Id: Iae8f9bb61662f17b2aa3ae7f4f4983f94144f799
2021-06-08 10:45:58 +00:00
markchien
21021efbe1 Suppress IpServer message logs
To avoid log flooding, suppress CMD_IPV6_TETHER_UPDATE and
CMD_NEIGHBOR_EVENT message log because they appear frequentlg and
don't have any content which means they are ueseless for debugging.
Also remove logMessage from BaseServingState to fix duplicated
message because all the message already log in TetheredState
and LocalHotspotState which inherit BaseServingState.

Bug: 162920185
Bug: 185649441
Test: atest TetheringCoverageTests
      atest MtsTetheringTestLatestSdk
      atest CtsTetheringTest
Change-Id: Ib8fe719f3c1c4a65e6b5152df5e5adf33aba2079
2021-06-08 15:57:04 +08:00
markchien
dc5903ae56 Remove *Locked wording
Since tethering run in single thread without any synchronized lock,
remove "Locked" wording from the methods which the use lock before.

Bug: 162920185
Test: atest TetheringCoverageTest
Change-Id: Ia8c057800cab30cdcbacae4db2d706b6427e9861
2021-06-08 15:56:14 +08:00
Lorenzo Colitti
b4bf015b57 Don't send onLinkPropertiesChanged after onLost for 464xlat.
Currently, when a network that uses 464xlat is torn down,
NetworkCallbacks will receive onLinkPropertiesChanged after
onLost. This is confusing and incorrect.

The incorrect callback is sent because handleLinkProperties
checks that the netId of the agent still exists, not that the
NetworkAgent is still registered. This is normally correct,
because the NetworkAgent is removed from mNetworkAgentInfos and
the netId are removed from mNetworkForNetId by the same method,
disconnectAndDestroyNetwork.

In this specific case it's not correct, because the call to
handleUpdateLinkProperties is from disconnectAndDestroyNetwork
itself via nai.clatd.update and calls Nat464Xlat#stop.

No other callers of handleUpdateLinkProperties are affected
because:

- EVENT_NETWORK_PROPERTIES_CHANGED is called only by
  maybeHandleNetworkAgentMessage, which first checks that the
  NetworkAgent is registered.
- handlePrivateDnsSettingsChanged only looks at registered
  NetworkAgents (it loops over mNetworkAgentInfos).
- handlePrivateDnsValidationUpdate, handleNat64PrefixEvent and
  handleCapportApiDataUpdate call getNetworkAgentInfoForNetId,
  which will correctly determine that the agent is no longer
  registered, since they run on the handler thread and thus
  cannot run at the same time as disconnectAndDestroyNetwork.

The existing code contains a check for the netId being current.
This is intended to ensure that an update from a NetworkAgent
cannot affect another agent with the same Network. This extra
check is not necessary, because code running on the handler
thread can never observe a NetworkAgent in mNetworkAgentInfos
unless mNetworkForNetId maps that NetworkAgent's Network to that
NetworkAgent. This is because mNetworkForNetId is updated by the
same methods as mNetworkAgentInfos, and those updates occur on
the handler thread. So all code on the handler thread will see
those two as consistent.

Bug: 176496580
Test: atest FrameworksNetTests CtsNetTestCases HostsideVpnTests
Change-Id: I944f4c6ad36206bdccd85a6ea7ef71324a29c685
2021-06-08 15:48:57 +09:00
markchien
35ad54b25e Add the tethering type to TetheringEventCallback methods
Before this change, tethering always report a list of tethered
interfaces and the caller need to use each tethering type's interface
regex to matching tethered list to manual implement the mapping of
tethering type and interface. This change allow caller to get rid of
tethering interface regex.

Bug: 162920185
Bug: 152203943
Test: atest CtsTetheringTest on S

Merged-In: I91bcccd676d109c1b974497ac29bd366a41b8899
Change-Id: I91bcccd676d109c1b974497ac29bd366a41b8899
2021-06-01 14:35:39 +08:00
Mark Chien
1217274ac0 Merge "Disable tryCell when UpstreamMonitor stop" am: 011552cc54 am: bed1ae7b4c
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1715791

Change-Id: I4f55ae5885e3904d0d2d17384875cb00809a0eed
2021-05-24 03:00:20 +00:00
markchien
89f2670b65 Disable tryCell when UpstreamMonitor stop
tryCell configuration would not be force disabled UpstreamMonitor stop.
If tethering stop with using mobile upstream and swap with SIM fron no
dun to dun supported, dun request would be filed even tethering is not
active.

Bug: 173068192
Test: atest TetheringTests
Change-Id: I5505655f52da9fdca2fd43a58e043a9ab727741d
2021-05-21 20:35:11 +08:00
Mark Chien
53fcccd8da Merge "Add the tethering type to TetheringEventCallback methods" into sc-dev 2021-05-18 14:48:27 +00:00
markchien
9935dbe03e Add the tethering type to TetheringEventCallback methods
Before this change, tethering always report a list of tethered
interfaces and the caller need to use each tethering type's interface
regex to matching tethered list to manual implement the mapping of
tethering type and interface. This change allow caller to get rid of
tethering interface regex.

Bug: 162920185
Bug: 152203943
Test: atest CtsTetheringTest on S
Ignore-AOSP-First: Currently aosp would automerge to mainlne-prod, merge
to sc-dev first to avoid adding new API to mainline-prod

CTS-Coverage-Bug: I already add cts test(ag/14622456), but Lint
still complaint because my cts is under packages/modules/Connectivity/
but it only check whether CL touching platform/cts
Change-Id: I91bcccd676d109c1b974497ac29bd366a41b8899
2021-05-18 14:47:43 +00:00
Mark Chien
e66481b436 Merge "Check whether feature is enabled by compare with apex version" am: 84a8a13a92 am: c59d6fa12d am: 2d577ad3d2
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1708088

Change-Id: Ifcc571196e302245816b663155bc57aabdef542b
2021-05-18 10:16:47 +00:00
Mark Chien
2d577ad3d2 Merge "Check whether feature is enabled by compare with apex version" am: 84a8a13a92 am: c59d6fa12d
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1708088

Change-Id: Id993424e895917267ac5ffa43ab3362169c1d37c
2021-05-18 09:56:00 +00:00
Mark Chien
84a8a13a92 Merge "Check whether feature is enabled by compare with apex version" 2021-05-18 03:09:20 +00:00
TreeHugger Robot
4547356487 Merge "Use SettingsShim to hide different implementation in shim" into sc-dev 2021-05-15 06:27:38 +00:00
markchien
a3ef48117f Check whether feature is enabled by compare with apex version
Replace the isFeatureEnabled function which is check with apex version.

Bug: 187946226
Test: Set device config flag and check the result
Change-Id: Iba44a01e2fdd0698dcb338ea4a8fe8147cbaa7dd
2021-05-14 16:56:33 +08:00
Nucca Chen
1ed7317a2f Merge "bpf: Add interface index to BPF devmap" am: aa10ddfa6f am: 72bd34e343 am: 76cc470496
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1703125

Change-Id: I5669ff227f761da71d8ad12cf7e0a228b3621d81
2021-05-14 03:25:05 +00:00
Nucca Chen
76cc470496 Merge "bpf: Add interface index to BPF devmap" am: aa10ddfa6f am: 72bd34e343
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1703125

Change-Id: I8ed82b1f5b8fa35e398c6d8c3bc928a03ee6318c
2021-05-14 03:01:16 +00:00
Nucca Chen
aa10ddfa6f Merge "bpf: Add interface index to BPF devmap" 2021-05-14 02:45:38 +00:00