Commit Graph

662 Commits

Author SHA1 Message Date
Hungming Chen
887a22cc4a Move Tether4Key and Tether4Value to common libs
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
2022-02-09 10:45:37 +00:00
Lorenzo Colitti
1705eb9964 Extract TestBpfMap from BpfCoordinatorTest.
The class is being moved to a common test utils location in
another CL in this topic.

Test: atest BpfCoordinatorTest
Change-Id: Ibf8dae3e05aacaea4f7c3fe8229d87e1ad6a68d5
2022-02-03 22:53:07 +01:00
Patrick Rohr
3157918fc9 Add jarjar rule for com.android.testutils.TestBpfMap
TestBpfMap needs to be jarjar'ed to work with ConnectivityCoverageTests
which combines both framework tests and tethering tests (and their
respective jarjar rules).

Test: atest ConnectivityCoverageTests:BpfCoordinatorTest
Change-Id: Ie3e7f0be9aeb848978f0df97be48100c808086bc
2022-02-03 22:53:07 +01:00
markchien
69681d65a5 Use new bluetooth API to enable/disable bt tethering after T
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
2022-01-17 16:47:43 +08:00
Treehugger Robot
0d4f956b34 Merge "Bump tethering target sdk version to 31" 2022-01-13 05:00:02 +00:00
markchien
bf62258f8c Bump tethering target sdk version to 31
Also add BLUETOOTH_CONNECT permission which is needed for access
PanService if target sdk 31+. The permission would be granted to
privilege application without prompt.

Also remove the min_sdk_version 29 from AndroidManifest because it is
useless that the Android.bp already define min_sdk_version 30.

$aapt dump xmltree TetheringNext.apk AndroidManifest.xml
N: android=http://schemas.android.com/apk/res/android
  E: manifest (line=19)
    A: android:sharedUserId(0x0101000b)="android.uid.networkstack" (Raw: "android.uid.networkstack")
    A: android:versionCode(0x0101021b)=(type 0x10)0x1f
    A: android:versionName(0x0101021c)="Tiramisu" (Raw: "Tiramisu")
    A: android:compileSdkVersion(0x01010572)=(type 0x10)0x1f
    A: android:compileSdkVersionCodename(0x01010573)="Tiramisu" (Raw: "Tiramisu")
    A: package="com.android.networkstack.tethering" (Raw: "com.android.networkstack.tethering")
    A: platformBuildVersionCode=(type 0x10)0x1f
    A: platformBuildVersionName="Tiramisu" (Raw: "Tiramisu")
    E: uses-sdk (line=23)
      A: android:minSdkVersion(0x0101020c)=(type 0x10)0x1e
      A: android:targetSdkVersion(0x01010270)=(type 0x10)0x1f
    ....
    E: uses-permission (line=35)
      A: android:name(0x01010003)="android.permission.BLUETOOTH_CONNECT" (Raw: "android.permission.BLUETOOTH_CONNECT")

Bug: 204265450
Test: manual testing bluetooth tethering and TH
Change-Id: I6f821020679b9379cada29f6f0816187545a24fb
2022-01-12 07:24:16 +00:00
Hungming Chen
bb8e9dae7f Add tethering IPv4 UDP forwarding test
This is a preparation for testing IPv4 BPF offload.
- Add an ARP responder.
- Add a basic UDP forwarding test.

Test: atest EthernetTetheringTest
Change-Id: I720a5a2c4b97493eb6a5570cecd73dfc1eabf5cd
2022-01-03 07:16:16 +00:00
Treehugger Robot
139f43509e Merge "Support testing upload/download packets" 2021-12-23 04:22:59 +00:00
markchien
1e020903cc Reuse BluetoothPan object and use it under tethering handler thread
1. Instead of create BluetoothPan every time when tethering need to use
it, store it with mBluetoothPan and resue it.
2. Call BluetoothPan function under tethering handler thread.

Bug: 190438212
Test: atest TetheringTests

Change-Id: I40adece59960ec44a02dc438d6bd95483a0788af
2021-12-16 12:12:07 +08:00
Ken Chen
5fabfd8dd0 Merge "[NETD-BPF#3] Relocate Tethering/bpf_progs and rename bpf_tethering_headers" 2021-12-02 12:54:01 +00:00
markchien
13e5a48cb7 Support testing upload/download packets
This is a preparing CL to test the packets sent from clients and the
packets replied from remote side.

Bug: 183166581
Test: atest EthernetTetheringTest
Change-Id: I898de024c0d9ecf13d81023035242c4abf856702
2021-11-29 18:02:24 +08:00
markchien
598a75ba8c Add defaults to enable/disable connectivity/tethering next
The defaults can be used to enable/disable connectivity next targets
depending on the branch, while minimizing merge conflicts.

The "next" target may use unstable APIs. It need to be disabled in the
branch which only have the last stable SDK available.

Also correct TetheringTestsLatestSdkLib which should use stable API.

Test: TH
Change-Id: I00d91bbd513277c1cedf67d18ac9f56cc4037309
2021-11-24 12:20:23 +08:00
Ken Chen
bb57fa9eec [NETD-BPF#3] Relocate Tethering/bpf_progs and rename bpf_tethering_headers
The folder is currently used by tether offload only. Because we will
move netd.c and clatd.c to it, the folder should be moved to the upper
tier.

Also, rename bpf_tethering_headers to bpf_connectivity_headers so that
other connectivity code besides to tethering are justified to use it.

Bug: 202086915
Test: atest FrameworksNetTests
Change-Id: I95943c6e909f1fdca12604ef0c55d67c39ca686b
2021-11-20 18:31:08 +08:00
markchien
f967b11087 Rename tethering jni and get the jni by its package name
tetherutiljni is renamed to com_android_networkstack_tethering_jni_util

Bug: 205088391
Test: atest TetheringTests
      atest CtsTetheringTest
      atest TetheringPrivilegedTests
Change-Id: Ifd1f4473625e33d3ebe190c9f8a2b5d54aa1ff49
2021-11-10 14:07:24 +08:00
markchien
d02f9af918 Rename tethering util folder and its package name
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
2021-11-09 17:02:47 +08:00
markchien
45dc794fb4 Fix TetheringPrivilegedTests crash
After separat BpfMap to a library, its package name is jarjar to
com.android.network.stack.util*. Also jarjar BpfMap of
TetheringPrivilegedTests to fix crash in jni registered.

Bug: 179733303
Test: atest TetheringPrivilegedTests
Change-Id: Ia9bc819a44fe26bf2ff7a46351ea60f2eeb02933
2021-11-04 16:40:18 +08:00
Maciej Żenczykowski
bb4c6073ec Merge "bpfmap: Move to Common Location" 2021-11-04 01:50:15 +00:00
Kimberly Kreider
200e42063c Merge "Replace "mts" with "mts-tethering"." 2021-11-01 23:43:53 +00:00
Tyler Wear
e8043ca762 bpfmap: Move to Common Location
Move bpfmap to frameworks/libs/net/common/native.

Bug: 179733303
Change-Id: Id08b216ec6a64968d66d7990f91ea7ce222a1154
2021-10-29 09:05:33 -07:00
Chalard Jean
adcec9ebbe Move to f/l/n instead of RouteUtils
Test: TetheringTests
Change-Id: I35b36538463a7fc2f02e142719c898d1694b2d6b
2021-10-29 16:05:46 +09:00
Kimberly Kreider
c5b3f34831 Replace "mts" with "mts-tethering".
Bug: 203466102
Test: build locally and verified contents
Change-Id: I7cccb54c0ad1a3bd8da0bcb7ad6474aa1e734299
2021-10-20 18:16:59 +00:00
Treehugger Robot
f8d1f3d1cd Merge "Unregister the tethering internal callback in finalize" 2021-10-20 08:40:08 +00:00
Treehugger Robot
9d0c5419c9 Merge "Test TetheringManager could be GC after getting connector" 2021-10-20 07:48:10 +00:00
markchien
819e19ea2a Unregister the tethering internal callback in finalize
Bug: 177265744
Bug: 191798390
Bug: 187972579
Test: atest TetheringServiceTest
Change-Id: Ie7f9535b923db5073a59329ead22546a54e6ef47
2021-10-20 06:57:58 +00:00
markchien
e7b4a505aa Test TetheringManager could be GC after getting connector
There is pollingConnector thread which start polling connector if
TetheringManager is created earlier than TetheringService started(during
device boot up). TetheringManager won't be GCed if pollingConnector
thread do not finish its task yet.

Bug: 177265744
Bug: 191798390
Bug: 187972579
Test: atest TetheringServiceTest
Change-Id: Id8c7d10c5172e1d5de460c5311ff9c20261facef
2021-10-20 06:06:04 +00:00
Treehugger Robot
d7d41a73e7 Merge "Fix TetheringManager memory leak" 2021-10-20 03:59:59 +00:00
markchien
1110b725a0 Fix TetheringManager memory leak
TetheringCallbackInteranl is inner class which explicitly reference
TetheringManager object. This causes TetheringManager can't be GC. Using
static nested class which has its own lifecycle and weak reference
TetheringManager object.

Still have a leak inside Tethering that TetheringCallbackInternal is
never unregistered. Currently it rely on binder died to remove the
reference, which usually happen in kill process. If process keep alive,
the TetheringCallbackInternal would not be freed even TetheringManager is
gone. Will have follow CL to fix this.

Bug: 177265744
Bug: 191798390
Bug: 187972579
Test: 1. lunch Settings with ON/OFF tethering, dump java heap.
      2. close Settings and restart Settings again, dump java heap.
      3. Compare java heap between step 1 and step 2.
Change-Id: I0e2a21b7988115098a033a581cd98da8bffe2791
2021-10-14 14:02:11 +08:00
markchien
97ac1a93fa Move runDhcp to TetheringTester am: f320c21120
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1817921

Change-Id: I74d5c4a6c88fb26e35218f05ef468fa125a340d4
2021-09-30 15:00:11 +00:00
markchien
f320c21120 Move runDhcp to TetheringTester
This is a no-op CL which add TetheringTester and move runDhcp related
logic to it.

Test: atest EthernetTetheringTest
Change-Id: Ib1c5647b2bd5a1b27c976450d3aa265aff8f5b70
2021-09-30 12:57:30 +00:00
markchien
7ea99be9d6 Rename mTapPacketReader to mDowntreamReader am: 0bd10760a8
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1824633

Change-Id: I1cde888d4502463bbd6d49a3b76f3f8a6d676483
2021-09-30 12:48:20 +00:00
Mark Chien
da862b2a35 Merge "Support set test network to tethering upstream" am: 473d864d20
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1797991

Change-Id: Ifd5c76a943886dfe55e9b68eeb77931dae6fe204
2021-09-30 12:48:15 +00:00
markchien
0bd10760a8 Rename mTapPacketReader to mDowntreamReader
Test: atest EthernetTetheringTest
Change-Id: I2905aba449a2625caf6a82b27b9e43b06191da9f
2021-09-30 12:36:28 +00:00
markchien
2fbd3e72d3 Support set test network to tethering upstream
Test: atest EthernetTetheringTest

Change-Id: Ief2a92bc6c573a6bb75c72b7a0630e5c0accfa73
2021-09-30 10:14:58 +00:00
Treehugger Robot
096498601e Merge "Replace inexact alarm setRepeasting with setExact alarm" am: 507de1cac6
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1793479

Change-Id: Ia989bed2395130329ce5946cb7ece91089fc8571
2021-08-30 14:01:49 +00:00
Treehugger Robot
507de1cac6 Merge "Replace inexact alarm setRepeasting with setExact alarm" 2021-08-30 13:42:25 +00:00
Hungming Chen
5dbbd2f132 Refactor the offload permission check and add tests am: b344870ea0
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1803422

Change-Id: I857de882e6f613d3bf57d271532f761be10bf988
2021-08-27 05:02:15 +00:00
Hungming Chen
b344870ea0 Refactor the offload permission check and add tests
- Rename the conntrack destination port check function
- Use CollectionUtils.contains to check the denied ports
- Add tests for the streams with ftp and pptp tcp port are
  not able to be offloaded

Bug: 195914327
Test: atest TetheringCoverageTests
Change-Id: I7e2591bea1f6db46271efb0c30970fb8d4efe1e4
2021-08-26 21:21:05 +08:00
Lorenzo Colitti
c1256c4cf3 Give EthernetTetheringTest the restricted networks permission. am: 8fbadf4ac5
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1807157

Change-Id: I13defb1e00586393e91ca19100cf437482a64090
2021-08-24 08:54:53 +00:00
Lorenzo Colitti
8fbadf4ac5 Give EthernetTetheringTest the restricted networks permission.
This test fails on devices where physical Ethernet interfaces are
available but marked restricted, like cuttlefish.

Bug: 197462993
Test: test-only change
Change-Id: I15c991b2e43e2d5e823dcdcfbd74adfd9b2f6f08
2021-08-24 15:18:54 +09:00
markchien
52158b1d47 Replace inexact alarm setRepeasting with setExact alarm
Use exact alarm to fix entilement recheck delay problem while device
asleep.

Bug: 195370891
Test: atest TehteringTests
Change-Id: I409e603bf2b990657551e1140b50f69640c328d8
2021-08-12 13:32:54 +08:00
Xiao Ma
f29e0435a9 Merge "Import net-utils-device-common-netlink instead of netlink-client." am: 609e71a46c am: dd7e9e8800
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1753303

Change-Id: I4fb162f20f5816de1ee1b784cb39533362b34677
2021-08-04 07:56:23 +00:00
Xiao Ma
609e71a46c Merge "Import net-utils-device-common-netlink instead of netlink-client." 2021-08-04 07:27:18 +00:00
Nucca Chen
e17f852861 Merge "Throw an errno exception when open BPF map failed" am: 22d5336279 am: 84c87a49b1
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1772440

Change-Id: Ib933a28d7ad5504def71e012a83b9080048fa37e
2021-08-03 09:00:34 +00:00
Nucca Chen
22d5336279 Merge "Throw an errno exception when open BPF map failed" 2021-08-03 08:38:42 +00:00
Hungming Chen
1257e9bfff Throw an errno exception when open BPF map failed
Needed because an invalid file descriptor should notify the caller to
stop using the object.

Bug: 190523685

Test: atest BpfMaptest
Change-Id: I70fb08b54b1c0caa4be4e3f07b59bf4f2397f39d
2021-08-03 08:38:16 +00:00
Remi NGUYEN VAN
96019d9353 Merge "Do not apply jarjar rules on intermediate libs" am: c1e68abd6f am: 4972bf1971
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1778569

Change-Id: I4bf35535002bc1ec90913a941923f9c6e0a1c72b
2021-08-03 08:19:31 +00:00
Remi NGUYEN VAN
c1e68abd6f Merge "Do not apply jarjar rules on intermediate libs" 2021-08-03 07:50:29 +00:00
Remi NGUYEN VAN
0015f04ec7 Do not apply jarjar rules on intermediate libs
Using jarjar on intermediate libraries causes issues when they are
combined with other libraries that use different jarjar rules, as the
resulting binary may contain multiple incompatible copies of the
classes. Instead, jarjar should be used on the final artifact, after
combining the libraries.

Ensure NetworkStackJarJarRules is not applied on intermediate libraries
like TetheringIntegrationTestsLib, but instead apply it on
TetheringIntegrationTests or CtsTetheringTest.

Bug: 192535368
Test: atest TetheringCoverageTests TetheringIntegrationTests \
          CtsTetheringTest
Change-Id: I248a533651984de81f676336c0e74e3788610bbb
2021-08-02 19:13:09 +09:00
Remi NGUYEN VAN
6a0a33dcf3 Remove hidden ArrayUtils usage in TetheringTest am: 3dfafbb516 am: 53b6370ec6
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1779756

Change-Id: I715be738618531ae541db589255129149cf4b306
2021-07-29 07:40:07 +00:00
Remi NGUYEN VAN
3dfafbb516 Remove hidden ArrayUtils usage in TetheringTest
Use CollectionUtils instead, which avoids using a hidden API.

Avoiding hidden API usage in tests is good in general, but this also
helps avoid jarjar problems where the com.android.internal.util package
is jarjared to some other package as some of its classes are included
in the module, and ArrayUtils cannot be found in the renamed package.

Bug: 192535368
Test: atest TetheringTest
Change-Id: I54dc8f6429d132a953ab1a674fe349fba4335936
2021-07-28 17:00:20 +09:00