[nat64] ensure to extend mapping lifetime on reuse (#11866)

Previously, a NAT64 mapping's lifetime was only extended upon its
initial allocation. This meant that if an existing mapping was found
and reused, its expiration timer would not be refreshed, potentially
leading to its premature removal.

This change moves the `mapping->Touch()` call from `AllocateMapping()` to
`TranslateFromIp6()`. This ensures that a mapping's lifetime is
extended every time it is used for translation, whether it is newly
allocated or an existing one being reused.
This commit is contained in:
Abtin Keshavarzian
2025-08-28 10:43:04 -07:00
committed by GitHub
parent 579d693295
commit 75bb4d018f
+2 -1
View File
@@ -163,6 +163,8 @@ Translator::Result Translator::TranslateFromIp6(Message &aMessage)
ExitNow(result = kDrop);
}
mapping->Touch(ip6Headers.GetIpProto());
#if OPENTHREAD_CONFIG_NAT64_PORT_TRANSLATION_ENABLE
srcPortOrId = mapping->mTranslatedPortOrId;
#else
@@ -502,7 +504,6 @@ Translator::Mapping *Translator::AllocateMapping(const Ip6::Headers &aIp6Headers
mapping->mSrcPortOrId = GetSourcePortOrIcmp6Id(aIp6Headers);
mapping->mTranslatedPortOrId = AllocateSourcePort(mapping->mSrcPortOrId);
#endif
mapping->Touch(aIp6Headers.GetIpProto());
LogInfo("Mapping created: %s", mapping->ToString().AsCString());