mirror of
https://github.com/espressif/openthread.git
synced 2026-07-28 14:47:46 +00:00
[test] enable NAT64 translator unit tests (#11845)
This commit makes several updates to enable and fix NAT64 unit test - Enables the NAT64 translator in `toranj` test configs, ensuring that the `test_nat64` unit test is now covered by the GitHub Actions CI (under the `toranj` workflow). - Enable `OPENTHREAD_CONFIG_NAT64_PORT_TRANSLATION_ENABLE` for the POSIX `toranj` build while disabling it for the simulation build, ensuring both configurations are built and covered by CI. - Fixes the `test_nat64` unit test by removing an incorrect "mapping pool exhausted" step. This step is now invalid as the pool size is configured to a much larger value (254) via `OPENTHREAD_CONFIG_NAT64_MAX_MAPPINGS`.
This commit is contained in:
@@ -161,9 +161,6 @@ extern int
|
||||
|
||||
unsigned int gNetifIndex = 0;
|
||||
char gNetifName[IFNAMSIZ];
|
||||
#if OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE
|
||||
static otIp4Cidr sActiveNat64Cidr;
|
||||
#endif
|
||||
|
||||
const char *otSysGetThreadNetifName(void) { return gNetifName; }
|
||||
|
||||
@@ -214,10 +211,6 @@ static uint8_t sAddedExternalRoutesNum = 0;
|
||||
static otIp6Prefix sAddedExternalRoutes[kMaxExternalRoutesNum];
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE && OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE
|
||||
static constexpr uint32_t kNat64RoutePriority = 100; ///< Priority for route to NAT64 CIDR, 100 means a high priority.
|
||||
#endif
|
||||
|
||||
#if defined(RTM_NEWMADDR) || defined(__NetBSD__)
|
||||
// on some BSDs (mac OS, FreeBSD), we get RTM_NEWMADDR/RTM_DELMADDR messages, so we don't need to monitor using MLD
|
||||
// on NetBSD, MLD monitoring simply doesn't work
|
||||
@@ -976,6 +969,11 @@ static void processAddressChange(const otIp6AddressInfo *aAddressInfo, bool aIsA
|
||||
}
|
||||
|
||||
#if defined(__linux__) && OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE
|
||||
|
||||
static otIp4Cidr sActiveNat64Cidr;
|
||||
|
||||
static constexpr uint32_t kNat64RoutePriority = 100; // Priority for route to NAT64 CIDR, 100 means a high priority.
|
||||
|
||||
static bool isSameIp4Cidr(const otIp4Cidr &aCidr1, const otIp4Cidr &aCidr2)
|
||||
{
|
||||
bool res = true;
|
||||
|
||||
@@ -70,6 +70,8 @@
|
||||
|
||||
#define OPENTHREAD_POSIX_CONFIG_NAT64_AIL_PREFIX_ENABLE 1
|
||||
|
||||
#define OPENTHREAD_CONFIG_NAT64_PORT_TRANSLATION_ENABLE 1
|
||||
|
||||
// The following two features (`USE_HEAP`) are set explicitly on posix `toranj`
|
||||
// to validate the build with these config. The `toranj` build under simulation
|
||||
// platform covers the opposite configs (allows `USE_HEAP`).
|
||||
|
||||
@@ -93,6 +93,8 @@
|
||||
|
||||
#define OPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE 1
|
||||
|
||||
#define OPENTHREAD_CONFIG_NAT64_PORT_TRANSLATION_ENABLE 0
|
||||
|
||||
#define OPENTHREAD_CONFIG_RADIO_STATS_ENABLE 0
|
||||
|
||||
#define OPENTHREAD_CONFIG_TREL_MANAGE_DNSSD_ENABLE 0
|
||||
|
||||
@@ -54,6 +54,8 @@
|
||||
|
||||
#define OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
|
||||
|
||||
#define OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
|
||||
|
||||
#define OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_ENABLE 1
|
||||
|
||||
#define OPENTHREAD_CONFIG_BORDER_ROUTING_DHCP6_PD_CLIENT_ENABLE 1
|
||||
|
||||
@@ -314,17 +314,6 @@ void TestNat64(void)
|
||||
TestCase4To6("no v4 mapping", kIp4Packet, Nat64::Translator::kDrop, nullptr, 0);
|
||||
}
|
||||
|
||||
{
|
||||
// fd02::2 fd01::ac10:f3c5 UDP 52 43981 → 4660 Len=4
|
||||
const uint8_t kIp6Packet[] = {
|
||||
0x60, 0x08, 0x6e, 0x38, 0x00, 0x0c, 0x11, 0x40, 0xfd, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xfd, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
172, 16, 243, 197, 0xab, 0xcd, 0x12, 0x34, 0x00, 0x0c, 0xe3, 0x30, 0x61, 0x62, 0x63, 0x64,
|
||||
};
|
||||
|
||||
TestCase6To4("mapping pool exhausted", kIp6Packet, Nat64::Translator::kDrop, nullptr, 0);
|
||||
}
|
||||
|
||||
testFreeInstance(sInstance);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user