From 45fc50cb2e239a31411d1087253afaf2fbeddb1e Mon Sep 17 00:00:00 2001 From: Jonathan Hui Date: Wed, 4 Jun 2025 11:19:35 -0700 Subject: [PATCH] [fuzz] allow border router services to start (#11561) --- tests/fuzz/radio-one-node.cpp | 5 ++- tests/nexus/CMakeLists.txt | 1 + tests/nexus/openthread-core-nexus-config.h | 1 - tests/nexus/platform/nexus_infra_if.cpp | 45 ++++++++++++++++++++++ 4 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 tests/nexus/platform/nexus_infra_if.cpp diff --git a/tests/fuzz/radio-one-node.cpp b/tests/fuzz/radio-one-node.cpp index 2991f464e..33abe7882 100644 --- a/tests/fuzz/radio-one-node.cpp +++ b/tests/fuzz/radio-one-node.cpp @@ -96,6 +96,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) node.GetInstance().SetLogLevel(kLogLevelInfo); + node.GetInstance().Get().Init(/* aInfraIfIndex */ 1, /* aInfraIfIsRunning */ true); + node.GetInstance().Get().SetEnabled(true); node.GetInstance().Get().SetAutoEnableMode(true); node.GetInstance().Get().SetDhcp6PdEnabled(true); node.GetInstance().Get().SetNat64PrefixManagerEnabled(true); @@ -105,8 +107,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) Log("Form network"); node.Form(); - nexus.AdvanceTime(13 * 1000); + nexus.AdvanceTime(60 * 1000); VerifyOrQuit(node.Get().IsLeader()); + VerifyOrQuit(node.Get().GetState() == Srp::Server::kStateRunning); Log("---------------------------------------------------------------------------------------"); Log("Fuzz"); diff --git a/tests/nexus/CMakeLists.txt b/tests/nexus/CMakeLists.txt index 002f89f39..95e668067 100644 --- a/tests/nexus/CMakeLists.txt +++ b/tests/nexus/CMakeLists.txt @@ -42,6 +42,7 @@ set(COMMON_COMPILE_OPTIONS add_library(ot-nexus-platform platform/nexus_alarm.cpp platform/nexus_core.cpp + platform/nexus_infra_if.cpp platform/nexus_mdns.cpp platform/nexus_misc.cpp platform/nexus_node.cpp diff --git a/tests/nexus/openthread-core-nexus-config.h b/tests/nexus/openthread-core-nexus-config.h index def70f8e0..a491018e0 100644 --- a/tests/nexus/openthread-core-nexus-config.h +++ b/tests/nexus/openthread-core-nexus-config.h @@ -49,7 +49,6 @@ #define OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE 1 #define OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE 1 #define OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE 1 -#define OPENTHREAD_CONFIG_BORDER_ROUTING_MOCK_PLAT_APIS_ENABLE 1 #define OPENTHREAD_CONFIG_BORDER_ROUTING_USE_HEAP_ENABLE 1 #define OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE 1 #define OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE 1 diff --git a/tests/nexus/platform/nexus_infra_if.cpp b/tests/nexus/platform/nexus_infra_if.cpp new file mode 100644 index 000000000..9f805b42b --- /dev/null +++ b/tests/nexus/platform/nexus_infra_if.cpp @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2025, The OpenThread Authors. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include + +namespace ot { +namespace Nexus { + +extern "C" { + +bool otPlatInfraIfHasAddress(uint32_t, const otIp6Address *) { return false; } + +otError otPlatInfraIfSendIcmp6Nd(uint32_t, const otIp6Address *, const uint8_t *, uint16_t) { return OT_ERROR_NONE; } + +otError otPlatInfraIfDiscoverNat64Prefix(uint32_t) { return OT_ERROR_NOT_IMPLEMENTED; } + +} // extern "C" + +} // namespace Nexus +} // namespace ot