mirror of
https://github.com/fosrl/newt.git
synced 2026-05-06 16:09:02 -05:00
[PR #205] [MERGED] perf(netstack2): optimize reverse NAT lookup with O(1) map #973
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/fosrl/newt/pull/205
Author: @LaurenceJJones
Created: 12/16/2025
Status: ✅ Merged
Merged: 3/3/2026
Merged by: @oschwartz10612
Base:
dev← Head:optimize-reverse-nat-lookup📝 Commits (2)
1cf75b0perf: optimize reverse NAT lookup with O(1) map instead of O(n) iteration5977667Merge branch 'fosrl:main' into optimize-reverse-nat-lookup📊 Changes
1 file changed (+43 additions, -15 deletions)
View changed files
📝
netstack2/proxy.go(+43 -15)📄 Description
Community Contribution License Agreement
By creating this pull request, I grant the project maintainers an unlimited,
perpetual license to use, modify, and redistribute these contributions under any terms they
choose, including both the AGPLv3 and the Fossorial Commercial license terms. I
represent that I have the right to grant this license for all contributed content.
Description
Replace O(n) linear search through NAT table with O(1) reverse lookup map for reply packet NAT translation.
Changes:
Performance:
This addresses Critical from performance analysis where reply path was walking the entire NAT table to find original mapping.
How to test?
Purely internal optimization, instead of walking the entire natTable every time to find where to reverse too. We create a map that is indexed by the reverse fields which stores the same netState data from the forward natTable.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.