Skip to content

fix(vpcnatgw): cannot DNAT same EIP and same external port on two different protocols#6201

Merged
oilbeater merged 1 commit intokubeovn:masterfrom
SkalaNetworks:fix-dnat-dedup
Jan 23, 2026
Merged

fix(vpcnatgw): cannot DNAT same EIP and same external port on two different protocols#6201
oilbeater merged 1 commit intokubeovn:masterfrom
SkalaNetworks:fix-dnat-dedup

Conversation

@SkalaNetworks
Copy link
Copy Markdown
Member

You should be able to DNAT 1.1.1.1:22 TCP and 1.1.1.1:22 UDP on the same EIP, but the check doesn't verify if it is two different protocols.

On Windows, RDP asks to open both the UDP and TCP protocols on the same port. It cannot be done behind an EIP attached to a VPC NAT gateway because of this bug.

…ferent protocols

You should be able to DNAT 1.1.1.1:22 TCP and 1.1.1.1:22 UDP on the same EIP, but the check doesn't check if it is two different protocols. On Windows, RDP asks to open both the UDP and TCP protocols on the same port. It cannot be done behind an EIP attached to a VPC NAT gateway because of this bug.

Signed-off-by: SkalaNetworks <contact@skala.network>
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jan 22, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @SkalaNetworks, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical bug in the VPC NAT gateway's DNAT rule management, where the system incorrectly prevented the creation of rules that shared an EIP and external port if the protocols were different. By extending the DNAT duplication check to include the network protocol, this change ensures that services requiring both TCP and UDP on the same port can now be properly configured, enhancing the flexibility and functionality of the NAT gateway.

Highlights

  • DNAT Rule Duplication Logic: The logic for checking duplicate DNAT rules has been updated to include the network protocol (TCP/UDP). Previously, only the EIP and external port were considered, leading to false positives when different protocols used the same EIP and port.
  • Enhanced Protocol Support: This change now allows for the creation of DNAT rules that share the same EIP and external port, as long as they utilize different protocols. This resolves issues for applications like RDP that require both TCP and UDP on the same port.
  • Controller Updates: The handleAddIptablesDnatRule and handleUpdateIptablesDnatRule functions in the controller have been modified to pass the protocol information to the isDnatDuplicated function, ensuring the new, more accurate duplication check is applied during rule creation and updates.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@dosubot dosubot bot added bug Something isn't working vpc labels Jan 22, 2026
@SkalaNetworks
Copy link
Copy Markdown
Member Author

@oilbeater do you think we can get this backported to 1.15?

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request effectively addresses the bug where DNAT rules were not correctly distinguishing between different protocols (TCP/UDP) on the same EIP and external port. The changes correctly modify the isDnatDuplicated function to include the protocol in its duplication check, and update all call sites and error messages accordingly. The implementation is straightforward and directly resolves the reported issue, ensuring that services requiring both TCP and UDP on the same port can now be configured correctly. The code changes are clear, concise, and maintain the existing code style.

@coveralls
Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 21259886797

Details

  • 0 of 6 (0.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.004%) to 22.885%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/controller/vpc_nat_gw_nat.go 0 6 0.0%
Totals Coverage Status
Change from base Build 21243686376: 0.004%
Covered Lines: 12305
Relevant Lines: 53770

💛 - Coveralls

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jan 23, 2026
@oilbeater oilbeater merged commit bc813ee into kubeovn:master Jan 23, 2026
76 of 77 checks passed
oilbeater pushed a commit that referenced this pull request Jan 23, 2026
…ferent protocols (#6201)

You should be able to DNAT 1.1.1.1:22 TCP and 1.1.1.1:22 UDP on the same EIP, but the check doesn't check if it is two different protocols. On Windows, RDP asks to open both the UDP and TCP protocols on the same port. It cannot be done behind an EIP attached to a VPC NAT gateway because of this bug.

Signed-off-by: SkalaNetworks <contact@skala.network>
(cherry picked from commit bc813ee)
oilbeater pushed a commit that referenced this pull request Jan 23, 2026
…ferent protocols (#6201)

You should be able to DNAT 1.1.1.1:22 TCP and 1.1.1.1:22 UDP on the same EIP, but the check doesn't check if it is two different protocols. On Windows, RDP asks to open both the UDP and TCP protocols on the same port. It cannot be done behind an EIP attached to a VPC NAT gateway because of this bug.

Signed-off-by: SkalaNetworks <contact@skala.network>
zbb88888 pushed a commit to qiniu/kube-ovn that referenced this pull request Jan 26, 2026
…ferent protocols (kubeovn#6201)

You should be able to DNAT 1.1.1.1:22 TCP and 1.1.1.1:22 UDP on the same EIP, but the check doesn't check if it is two different protocols. On Windows, RDP asks to open both the UDP and TCP protocols on the same port. It cannot be done behind an EIP attached to a VPC NAT gateway because of this bug.

Signed-off-by: SkalaNetworks <contact@skala.network>
(cherry picked from commit bc813ee)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files. vpc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants