[nat64] use OwningList to manage active mappings - #11878
Conversation
Library files
|
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors the management of active NAT64 mappings to use an OwningList, which simplifies the code by encapsulating mapping cleanup logic within the Mapping::Free method. This is a great improvement that removes several manual mapping release methods from the Translator class. The changes are well-implemented and align with the goal of simplification. I have one minor suggestion to improve code readability by refactoring a conditional statement to avoid an empty if block.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #11878 +/- ##
==========================================
- Coverage 75.25% 69.44% -5.81%
==========================================
Files 644 644
Lines 98754 102434 +3680
==========================================
- Hits 74313 71134 -3179
- Misses 24441 31300 +6859
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull Request Overview
This change refactors the NAT64 translator to use OwningList for managing active mappings, replacing manual memory management with automatic cleanup. The Mapping struct is enhanced to handle its own resource deallocation through a new Free() method, eliminating the need for multiple release methods in the Translator class.
- Replaces
LinkedList<Mapping>withOwningList<Mapping>for automatic memory management - Adds
Free()method toMappingstruct to encapsulate cleanup logic - Removes redundant release methods (
ReleaseMapping,ReleaseMappings,ReleaseExpiredMappings)
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/core/net/nat64_translator.hpp | Updates class structure to use OwningList, adds Free() method to Mapping, removes manual release methods |
| src/core/net/nat64_translator.cpp | Implements Mapping::Free() method, updates mapping pool initialization, replaces manual cleanup calls with OwningList methods |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
This change updates the management of active NAT64 mappings to use an `OwningList`. To support this, the `Mapping` struct now inherits from `InstanceLocatorInit` and includes a new `Free()` method. This method encapsulates the logic for releasing the associated IPv4 address and the `Mapping` entry back to their corresponding pools. This new design simplifies the `Translator` class by removing the redundant `ReleaseMapping()`, `ReleaseMappings()`, and `ReleaseExpiredMappings()` methods. All mapping cleanup operations are now handled by the `OwningList` class (which invokes `Mapping::Free()` on entries as they are removed).
cec9823 to
b7bcde6
Compare
This change updates the management of active NAT64 mappings to use an
OwningList.To support this, the
Mappingstruct now inherits fromInstanceLocatorInitand includes a newFree()method. This method encapsulates the logic for releasing the associated IPv4 address and theMappingentry back to their corresponding pools.This new design simplifies the
Translatorclass by removing the redundantReleaseMapping(),ReleaseMappings(), andReleaseExpiredMappings()methods. All mapping cleanup operations are now handled by theOwningListclass (which invokesMapping::Free()on entries as they are removed).