From 5ddcb44a96abd7aa0fc89d2760f05cd8abeb3ca5 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Wed, 8 Jan 2025 21:00:09 -0800 Subject: [PATCH] [nat64-translator] ensure expired mappings are released in timer callback (#11139) This commit fixes the release of expired mappings by ensuring that `ReleaseExpiredMappings()` is always called from the timer callback `HandleMappingExpirerTimer()`, regardless of the logging level. Previously, `ReleaseExpiredMappings()` was called as an input to `LogInfo()`, which could become an empty macro (ignoring its input) if info-level logs were disabled. --- src/core/net/nat64_translator.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/core/net/nat64_translator.cpp b/src/core/net/nat64_translator.cpp index e46656a01..7b56886bc 100644 --- a/src/core/net/nat64_translator.cpp +++ b/src/core/net/nat64_translator.cpp @@ -552,8 +552,13 @@ exit: void Translator::HandleMappingExpirerTimer(void) { - LogInfo("Released %d expired mappings", ReleaseExpiredMappings()); + uint16_t numReleased = ReleaseExpiredMappings(); + + LogInfo("Released %u expired mappings", numReleased); + mMappingExpirerTimer.Start(kAddressMappingIdleTimeoutMsec); + + OT_UNUSED_VARIABLE(numReleased); } void Translator::InitAddressMappingIterator(AddressMappingIterator &aIterator)