[posix] only add IPv4 route if NAT64 is enabled (#9762)

Currently, when netlink informs that the network interface is up, an
IPv4 route is added if a valid one is specified. However, elsewhere we
only add/update the route when NAT64 is actually enabled. Since IPv4
route is not useful when NAT64 is not enabled, apply the same logic when
the network interface is started.

This avoids warnings when NAT64 is compiled in but disabled:
incoming message is an IPv4 datagram but no NAT64 prefix configured, drop
This commit is contained in:
Stefan Agner
2024-01-11 17:57:29 -08:00
committed by GitHub
parent 557ecf925f
commit 71aed827d5
+1 -1
View File
@@ -1357,7 +1357,7 @@ static void processNetifLinkEvent(otInstance *aInstance, struct nlmsghdr *aNetli
}
#if OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE && OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE
if (isUp && sActiveNat64Cidr.mLength > 0)
if (isUp && otNat64GetTranslatorState(gInstance) == OT_NAT64_STATE_ACTIVE)
{
// Recover NAT64 route.
if ((error = AddIp4Route(sActiveNat64Cidr, kNat64RoutePriority)) != OT_ERROR_NONE)