Commit graph android_packages_modules_Co.../Tethering/src
Message SHA1
BpfCoordinator: ignore stopping event monitoring if never started
Ignore stopping monitoring if the monitor has never started
for a given IpServer.

Also fix the related bug in
BpfCoordinator#testStartStopConntrackMonitoring.

Bug: 250552545
Test: atest BpfCoordinatorTest
Change-Id: I7ac71f0ed52bf52244aadaa3c90ca8df239873e4

Hungming Chen   authored and   Nucca Chen   commited 2022-10-03 11:56:38 +00:00
09d163dfa8
handle "TODO: remove equals/hashCode/toString once aosp/1536721 merged"
aosp/1536721 is merged, so this code duplication should not be needed any more.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ic05adfc46495086d7f681322aac7acddc30a2260

Maciej Żenczykowski   commited 2022-09-16 06:35:32 +00:00
49e9660e0e
Merge "Revert "UpstreamNetworkMonitor: add NOTIFY_TEST_NETWORK_AVAILABLE""
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-09-14 14:25:13 +00:00
1949d98e81
Revert "UpstreamNetworkMonitor: add NOTIFY_TEST_NETWORK_AVAILABLE"
This reverts commit 82e7733909.

Reason for revert: don't modify production code for testing only

Change-Id: I19826c3308774ce6f62a2748b4e038500aec33e2

Nucca Chen   commited 2022-09-05 03:25:33 +00:00
6cafe04787
Use IBpfMap type instead of BpfMap type
Currently, production code uses BpfMap type and TestBpfMap extends
BpfMap but this makes it diffcult to test because TestBpfMap loads the
JNI.

This CL updates to use IBpfMap type in the production code.
Upcoming CL updates TestBpfMap to implement IBpfMap instead of extending
BpfMap so that test can still use TestBpfMap but tests do not need to
load JNI.

Bug: 217624062
Test: atest BpfCoordinatorTest BpfNetMapsTest
Change-Id: Ie67e14bf5519fb4427474ecc0fda441877a9555f

Motomu Utsumi   commited 2022-08-24 23:31:19 +09:00
73599a5f5d
Merge "updateSupportedDownstreams when tethering allowed is changed"
Mark Chien   authored and   Gerrit Code Review   commited 2022-08-22 15:15:11 +00:00
0d3c8b692d
updateSupportedDownstreams when tethering allowed is changed
There are three configuration could affect tethering allowed:
1. user restriction
2. tether_supported settings
3. ro.tether.denied system properties

When user restricted or tether supported setting change, updating
supported downstreams.
ro.tether.denied is read only properties, so it won't be changed runtime.

Also correct the unit test that there is no TetheringConfiguration change when settings or user restriction change.

Bug: 184996041
Bug: 239500515
Test: atest TetheringTests

Change-Id: I8dfcc42de9787a5e9ba19b69db9444c14ace56f0

Mark   commited 2022-08-18 05:42:05 +00:00
c2cc1b42b8
use getIfName in more spots to improve logging
Also just use 'int' for ifindex.  The kernel allocates these in order,
if we ever exceed 2 billion, we'll have other problems to worry about.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I33eb46185fde90cd4d158bb74f8f9c17b41434fb

Maciej Żenczykowski   commited 2022-08-18 01:07:20 +00:00
9ab28d0832
replace U32 ifindex with S32
These are allocated in order by the kernel, if we go
over 2 billion, we've got other problems... besides
U32 to S32 conversion will work just fine anyway.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ifbb7139e9118dd2d0c52e83c5874132e03760b30

Maciej Żenczykowski   commited 2022-08-18 01:07:11 +00:00
09813ced3e
Merge changes I95352711,I27bdb5d8,I7e1acc65,I7c95ff19
* changes:
  BpfCoordinator: dump IPv6 BPF downstream rules
  BpfCoordinator: change function name and format for dumping IPv6 rules
  add header on ipv6 forwarding rulesdump
  add header on ipv6 upstream bpf map dump

Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2022-08-18 00:49:54 +00:00
370f10d117
BpfCoordinator: dump IPv6 BPF downstream rules
Test: adb shell dumpsys tethering
Forwarding rules:
  IPv6 Upstream: iif(iface) [inDstMac] -> oif(iface) etherType [outSrcMac] [outDstMac]
    54(54) [7a:2e:e8:f1:e3:54] -> 15(rmnet1) 86dd [00:00:00:00:00:00] [00:00:00:00:00:00]
  IPv6 Downstream: iif(iface) [inDstMac] neigh6 -> oif(iface) etherType [outSrcMac] [outDstMac]
    15(rmnet1) [00:00:00:00:00:00] 2401:e180:88e1:7aef:55fb:14d3:7ded:71cd -> 54(54) 86dd [7a:2e:e8:f1:e3:54] [52:5c:cf:fc:c6:ff]

Change-Id: I95352711fad48e5e7779e8bc2c27aa415d98758f

Hungming Chen   authored and   Nucca Chen   commited 2022-08-17 05:09:12 +00:00
e5cd2d4294
BpfCoordinator: change function name and format for dumping IPv6 rules
Current function naming is confusing.
dumpIpv6ForwardingRules dumps Java map.
dumpIpv4ForwardingRules dumps BPF map.

Change related function name and minor output string format.

Test: adb shell dumpsys tethering
Forwarding rules:
  IPv6 Forwarding rules by downstream interface:
    [ap_br_wlan2]: iif(iface) oif(iface) v6addr [srcmac] [dstmac]
      15(rmnet1) 54(ap_br_wlan2) 2401:e180:8d60:9943:a550:fafd:1644:14b6 [d6:bb:b4:95:3c:58] [52:5c:cf:fc:c6:ff]
  IPv6 Upstream: iif(iface) [inDstMac] -> oif(iface) etherType [outSrcMac] [outDstMac]
    54(54) [d6:bb:b4:95:3c:58] -> 15(rmnet1) 86dd [00:00:00:00:00:00] [00:00:00:00:00:00]

Change-Id: I27bdb5d8f3773789f8dcce63e9a33c4316d8048b

Hungming Chen   authored and   Nucca Chen   commited 2022-08-17 05:09:06 +00:00
f88f7f5c23
add header on ipv6 forwarding rulesdump
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I7e1acc6565ebafcf3c27fd56e0a5602f1a760e31

Maciej Żenczykowski   authored and   Nucca Chen   commited 2022-08-17 05:08:57 +00:00
93c2b64448
add header on ipv6 upstream bpf map dump
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I7c95ff19fe665e9b502e439cb59498cac3622eab

Maciej Żenczykowski   authored and   Nucca Chen   commited 2022-08-17 05:08:40 +00:00
5d2dc65063
UpstreamNetworkMonitor: add NOTIFY_TEST_NETWORK_AVAILABLE
Used for test interface upstream can replace existing non-test
upstream interface, like ethernet on cuttlefish.

This helps to fix the flaky test when we are using test interface on
cuttlefish. Because the ethernet and test interface upstream update
event order can't be guaranteed.

Bug: 237369591
Bug: 242067530

Test: atest ConnectivityCoverageTests
Change-Id: I9da71ee116bf1ebc9831f61f25acf42e328a8370

Hungming Chen   commited 2022-08-15 17:38:06 +08:00
82e7733909
BpfCoordinator: avoid attach/deatach ipv6 program on 464xlat interface
464xlat interface v4-* doesn't have IPv6 address. IPv6 program should
not be attached/deatached on v4-* interface.

Bug: 241106456
Test: atest BpfCoordinatorTest
Test: manual test

Use IPv6-only wifi to test because there is no IPv6-only live
cellular environment here.

1. Patch TetheringInterfaceUtils.allowIpv6Tethering to allow WIFI.
2. Connect to IPv6-only wifi Google-Guest.
3. Enable USB tethering.
4. Check that v4-wlan0 doesn't have IPv6 program.

$ adb shell tc filter show dev wlan0 ingress;
filter protocol ipv6 pref 2 bpf chain 0
filter protocol ipv6 pref 2 bpf chain 0 handle 0x1 prog_offload_schedcls_tether_downstream6_ether:[*fsobj] direct-action not_in_hw id 2 tag 7d9be9d02d02e8d8
filter protocol ip pref 3 bpf chain 0
filter protocol ip pref 3 bpf chain 0 handle 0x1 prog_offload_schedcls_tether_downstream4_ether:[*fsobj] direct-action not_in_hw id 8 tag 434b3ecac7968bb3
filter protocol ipv6 pref 4 bpf chain 0
filter protocol ipv6 pref 4 bpf chain 0 handle 0x1 prog_clatd_schedcls_ingress6_clat_ether:[*fsobj] direct-action not_in_hw id 24 tag 06763574e0e1f984

$ adb shell tc filter show dev v4-wlan0 ingress;
filter protocol ip pref 3 bpf chain 0
filter protocol ip pref 3 bpf chain 0 handle 0x1 prog_offload_schedcls_tether_downstream4_rawip:[*fsobj] direct-action not_in_hw id 6 tag 9e6e587e0c6cf0bc

$ adb shell tc filter show dev v4-wlan0 egress;
filter protocol ip pref 4 bpf chain 0
filter protocol ip pref 4 bpf chain 0 handle 0x1 prog_clatd_schedcls_egress4_clat_rawip:[*fsobj] direct-action not_in_hw id 27 tag 9158397a2869247e

$ adb shell tc filter show dev ncm0 ingress;
filter protocol ipv6 pref 2 bpf chain 0
filter protocol ipv6 pref 2 bpf chain 0 handle 0x1 prog_offload_schedcls_tether_upstream6_ether:[*fsobj] direct-action not_in_hw id 3 tag 5f70a4f42dffe899
filter protocol ip pref 3 bpf chain 0
filter protocol ip pref 3 bpf chain 0 handle 0x1 prog_offload_schedcls_tether_upstream4_ether:[*fsobj] direct-action not_in_hw id 9 tag 26f324113d54c30a

Change-Id: Ic1c1cfc7646b4d4004856850b66428e4651d42ab

Hungming Chen   commited 2022-08-08 20:56:50 +08:00
1668b2da03
BpfCoordinator: avoid attach/deatach duplicate downstream program
The forwarding pairs may use the same downstream. Ex: 464xlat
tethering has rmnet0:ncm0, v4-rmnet0:ncm0 forwarding pairs.
Need to avoid duplicate downstream program.

Bug: 241106456
Test: atest BpfCoordinatorTest
Change-Id: Ic41b3ad856e4876808f8497a760081afcfd04988

Hungming Chen   commited 2022-08-05 20:56:04 +08:00
6f54391340
clarify 'which is not tetherable' log line
Test: TreeHugger
Bug: 241104956
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I01418e026b2084cbcf013b7e633d82148f2c874c

Maciej Żenczykowski   commited 2022-08-04 11:08:21 +00:00
63a2f68bd2
Merge changes I41ae1d61,I334860af
* changes:
  Make tethering APIs unsupported synchronously when disallowed
  Revert "Revert "Add onSupportedTetheringType callback""

Mark Chien   authored and   Gerrit Code Review   commited 2022-07-28 02:22:07 +00:00
794d04d779
Make tethering APIs unsupported synchronously when disallowed
To backward compatible existing behavior, make tethering APIs
unsupported synchronously when tethering is disallowed. There
are two APIs register/unregisterTetheringEventCallback still
supported even tethering is disallowed.
This could avoid some existing tests flaky. The test assume
startTethering would fail right away after tethering restricted
apply.

Bug: 184996041
Bug: 239500515
Test: atest TetheringTests
Change-Id: I41ae1d61647c9baf69bcb246965e8d9b4a89b497

Mark   commited 2022-07-27 09:41:42 +00:00
cf230301e3
Merge "Fix tethering WTF issue"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-07-22 12:52:13 +00:00
e522b7ff75
Revert "Revert "Add onSupportedTetheringType callback""
This reverts commit 4bf22ae076.

Reason for revert: land the change again

Change-Id: I334860af201ce0faa09f1dbb8935bc9fddd66c50

Mark Chien   authored and   Mark   commited 2022-07-20 06:18:13 +00:00
874a3e273e
Fix tethering WTF issue
When enable/disable tethering quickly, tethering may have stopped
when Ipserver start creatFd().
As tethering iface is down due to tethering stopped, creatFd() will
throw ErrnoException: bind failed: ENODEV (No such device).
When tethering is stopped, this exception is normal, should not
rise WTF.

Bug: 233587050
Test: manual test
Change-Id: I2e200313d1bec2c1e1245e779f3875397127160d

zhengyu.zhan   authored and   Lili Lin   commited 2022-07-19 17:18:26 +08:00
d1b6993684
Merge "Correct javadoc usage"
Chiachang Wang   authored and   Gerrit Code Review   commited 2022-07-15 07:41:33 +00:00
b7f81e4a6d
Correct javadoc usage
"{@see" aren't rendered properly. Replace them with "See {@link"
or @see depending on the usage.

Bug: 238753273
Test: make doc-comment-check-docs ; Check the doc result
Change-Id: I70cb2f36e7c5fa8102b5949054df5184d755202c

chiachangwang   commited 2022-07-15 03:44:46 +00:00
9473c59980
Deprecate filegroup tethering-module-utils-srcs in tethering.
tethering-module-utils-srcs filegroup only contains NetdUtils.java
class, import this class from netd-client static lib instead.

Bug: 238960524
Test: m
Change-Id: I7547c3a3a13e564408cdf8e702f3438530763381

Xiao Ma   commited 2022-07-14 13:30:27 +09:00
59819aeb0e
Make Tethering module depend on net-utils-device-common-ip.
NetworkStack module utils are duplicated to net-utils-device-common-ip,
delete the module utils source code and use net-utils-device-common-ip
instead.

Bug: 235901424
Test: atest TetheringTests
Change-Id: I19fe72a92d6de1084963c2b3a38d094f8da2a91e

Xiao Ma   commited 2022-07-13 04:32:28 +00:00
c81c066958
Merge "Revert "Add onSupportedTetheringType callback""
Mark Chien   authored and   Gerrit Code Review   commited 2022-07-12 07:30:50 +00:00
370ba4f3c5
Revert "Add onSupportedTetheringType callback"
This reverts commit ae3d303344.

Reason for revert: this cause GTS fail
Bug: 238038401

Change-Id: I3e21321e931f60208cb0befaed38e58b088ff966

Mark Chien   commited 2022-07-12 02:11:48 +00:00
4bf22ae076
Use frameworks/libs/net version of SharedLog
Test: m
Bug: 235901424
Change-Id: Ibfa7821c68c41036a47e765f15078cd5d195afb8

Patrick Rohr   commited 2022-07-07 12:52:58 -07:00
b873e25ab4
Merge "Use BpfDump.toBase64EncodedString to dump raw map"
Nucca Chen   authored and   Gerrit Code Review   commited 2022-07-06 12:04:54 +00:00
bf28a595f2
Merge "Ignore BPF tethering offload test if tether config is disabled"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-06-29 07:57:56 +00:00
dd9a89c2f2
Merge "Fix metrics doesn't work if multiple tethering requested"
Treehugger Robot   authored and   Gerrit Code Review   commited 2022-06-29 03:39:03 +00:00
b7c368c27f
Fix metrics doesn't work if multiple tethering requested
There is a bug in TetheringMetrics that the on-going builders would be
cleared when creating new builder. This means if multiple tethering
created at the same time, only latest tethering would have metrics.

Bug: 153942334
Test: atest TetheringTests
Change-Id: I16a66790bc19072d8ffe570348bcbafa91263573

Mark   authored and   Mark Chien   commited 2022-06-28 10:31:02 +00:00
26cf9b6728
Tethering: remove dead code
changeInterfaceState only used in enableIpServing which always
pass STATE_TETHERED or STATE_LOCAL_ONLY state. Move it into
enableIpServing directly and remove unused code.

Test: m
Change-Id: I2d91115e588a153ddcb9d61f8e2bc09a09c52d48

Mark   authored and   Mark Chien   commited 2022-06-28 06:46:27 +00:00
133299a9b8
Ignore BPF tethering offload test if tether config is disabled
Needed because OEM can disable BPF offload by PRO.

Bug: 237144191
Bug: 236925089
Test: atest EthernetTetheringTest
Change-Id: Idf965caa44aeaae1f084d2c4fcd516a352c1b138

Hungming Chen   commited 2022-06-27 15:11:23 +08:00
b37f76f28e
Use BpfDump.toBase64EncodedString to dump raw map
Move base64 related bpf map function and constant to f/l/n.
This is preparation for testing BPF map in ClatCoordinator.

Test: atest EthernetTetheringTest
Change-Id: Ieb1e0a0f128c9aa0d7c9f043e90eecf3c61252f5

Hungming Chen   commited 2022-06-23 21:42:20 +08:00
264cac59bb
Merge "Register localOnly softapCallback for local only hotspot"
Mark Chien   authored and   Gerrit Code Review   commited 2022-05-17 09:07:38 +00:00
46c86bbf82
Prepare for refactoring wifi ipserver start/stop
This is a preparing change.
1) In enableWifiIpServing, replace
   ensureIpServerStarted(ifname) +
   changeInterfaceState(ifname, ipServingMode)
   with enableIpServing(TETHERING_WIFI, ifname, ipServingMode).

   And checking whether corresponding wifi or p2p feature is
   avaialble before enableWifiIpServing. Note: If the wifi or p2p
   feature wasn't supported before, it would still call
   changeInterfaceState without ipServer created but
   changeInterfaceState would be no-op because there is no
   corresponding ipServer for changing state.

2) Splitting enableWifiIpServing into enableWifiIpServing and
   enableWifiP2pIpServing.

3) No longer guess the interface name after T. WIFI_AP_STATE_CHANGED
   intent should always include ifname and it should be tracked by
   mTetherStates. If OEM have modification in wifi framework to send
   empty ifname, tethering no longer support this after T.

4) After T, tethering always trust the ifname which pass by wifi or p2p
   intent broadcast and treat it as TETHERING_WIFI or
   TETHERING_WIFI_P2P. This allow tethering to deprecate wifi/p2p regexs
   after T.

Bug: 189410000
Bug: 178116595
Bug: 185451791
Bug: 190145323
Bug: 176048959

Test: atest TetheringTests

Change-Id: Ia5f69ddf2d842536ce0df75eeae57866f56df571

markchien   commited 2022-05-16 21:17:40 +08:00
f2e9409f55
Register localOnly softapCallback for local only hotspot
Before T, wifi local only mode won't update onConnectedClientsChanged.
To support updating tethered client information for localOnly hotspot,
register localOnly softap callback to get connected wifi client update.

Bug: 171928468
Test: atest TetheringTests

Change-Id: I0e974feea9497809ea02a4138c7b9c2c584a8a45

markchien   commited 2022-05-16 15:09:10 +08:00
4ccb419602
Merge changes from topic "tethering_metrics"
* changes:
  Add tethering stats into statsd
  Injecting tethering stats into statsd

Treehugger Robot   authored and   Gerrit Code Review   commited 2022-05-16 05:06:01 +00:00
42f38d0bdf
Add tethering stats into statsd
Bug: 153942334
Test: atest TetheringTest IpServerTest
Test: Manual test with statsd_testdrive
Change-Id: I7205bb24dd30ba78b79bc352034da299d452750f

Wayne Ma   commited 2022-05-12 17:21:11 +08:00
6cd440fedd
Catch new exceptions from BpfMap
Bug: 230880517
Test: atest FrameworksNetTests
Change-Id: I9eff2589f83ac109fb6e8b9906da05890daa9bd9

Hungming Chen   commited 2022-05-12 14:13:01 +08:00
374107963a
Injecting tethering stats into statsd
Fill in downstream type, upstream type, error code and user type to NetworkTetheringReported.

Bug: 153942334
Test: m, flash and boot
Test: atest TetheringMetricsTest
Change-Id: I6ba7d9e512b1ada519f44f9f3a95667e4b0f03c0

Wayne Ma   commited 2022-05-09 19:35:53 +08:00
7ecded8248
Merge "[Tetheirng] Refactor carrier config to EntitlementManager"
Tom Hsu   authored and   Gerrit Code Review   commited 2022-04-21 13:43:14 +00:00
1135676150
[Tetheirng] Refactor carrier config to EntitlementManager
- To reduce CarrierConfigManager access times, move CarrierManager
  to TetheringConfiguration.

Bug: 225900149
Test: atest EntitlementManagerTest pass
Test: atest TetheringConfigurationTest pass
Change-Id: I5b206e2bc012cbbca26fb1e5c72558383981f183

tom hsu   commited 2022-04-21 12:44:26 +08:00
f0d60e9902
Add bpf forwording packet count test
- Add dumpsys option to dump stats map in BpfCoordinator
- Add stats test to check bpf forwording packet count in
  EthernetTetheringTest

Bug: 227159997
Test: atest TetheringCoverageTests
Change-Id: I177787ed0c28ebe137ff1431f40a23b1e4b22a19

Hungming Chen   authored and   Nucca Chen   commited 2022-04-20 08:54:08 +00:00
e32dbded7c
Tethering: replace argsContain with CollectionUtils.contains
Bug: 227159997
Test: adb shell dumpsys tethering --short
Change-Id: I6158d4cb4aecf9db4d7cc6698db898ce2cbb2c4c

Hungming Chen   authored and   Nucca Chen   commited 2022-04-20 08:53:49 +00:00
6abd0ff25d
BpfCoordinator: Add an option to choose which raw bpf map to dump
Make that tethering dumpsys can choose which map to dump.
The related functions in BpfCoordinator and its test are refactored
into template functions. This is used in the following commits which
will dump stats map for testing.

Bug: 227159997
Test: atest TetheringCoverageTests

Change-Id: I23d747543d16a971773c132b60227eb3f42efe25

Hungming Chen   commited 2022-04-20 15:58:47 +08:00
e4a6b28938
Merge "Add onSupportedTetheringType callback"
Mark Chien   authored and   Gerrit Code Review   commited 2022-04-20 03:38:42 +00:00
c4379c2440