From 08c48a3dff1ff913f882c562fcc3326dd39a4440 Mon Sep 17 00:00:00 2001 From: Hungming Chen Date: Wed, 27 Apr 2022 19:35:10 +0800 Subject: [PATCH] Ignore UDP offload test on kernel which is older than 4.14 Kernel version which is older than 4.14 doesn't support UDP offload absolutely. Kernel version which is between 4.14 and 5.8 support UDP offload probably. Simply set kernel 4.14 to be threshold first and monitor on what devices tests fail for improving the offload support checking. Also fix a minor bug which UDP tethering without offload is not tested on R. Bug: 230359047 Test: atest EthernetTetheringTest Change-Id: Ieb181d1b5ed67b922e18ce77a9c96208b2984d10 --- .../android/net/EthernetTetheringTest.java | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/Tethering/tests/integration/src/android/net/EthernetTetheringTest.java b/Tethering/tests/integration/src/android/net/EthernetTetheringTest.java index e73b7d5a35..3699f7a4c1 100644 --- a/Tethering/tests/integration/src/android/net/EthernetTetheringTest.java +++ b/Tethering/tests/integration/src/android/net/EthernetTetheringTest.java @@ -59,6 +59,7 @@ import android.os.Handler; import android.os.HandlerThread; import android.os.SystemClock; import android.os.SystemProperties; +import android.os.VintfRuntimeInfo; import android.text.TextUtils; import android.util.Base64; import android.util.Log; @@ -84,6 +85,7 @@ import com.android.net.module.util.structs.UdpHeader; import com.android.testutils.DevSdkIgnoreRule; import com.android.testutils.DevSdkIgnoreRule.IgnoreAfter; import com.android.testutils.DevSdkIgnoreRule.IgnoreUpTo; +import com.android.testutils.DeviceInfoUtils; import com.android.testutils.DumpTestUtils; import com.android.testutils.HandlerUtils; import com.android.testutils.TapPacketReader; @@ -1058,19 +1060,33 @@ public class EthernetTetheringTest { } @Test - @IgnoreAfter(Build.VERSION_CODES.Q) - public void testTetherUdpV4WithoutBpf() throws Exception { + @IgnoreAfter(Build.VERSION_CODES.R) + public void testTetherUdpV4UpToR() throws Exception { initializeTethering(); runUdp4Test(new TetheringTester(mDownstreamReader), new RemoteResponder(mUpstreamReader), false /* usingBpf */); } + private static boolean isUdpOffloadSupportedByKernel() { + final String kVersionString = VintfRuntimeInfo.getKernelVersion(); + // Kernel version which is older than 4.14 doesn't support UDP offload absolutely. Kernel + // version which is between 4.14 and 5.8 support UDP offload probably. Simply apply kernel + // 4.14 to be threshold first and monitor on what devices tests fail for improving the + // offload support checking. + return DeviceInfoUtils.compareMajorMinorVersion(kVersionString, "4.14") >= 0; + } + @Test @IgnoreUpTo(Build.VERSION_CODES.R) - public void testTetherUdpV4WithBpf() throws Exception { + public void testTetherUdpV4AfterR() throws Exception { initializeTethering(); + boolean usingBpf = isUdpOffloadSupportedByKernel(); + if (!usingBpf) { + Log.i(TAG, "testTetherUdpV4AfterR will skip BPF offload test for kernel " + + VintfRuntimeInfo.getKernelVersion()); + } runUdp4Test(new TetheringTester(mDownstreamReader), new RemoteResponder(mUpstreamReader), - true /* usingBpf */); + usingBpf); } @Nullable