Skip to content

Conversation

@PlagueCZ
Copy link
Contributor

Addressed rollback problems as per issue.

Hopefully I did not misunderstand the code flow, please verify.

Fixes #699

@PlagueCZ PlagueCZ requested a review from a team as a code owner July 18, 2025 23:01
@github-actions github-actions bot added size/S bug Something isn't working labels Jul 18, 2025
@PlagueCZ
Copy link
Contributor Author

The second commit is an addition as it occurred to me that having the INC macro used in snat_node.c while the DEC macro used in dp_nat.c is asking for trouble, so I moved them to be in one place (inside NAT functions themselves).

@github-actions github-actions bot added size/M and removed size/S labels Jul 21, 2025
@byteocean
Copy link
Contributor

Thanks for spotting this potential leak. I was able to understand the first two commits, but couldn't relate the third commit "Fix edge-case in SNAT deletion" with the wording in the issue description, as it seems to be a code reorg, which looks better for sure. Could you help to elaborate more or point to the relevant description in the issue?

@PlagueCZ
Copy link
Contributor Author

Thanks for spotting this potential leak. I was able to understand the first two commits, but couldn't relate the third commit "Fix edge-case in SNAT deletion" with the wording in the issue description, as it seems to be a code reorg, which looks better for sure. Could you help to elaborate more or point to the relevant description in the issue?

I edited the issue. The problem was that there was a quick-return but that jumped over the code at the end with DP_STATS_NAT_DEC_USED_PORT_CNT().

This would become a bigger issue in the followup PRs as I will be adding more to the "finishing" part of this function

@PlagueCZ PlagueCZ force-pushed the fix/snat_rollback branch from 5f514e3 to c52b306 Compare July 22, 2025 13:43
Copy link
Contributor

@byteocean byteocean left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved as communicated

@guvenc guvenc moved this to In Progress in Networking Jul 23, 2025
@guvenc guvenc removed this from Networking Jul 23, 2025
DPS_LOG_ERR("Cannot lookup portmap key", DP_LOG_RET(ret));
if (ret != -ENOENT)
return ret;
// otherwise already deleted, finish
Copy link
Collaborator

@guvenc guvenc Jul 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that this control flow fall through is intentional now so that it can hit the INC macro at the end but this would also cause the new code to hit the lines below for ret == ENOENT case.

created_port = dp_get_port_by_id(cntrack->created_port_id);
if (!created_port)
return DP_ERROR;

Was this intentional ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. This is the commit that "fixes SNAT edge case" because previously it could have found a portmap entry (and immediately deleted it), but not found portoverload entry and then return without actually decreasing the counter.

@guvenc guvenc merged commit c52b306 into main Jul 24, 2025
6 checks passed
@guvenc guvenc deleted the fix/snat_rollback branch July 24, 2025 11:17
@github-project-automation github-project-automation bot moved this to Done in Roadmap Jul 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/networking bug Something isn't working size/M

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Improper rollback in ipv4/nat64 snat

5 participants