mirror of
https://github.com/espressif/openthread.git
synced 2026-08-13 14:17:47 +00:00
[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:
@@ -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());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user