summaryrefslogtreecommitdiff
path: root/Tethering/tests/unit/src/android/net/ip/IpServerTest.java
Commit message (Collapse)AuthorAgeFilesLines
* Merge "Move TetherStatsKey and TetherStatsValue to common libs"Treehugger Robot2022-04-191-2/+2
|\
| * Move TetherStatsKey and TetherStatsValue to common libsHungming Chen2022-04-041-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | EthernetTetheringTest needs to parse BPF map content for bpf stats tests. Move the struct class files to common libs. Compare TetherStats{Key, Value}.java between frameworks/libs/net/common and packages/modules/Connectivity/Tethering. There is only the package name change as expected. $ diff packages/modules/Connectivity/Tethering/src/com/android/networkstack/tethering/TetherStatsKey.java frameworks/libs/net/common/device/com/android/net/module/util/bpf/TetherStatsKey.java 17c17 < package com.android.networkstack.tethering; Bug: 227159997 Test: atest TetheringCoverageTests Change-Id: I87193cb6409b4d19c72184011d7e99275800dab1
* | Add config_p2p_leases_subnet_prefix_length configurationmarkchien2022-03-311-0/+9
|/ | | | | | | | | | | | | | | | Add new rro configuration which can be used to make the p2p dhcp prefix length larger to reserve the address range outside of leases subnet prefix length for EAPOL-Key feature. This configuration only valid if its value larger than dhcp server address prefix length and config_tether_enable_legacy_wifi_p2p_dedicated_ip is true. E.g.:leaseSubnetPrefixLength = 25, p2p static address = 192.168.49.1/24 dhcp range: 192.168.49.0 ~ 192.168.49.127 (192.168.49.1/25), reserved 192.168.49.128 ~ 192.168.49.255 for EAPOL-Key feature. Bug: 170056953 Test: atest TetheringTests Change-Id: I1319efd871796da7234383a29ab64a1623101ae7
* Merge changes from topic "dedup-interfaceparams"Maciej Żenczykowski2022-03-051-1/+1
|\ | | | | | | | | | | * changes: Remove unused InterfaceParams jarjar rule Deduplicate InterfaceParams
| * Deduplicate InterfaceParamsPatrick Rohr2022-03-041-1/+1
| | | | | | | | | | | | | | | | CS should use InterfaceParams from frameworks/libs/net. Test: builds Bug: 222448728 Change-Id: I1f45d3171b265461a8724b4be7b212c030b63fe9
* | Pass whole TetheringConfiguration to IpServermarkchien2022-03-031-4/+7
|/ | | | | | | | | This is a no-op CL that passing whole TetheringConfiguration to IpServer to reduce the number of IpServer constructor parameters. Bug: 170056953 Test: atest TetheringTests Change-Id: I4ec17f7ecaefd7f275139ad9c7f7551635b192c9
* Move Tether4Key and Tether4Value to common libsHungming Chen2022-02-091-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | EthernetTetheringTest needs to parse BPF map content for IPv4 forwarding rule tests. Move the struct class files to common libs. Compare Tether4{Key, Value}.java between frameworks/libs/net/common and packages/modules/Connectivity/Tethering. There is only the package name change as expected. $ diff packages/modules/Connectivity/Tethering/src/com/android/networkstack/tethering/Tether4Key.java frameworks/libs/net/common/device/com/android/net/module/util/bpf/Tether4Key.java 17c17 < package com.android.networkstack.tethering; --- > package com.android.net.module.util.bpf; $ diff packages/modules/Connectivity/Tethering/src/com/android/networkstack/tethering/Tether4Value.java frameworks/libs/net/common/device/com/android/net/module/util/bpf/Tether4Value.java 17c17 < package com.android.networkstack.tethering; --- > package com.android.net.module.util.bpf; Test: atest TetheringCoverageTests Change-Id: I73c180fa4129aefde1e64ecbafe928f388b061d6
* Use new bluetooth API to enable/disable bt tethering after Tmarkchien2022-01-171-7/+24
| | | | | | | | | | | | | This change only apply to the device after T. Use new bluetooth API to change bluetooth tethering settings and the new API provide the callback to to notify Tethering when bluetooth interface is ready. Tethering doesn't use bluetooth interface status change event from netlink to add/remove IpServer anymore. Tag: #feature Bug: 190438212 Test: TetheringTest Change-Id: Iae92d98d500f83b116da7282cf1130fb8fecf53d
* Rename tethering util folder and its package namemarkchien2021-11-091-2/+2
| | | | | | | | | | | | | | Move tethering util files from android.net.util into com.android.networkstack.tethering.util. The goal is move all of tethering internal files into its own namespace com.android.networkstack.tethering.util. Bug: 205088391 Test: atest TetheringTests atest CtsTetheringTest atest TetheringPrivilegedTests Change-Id: I6559fb4f873b3cad5b210b10e49df1b6c6914a70
* bpfmap: Move to Common LocationTyler Wear2021-10-291-1/+1
| | | | | | | Move bpfmap to frameworks/libs/net/common/native. Bug: 179733303 Change-Id: Id08b216ec6a64968d66d7990f91ea7ce222a1154
* Import net-utils-device-common-netlink instead of netlink-client.Xiao Ma2021-07-211-5/+5
| | | | | | | | | | | | | After moving all netlink-client stuff to frameworks/libs/net/common and build it as an individual library, deprecate the netlink-client lib and use net-utils-device-common-netlink instead. Due to that the package name of netlink lib has changed, also update the package name used in Tethering and ConnectivityService module. Bug: 192535368 Test: atest TetheringTests TetheringIntegrationTests Change-Id: Ic2078caf67a640836d98c5a2e4ca89939adcb896
* Skip bpf offload if upstream interface is VCNmarkchien2021-07-131-0/+24
| | | | | | | | | 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
* Clear IPv4 offload rules when tethering stoppedHungming Chen2021-06-231-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* bpf: Add interface index to BPF devmapHungming Chen2021-05-121-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | Add upstream and downstream interface index to BPF map and rename the BPF map name from xdp_devmap to dev. $ adb shell dumpsys tethering Device map: ifindex (iface) -> ifindex (iface) 21 (21) -> 21 (21) 25 (25) -> 25 (25) 12 (rmnet_data2) -> 12 (rmnet_data2) $ adb shell ip addr 12: rmnet_data2 .. 21: wlan1 .. 25: rndis0 .. $ adb shell ls /sys/fs/bpf/tethering map_offload_tether_dev_map Test: atest TetheringCoverageTests Change-Id: Ic49965f3374d9e196ee672ec2f0e9e08f3847deb
* Populate the key destination mac addressHungming Chen2021-04-011-29/+54
| | | | | | | | | Required because XDP offload needs input interface mac address to be a part of the key. The mac address is used for checking packets which are received from exceped input interface. Test: atest TetheringCoverageTests, TetheringPrivilegedTests Change-Id: Ied159454b516c0d70efe0a85744d1bb606892f2d
* Set the limit whenever any IPv4 or IPv6 rule exists.Lorenzo Colitti2021-04-011-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | Currently, BpfCoordinator only sets the data limit on a given upstream whenever the first IPv6 rule is created on that upstream, and clears it whenever the last rule is deleted on that upstream. It never does this when adding or removing IPv4 rules. This makes it impossible to offload traffic on IPv4-only networks. Fix this by setting the limit when IPv4 rules are created or deleted as well. Test: atest TetheringCoverageTests Manual tests as the follows Test {add, clear} limit with IPv6-only network [OK] Test {add} limit with IPv4-only upstream [OK] TODO: Test {clear} limit with IPv4-only network. blocked by aosp/1579873 because the IPv4 rules have never deleted. Change-Id: I5a29bdd18e564318759f617023163e23fb5a3ed0
* [NFCT.TETHER.15] Attach BPF program in the mainline moduleHungming Chen2021-03-111-9/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Migrate Maze's BPF program attaching and detaching functions from system/netd/server/OffloadUtils.{c, h} to tethering module. Test: atest TetheringCoverageTests Test case #1: Enable WiFi hotspot and check tc filters are added or removed on both wlan1 and rmnet_data#. $ adb shell tc filter show dev wlan1 ingress filter protocol ipv6 pref 1 bpf chain 0 filter protocol ipv6 pref 1 bpf chain 0 handle 0x1 prog_offload_schedcls_tether_upstream6_ether:[*fsobj] direct-action not_in_hw id 2 tag 7cf020cc09a7c982 filter protocol ip pref 2 bpf chain 0 filter protocol ip pref 2 bpf chain 0 handle 0x1 prog_offload_schedcls_tether_upstream4_ether:[*fsobj] direct-action not_in_hw id 7 tag 2f87d55b636c082c $ adb shell tc filter show dev rmnet_data2 ingress; filter protocol ipv6 pref 1 bpf chain 0 filter protocol ipv6 pref 1 bpf chain 0 handle 0x1 prog_offload_schedcls_tether_downstream6_rawip:[*fsobj] direct-action not_in_hw id 3 tag 8b3885b75bd261de filter protocol ip pref 2 bpf chain 0 filter protocol ip pref 2 bpf chain 0 handle 0x1 prog_offload_schedcls_tether_downstream4_rawip:[*fsobj] direct-action not_in_hw id 6 tag b1c9478c91f8df9a Test case #2: Enable USB tethering and check tc filters are added or removed on both rndis0 and rmnet_data#. Test case #3: Enable WiFi and USB tethering and check tc filter are added or removed on rndis0, wlan1 and rmnet_data#. Change-Id: I3f9a65043271bc8f5bf1b82ae505c471625ca9de
* Remove IpServer.Dependencies#getIfIndex.Lorenzo Colitti2021-01-271-3/+0
| | | | | | | This code is unused. Test: atest TetheringTests Change-Id: Iaac422d72e8538b67798cb3ae3737deb7b426401
* Address comments on aosp/1559686.Lorenzo Colitti2021-01-271-8/+4
| | | | | | | Also remove some unnecessary line wrapping. Test: atest TetheringTests Change-Id: Ia7638b3198d7811cdbb34e959c50608cf1a656bf
* Program the upstream IPv6 map in BpfCoordinator.Lorenzo Colitti2021-01-271-9/+66
| | | | | | | | | | | - Add methods to start and stop IPv6 forwarding upstream - Populate the upstream IPv6 map when the first rule for any upstream/downstream pair is created. - Clear the upstream IPv6 map when the last rule for any upstream/downstream pair is deleted. Test: Added coverage to IpServerTest and BpfCoordinatorTest Change-Id: Ib041081e95f5f449489ab63138de034222ffac8f
* Rename TetherDownstream6Value to Tether6Value.Lorenzo Colitti2021-01-271-5/+5
| | | | | | | | The two value types are identical so there is no need to have separate classes for them. Test: atest TetheringTests Change-Id: Ia622b082d0a44373d21f51222f5e675e5bde08e0
* Merge changes from topic "bpf_tether4_rename"Lorenzo Colitti2021-01-261-8/+6
|\ | | | | | | | | | | | | * changes: merge Tether{Down,Up}stream4{Key,Value} - part 3 - fixups merge Tether{Down,Up}stream4{Key,Value} - part 2 - java merge Tether{Down,Up}stream4{Key,Value} - part 1 - C portion
| * merge Tether{Down,Up}stream4{Key,Value} - part 2 - javaMaciej Żenczykowski2021-01-251-8/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Generated via: git grep 'Tether(Down|Up)stream4(Key|Value)' | cut -d: -f1 | sort -u | while read i; do sed -r -i 's@TetherUpstream4Value@Tether4Value@g' "$i" sed -r -i 's@TetherDownstream4Value@Tether4Value@g' "$i" sed -r -i 's@TetherDownstream4Key@Tether4Key@g' "$i" sed -r -i 's@TetherUpstream4Key@Tether4Key@g' "$i" done cd Tethering/src/com/android/networkstack/tethering git mv TetherUpstream4Key.java Tether4Key.java git mv TetherUpstream4Value.java Tether4Value.java git diff TetherDownstream4Key.java Tether4Key.java git diff TetherDownstream4Value.java Tether4Value.java git rm TetherDownstream4Key.java git rm TetherDownstream4Value.java Fixup resulting 'import' duplication mcedit Tethering/apishim/31/com/android/networkstack/tethering/apishim/api31/BpfCoordinatorShimImpl.java mcedit Tethering/apishim/30/com/android/networkstack/tethering/apishim/api30/BpfCoordinatorShimImpl.java mcedit Tethering/apishim/common/com/android/networkstack/tethering/apishim/common/BpfCoordinatorShim.java mcedit Tethering/tests/unit/src/android/net/ip/IpServerTest.java Test: N/A, requires follow up commit Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I1dfc3108ca4bbd0cefc3420bc7e421594b62619c
* | Fix a WTF in IpServerTest.Lorenzo Colitti2021-01-261-0/+5
|/ | | | | | Bug: 178324405 Test: atest TetheringTests Change-Id: I2069ea79f982e6bb197388edd7820a05d1e651f1
* [NFCT.TETHER.10] Add/delete IPv4 offload BPF rules to/from BPF mapHungming Chen2021-01-251-0/+18
| | | | | | | Access the IPv4 downstream and upstream BPF map with the built rules. Test: atest TetheringCoverageTests Change-Id: I8cd6e49b377c72250988019eea57f93cccd78309
* [NFCT.TETHER.1] Add conntrack monitor to BpfCoordinatorHungming Chen2021-01-211-0/+7
| | | | | | | | A preparation for starting monitoring conntrack event which is required by IPv4 tethering offload. Test: atest TetheringCoverageTests Change-Id: Ied46aeca193554f52a90889dfdf92827e94845d6
* refactor: continuedMaciej Żenczykowski2021-01-201-8/+10
| | | | | | | | Test: builds, atest, TreeHugger git grep 'makeIngressKey|makeIngressValue|BpfIngressMap|TETHER_INGRESS_FS_PATH' no longer finds anything Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I27200d33cbc4ea2094b18e05bf93ab54c564da0b
* refactor: TetherIngress becomes TetherDownstream6 (and friends)Maciej Żenczykowski2021-01-191-22/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Generated via: #!/bin/bash do_replace() { pushd "$1" >/dev/null shift git grep "$1" | cut -d: -f1 | sort -u | while read f; do sed -i -r "s@$1@$2@g" "${f}" git add "${f}" done popd >/dev/null } replace() { do_replace packages/modules/Connectivity/Tethering "$@" do_replace system/netd "$@" } do_reset() { pushd "$1" >/dev/null git rhh popd >/dev/null } main() { do_reset packages/modules/Connectivity/Tethering do_reset system/netd replace TetherIngressKey TetherDownstream6Key replace TetherIngressValue TetherDownstream6Value pushd packages/modules/Connectivity/Tethering/src/com/android/networkstack/tethering >/dev/null git mv TetherIngressKey.java TetherDownstream6Key.java git mv TetherIngressValue.java TetherDownstream6Value.java popd >/dev/null replace TETHER_INGRESS_PROG TETHER_DOWNSTREAM6_TC_PROG replace ingress_tether tether_downstream6 replace ingress/tether_ tether_downstream6_ replace TETHER_INGRESS_MAP TETHER_DOWNSTREAM6_MAP replace tether_ingress_map tether_downstream6_map replace getTetherIngressMapFd getTetherDownstream6MapFd replace getTetherIngressProgFd getTetherDownstream6TcProgFd replace mBpfIngressMap mBpfDownstream6Map replace bpfIngressMap bpfDownstream6Map replace printIngressMap printDownstream6Map replace 'BPF ingress map' 'BPF downstream ipv6 map' } main "$@"; exit Followed by: cd system/netd # change regexp in tests/binder_test.cpp:3374 git add tests/binder_test.cpp (and whitespace adjustments to prevent lines from going over 100 characters) Afterwards we have: $ adbz shell ls /sys/fs/bpf/tethering map_offload_tether_downstream6_map map_offload_tether_limit_map map_offload_tether_stats_map map_test_tether_downstream6_map prog_offload_schedcls_tether_downstream6_ether prog_offload_schedcls_tether_downstream6_rawip prog_test_xdp_drop_ipv4_udp_ether Test: atest, TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Ib04dc0c6e3d034461f3f84e09f6fa93a862e1bb2
* [NFCT.TETHER.5] Migrate tetherOffloadSetInterfaceQuota from netd to mainlineHungming Chen2021-01-151-0/+8
| | | | | | | A preparation for updating BPF map in mainline module. Test: atest TetheringCoverageTests Change-Id: I67dfba750c7303e4aeaf65f5086db1290d176b4d
* [NFCT.TETHER.4] Migrate tetherOffloadRuleRemove from netd to mainlineHungming Chen2021-01-151-11/+33
| | | | | | | A preparation for updating BPF map in mainline module. Test: atest TetheringCoverageTests Change-Id: I969d6182a307f46c8ed0a30960deb460ecedd8ea
* [NFCT.TETHER.3] Migrate tetherOffloadGetStats from netd to mainlineHungming Chen2021-01-151-0/+8
| | | | | | | A preparation for updating BPF map in mainline module. Test: TetheringCoverageTests Change-Id: Ie73f7b4d9b191e62cfdfe2cfa3360cc7210f17e8
* [NFCT.TETHER.2] Migrate tetherOffloadRuleAdd from netd to mainlineHungming Chen2021-01-151-39/+100
| | | | | | | A preparation for updating BPF map in mainline module. Test: atest TetheringCoverageTests Change-Id: I6f8667bf110dae3e2805c2752ff59e7284a7bce0
* Make the IP subnet persistent till rebootmarkchien2020-10-061-7/+11
| | | | | | | | | Make the IP subnet persistent if it do not conflict with upstream. It allow client to reuse its IP that usually reduce DHCP procedure. Bug: 168169687 Test: atest TetheringTests Change-Id: Iddc5304730dce7b11c5d124b7eddce057d752bbd
* tethering: DAD Proxy DaemonTyler Wear2020-09-221-0/+91
| | | | | | | DAD proxy daemon responsible for forwarding NS/NA between tethered iface and upstream iface. Change-Id: I2e58e10e7fa7dba6a6f63ad03b000549f3afc37e
* Revert "Revert "Move Inet[4]AddressUtils to libs/net""Chalard Jean2020-08-071-1/+2
| | | | | | | | | | | | | | | This patch is still needed and should go in now that the error is fixed. The patch was submitted into rvc-dev and is already in rvc-dev-plus-aosp (patch in in ag/11923559, revert skipped in ag/12072199). A follow-up will remove the unused services.net-module-wifi target. Test: originally tested in aosp/1324109 Test: m; manual: flashed, wifi and telephony working Test: atest NetworkStackCoverageTests Change-Id: I1074eedb0b0f156a1135e11210ec102de15ea674 Merged-In: Icd141a992c46290c74929785e261a1cd57bc001b
* Always stop dhcp server even it is obsoletemarkchien2020-07-291-11/+43
| | | | | | | | If dhcp server is obsolete, explicitly stop it to shut down its thread. Bug: 161418295 Test: atest CtsTetheringTest Change-Id: Ic5b876bd23711ec8d832879a7baee0495246b218
* Revert "Move Inet[4]AddressUtils to libs/net"Chalard Jean2020-07-021-2/+1
| | | | | | | | | This reverts commit cf86031c12405ddb5817cf834c49a032480547b3. Reason for revert: Breaks the build b/160390899 Merged-In: Icd141a992c46290c74929785e261a1cd57bc001b Change-Id: Ie10e66f61393602f17fbb61bf17230b176bf1f44
* Move Inet[4]AddressUtils to libs/netRemi NGUYEN VAN2020-07-021-1/+2
| | | | | | | | | | | | | | | | | | The classes should not be picked up from frameworks/base, as they are part of several mainline modules. Also refine comments in DhcpResults following feedback in previous change. (cherry-pick from internal branch skipping wifi classes; no other conflict) Bug: 151052811 Test: m; manual: flashed, wifi and telephony working Test: atest NetworkStackCoverageTests Merged-In: I7074651c6a2a7a6b11bcf13cc4bb03833d7d655f Change-Id: I7074651c6a2a7a6b11bcf13cc4bb03833d7d655f
* Test that IpNeighborMonitor is stopped when IpServer stops.Lorenzo Colitti2020-06-181-0/+1
| | | | | | Bug: 159097215 Test: test-only change Change-Id: I2292c1cbff06a304f70191b88d833b19af2b8b92
* [BOT.12] Add unit test for disabling BpfCoordinator by configHungming Chen2020-06-161-4/+3
| | | | | | Bug: 150736748 Test: BpfCoordinatorTest Change-Id: Iedb936b7592b6be773d1b84a2498bfc5a440a198
* [BOT.11] BpfCoordinator could be disabled by device configHungming Chen2020-06-151-5/+37
| | | | | | Bug: 150736748 Test: BpfCoordinatorTest Change-Id: Id413b7f2f7edb2e5c3e02d5677fe536ed52fbbcb
* [BOT.6] Make BpfCoordinator to support data limitHungming Chen2020-06-091-46/+124
| | | | | | | | | | | | | | | | | | | | The BPF tethering coordinator listens to the forwarding rule changes for updating data limit which is applied in the following conditions. - After adding the first rule on a given upstream, add data limit. - After removing the last rule on a given upstream, clear data limit. - The service applies a new data limit on current upstream. The reason for relying on rule changes is because the Tethering and IpServer objects have multi-internal state machines. It is hard to synchronize all of their states. Note that the data limit cleanup for stopping or switching upstream relies on offload rules are all removed as well. Bug: 150736748 Test: manual Change-Id: I829d36339973f9473fe6b616c48aa288f18d1c46
* [BOT.2] Create a coordinator and stats provider to provide tether statsHungming Chen2020-05-291-3/+5
| | | | | | | | | | | Make BPF tethering offload coordinator, BpfCoordinator, registers a network stats provider, BpfTetherStatsProvider, and provide the tethering stats from the BPF map. Bug: 150736748 Test: new test BpfCoordinatorTest Change-Id: I22e71f87b67668f7e733e4f215d93bf5b2c9380d
* Tethering: ensure downstream prefix do not conflict with upstreammarkchien2020-05-271-24/+43
| | | | | | | | | | | | | | | | | - Add New class PrivateAddressCoordinator to coordinate the private address conflict problem. - Downstream prefix would be random in 192.168.0.0/24 ~ 192.168.255.0/24. - If new upstream prefix is conflict with existing downstream prefix, downstream would be kicked out and it would request a new one. - The last conflict upstream prefixes would be blacklist. Avoid to select downstream prefix which is conflict with prefixes in blacklist. Bug: 130879722 Test: -build, flash, boot -atest TetheringTests Change-Id: Ib45b87bcd9eeb5da03fb7ec90b1af9ca53998cf5
* Adjust TTL for ipv6 tetheringmarkchien2020-05-241-8/+54
| | | | | | | | | | | | If upstream is cellular, set the TTL in Router Advertisements to "network-set TTL - 1" for carrier requirement. For other non-cellular upstream, set TTL as "network-set TTL + 1" to preventing arbitrary distinction between tethered and untethered traffic. Bug: 154776299 Test: atest TetheringTests Change-Id: I7f2696a642f96c6aafb5613b980bf5bcdd08bbda
* Support MirrorLink DHCPDECLINE.Xiao Ma2020-05-131-7/+71
| | | | | | | | | Add the specific implementation of onNewPrefixRequest callback on IpServer side, also refactor some common code. Bug: 130741856 Test: atest TetheringTests Change-Id: If2871bf899cb5890bbfee18063a194c92b6f474e
* Use device option to control BPF offload featuresHungming Chen2020-05-051-9/+62
| | | | | | | | | | | If BPF offload device config is not enabled: - Does not add/remove offload forwarding rules through disabling IP neighbor monitor. - Does not apply the RA MTU reduction. Bug: 149997301 Test: atest IpServerTest Change-Id: I2d6f80f0229f580c4b16243a064e889a6c37f77a
* Don't crash when receiving an RTM_DELNEIGH or NUD_FAILED.Lorenzo Colitti2020-04-141-3/+5
| | | | | | | | | | | | | | | | These events don't have MAC addresses, so the code attempts to create an Ipv6ForwardingRule with a null MAC address. This crashes when attempting to get the raw MAC address bytes to send to netd in the TetherOffloadRuleParcel. This was not caught by unit tests because the test exercise this code path in a way that is not correct (by sending RTM_DELNEIGH and NUD_FAILED events with MAC addresses). Fix the unit tests to properly pass in null MAC addresses for these events. Bug: 153697068 Test: fixed existing tests to be more realistic Change-Id: I26d89a81f1c448d9b4809652b079a5f5eace3924
* Migrate to TetherOffloadRuleParcel in IpServerLorenzo Colitti2020-04-041-30/+79
| | | | | | | | | | The netd tethering offload IPCs are changing from taking a list of primitives to taking a TetherOffloadRuleParcel. Modify their only caller. Bug: 140541991 Test: atest IpServerTest Change-Id: I83718c80ef9d31199c87021b4dd5821717fd5ba5
* TetheringManager API clean upmarkchien2020-03-191-2/+2
| | | | | | | | | | | | | | | | | | | | | | | Per API review: - @IntDef defined on the type integer parameter - have getters on each parameter that is set in the TetheringRequest.Builder - new added API should not be deprecated Below APIs is moved from system-current to module-lib-current that only plafrom code(e.g. ConnectivityManager and Settings) can use them. TetheringRequest. onTetherableInterfaceRegexpsChanged, TetheringInterfaceRegexps: Only platform code can use them because interfaces by regular expressions are a mechanism which is planning to be deprecated. Also rename some constants for easier to understand. Bug: 149858697 Bug: 151243337 Test: m doc-comment-check-docs atest TetheringTests Change-Id: I45cb21d5bc919f6d32c42650326597d5173ea028 Merged-In: Idd041f0fbeca411ea23e49786a50dd7feb77ef45