Merge "[mdns] add elapsedRealTime() to Dependencies for MdnsRecordRepository" into main
diff --git a/netbpfload/loader.cpp b/netbpfload/loader.cpp
index a2fa4b8..f5e45d6 100644
--- a/netbpfload/loader.cpp
+++ b/netbpfload/loader.cpp
@@ -769,7 +769,7 @@
.max_entries = max_entries,
.map_flags = md[i].map_flags,
};
- if (isAtLeastKernelVersion(4, 14, 0))
+ if (isAtLeastKernelVersion(4, 15, 0))
strlcpy(req.map_name, mapNames[i].c_str(), sizeof(req.map_name));
fd.reset(bpf(BPF_MAP_CREATE, req));
saved_errno = errno;
diff --git a/tests/cts/net/src/android/net/cts/ApfIntegrationTest.kt b/tests/cts/net/src/android/net/cts/ApfIntegrationTest.kt
index 7a4d90b..0e57019 100644
--- a/tests/cts/net/src/android/net/cts/ApfIntegrationTest.kt
+++ b/tests/cts/net/src/android/net/cts/ApfIntegrationTest.kt
@@ -39,6 +39,7 @@
import android.system.OsConstants.IPPROTO_ICMP
import android.system.OsConstants.SOCK_DGRAM
import android.system.OsConstants.SOCK_NONBLOCK
+import android.util.Log
import androidx.test.platform.app.InstrumentationRegistry
import com.android.compatibility.common.util.PropertyUtil.getVsrApiLevel
import com.android.compatibility.common.util.SystemUtil.runShellCommand
@@ -62,8 +63,8 @@
import java.lang.Thread
import java.net.InetSocketAddress
import java.util.concurrent.CompletableFuture
-import java.util.concurrent.ExecutionException
import java.util.concurrent.TimeUnit
+import java.util.concurrent.TimeoutException
import kotlin.random.Random
import kotlin.test.assertFailsWith
import kotlin.test.assertNotNull
@@ -83,6 +84,8 @@
@AppModeFull(reason = "CHANGE_NETWORK_STATE permission can't be granted to instant apps")
@RunWith(DevSdkIgnoreRunner::class)
@NetworkStackModuleTest
+// ByteArray.toHexString is experimental API
+@kotlin.ExperimentalStdlibApi
class ApfIntegrationTest {
companion object {
private val PING_DESTINATION = InetSocketAddress("8.8.8.8", 0)
@@ -111,7 +114,7 @@
private val network: Network
) : PacketReader(handler, RCV_BUFFER_SIZE) {
private var sockFd: FileDescriptor? = null
- private val futureReply = CompletableFuture<ByteArray>()
+ private var futureReply: CompletableFuture<ByteArray>? = null
override fun createFd(): FileDescriptor {
// sockFd is closed by calling super.stop()
@@ -124,7 +127,9 @@
override fun handlePacket(recvbuf: ByteArray, length: Int) {
// Only copy the ping data and complete the future.
- futureReply.complete(recvbuf.sliceArray(8..<length))
+ val result = recvbuf.sliceArray(8..<length)
+ Log.i(TAG, "Received ping reply: ${result.toHexString()}")
+ futureReply!!.complete(recvbuf.sliceArray(8..<length))
}
fun sendPing(data: ByteArray) {
@@ -142,20 +147,18 @@
// +-+-+-+-+-
val icmpHeader = byteArrayOf(0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
val packet = icmpHeader + data
+ Log.i(TAG, "Sent ping: ${packet.toHexString()}")
+ futureReply = CompletableFuture<ByteArray>()
Os.sendto(sockFd!!, packet, 0, packet.size, 0, PING_DESTINATION)
}
fun expectPingReply(): ByteArray {
- return futureReply.get(TIMEOUT_MS, TimeUnit.MILLISECONDS)
+ return futureReply!!.get(TIMEOUT_MS, TimeUnit.MILLISECONDS)
}
fun expectPingDropped() {
- assertFailsWith(IllegalStateException::class) {
- try {
- futureReply.get(TIMEOUT_MS, TimeUnit.MILLISECONDS)
- } catch (e: ExecutionException) {
- throw e.cause!!
- }
+ assertFailsWith(TimeoutException::class) {
+ futureReply!!.get(TIMEOUT_MS, TimeUnit.MILLISECONDS)
}
}
@@ -303,7 +306,7 @@
}
fun installProgram(bytes: ByteArray) {
- val prog = HexDump.toHexString(bytes, 0 /* offset */, bytes.size, false /* upperCase */)
+ val prog = bytes.toHexString()
val result = runShellCommandOrThrow("cmd network_stack apf $ifname install $prog").trim()
// runShellCommandOrThrow only throws on S+.
assertThat(result).isEqualTo("success")