Skip to content

Fix Static NAT/Port Forwarding when VM NIC is not the default#13200

Open
sudo87 wants to merge 4 commits into
apache:mainfrom
shapeblue:fixStaticnatNondefault
Open

Fix Static NAT/Port Forwarding when VM NIC is not the default#13200
sudo87 wants to merge 4 commits into
apache:mainfrom
shapeblue:fixStaticnatNondefault

Conversation

@sudo87

@sudo87 sudo87 commented May 20, 2026

Copy link
Copy Markdown
Contributor

Description

This PR intends to fix #8366

When CloudStack VR forwards traffic to a VM whose NIC is not the VM's default, the VM may reply via its default NIC (asymmetric routing). To force symmetric routing we SNAT the forwarded packet's source to the VR’s guest IP on the VM subnet so the VM replies on-link back to that VR interface. Also fix the port-forwarding SNAT to pick the correct VR guest IP for the VM's subnet

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

  1. Deploy instance vm1 on network (net_1)
  2. Create Isolated network (iso_2), attach NIC nic_2 from this to vm1
  3. Acquire public_ip from iso_2 and enable static nat to vm1
  4. Configure firewall rules e.g. enable icmp
  5. Ping via public_ip, expect response from instance vm1

How did you try to break this feature and the system with this change?

@codecov

codecov Bot commented May 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 6.45161% with 29 lines in your changes missing coverage. Please review.
✅ Project coverage is 19.64%. Comparing base (75748a5) to head (ba07131).

Files with missing lines Patch % Lines
...a/com/cloud/network/router/CommandSetupHelper.java 0.00% 11 Missing ⚠️
...t/resource/virtualnetwork/model/StaticNatRule.java 0.00% 10 Missing ⚠️
...n/java/com/cloud/agent/api/to/StaticNatRuleTO.java 14.28% 6 Missing ⚠️
...ualnetwork/facade/SetStaticNatRulesConfigItem.java 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #13200      +/-   ##
============================================
- Coverage     19.65%   19.64%   -0.01%     
+ Complexity    19792    19790       -2     
============================================
  Files          6368     6368              
  Lines        575107   575137      +30     
  Branches      70370    70372       +2     
============================================
- Hits         113016   112998      -18     
- Misses       449808   449854      +46     
- Partials      12283    12285       +2     
Flag Coverage Δ
uitests 3.41% <ø> (ø)
unittests 20.92% <6.45%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread systemvm/debian/opt/cloud/bin/configure.py Outdated
@sudo87
sudo87 force-pushed the fixStaticnatNondefault branch from bc506f4 to 4a9d0f4 Compare May 21, 2026 11:54
@sudo87

sudo87 commented May 21, 2026

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@sudo87 a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17959

@sudo87

sudo87 commented May 22, 2026

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@sudo87 a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 17986

@sudo87

sudo87 commented May 22, 2026

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@sudo87 a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17987

@weizhouapache weizhouapache added this to the 4.24.0 milestone Jun 29, 2026
@github-actions

Copy link
Copy Markdown

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

Copilot AI review requested due to automatic review settings July 20, 2026 09:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@sudo87
sudo87 marked this pull request as ready for review July 20, 2026 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Static NAT and Port forwarding do not work if the VM NIC is not default

5 participants