Static Routes with nexthop non-functional for private gateways#12859
Static Routes with nexthop non-functional for private gateways#12859bhouse-nexthop wants to merge 2 commits intoapache:4.22from
Conversation
|
Congratulations on your first Pull Request and welcome to the Apache CloudStack community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md)
|
f51b1ab to
1141a7a
Compare
Static routes were only being added to the main routing table, but policy-based routing (PBR) is active on VPC routers. This caused traffic coming in from specific interfaces to not find the static routes, as they use interface-specific routing tables (Table_ethX). This fix: - Adds a helper method to find which interface a gateway belongs to by matching the gateway IP against configured interface subnets - Modifies route add/delete operations to update both the main table and the appropriate interface-specific PBR table - Uses existing CsAddress databag metadata to avoid OS queries - Handles both add and revoke operations for proper cleanup - Adds comprehensive logging for troubleshooting Fixes apache#12857
1141a7a to
8a60b80
Compare
4dc4ac3 to
e102b98
Compare
|
@weizhouapache can you approve the workflow runs and review this. I've just confirmed this fixes both of my issues. |
e102b98 to
16228ff
Compare
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
16228ff to
556ae05
Compare
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
copilot issues, eh? |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 4.22 #12859 +/- ##
============================================
- Coverage 17.61% 17.60% -0.01%
+ Complexity 15661 15658 -3
============================================
Files 5917 5917
Lines 531430 531430
Branches 64973 64973
============================================
- Hits 93586 93566 -20
- Misses 427288 427309 +21
+ Partials 10556 10555 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
guess there are... |
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
When static routes use nexthop (gateway) instead of referencing a private gateway's public IP, the iptables FORWARD rules were not being generated. This caused traffic to be dropped by ACLs. This fix: - Adds a shared helper CsHelper.find_device_for_gateway() to determine which interface a gateway belongs to by checking subnet membership - Updates CsStaticRoutes to use the shared helper instead of duplicating the device-finding logic - Modifies CsAddress firewall rule generation to handle both old-style (ip_address-based) and new-style (nexthop-based) static routes - Generates the required FORWARD and PREROUTING rules for nexthop routes: * -A PREROUTING -s <network> ! -d <interface_ip>/32 -i <dev> -j ACL_OUTBOUND_<dev> * -A FORWARD -d <network> -o <dev> -j ACL_INBOUND_<dev> * -A FORWARD -d <network> -o <dev> -m state --state RELATED,ESTABLISHED -j ACCEPT Fixes the second part of apache#12857
556ae05 to
4b27656
Compare
|
for some reason I thought only the forward was needed, but without the prerouting rule as well it doesn't enforce all the ACLs. I fixed the PR and force-pushed. I'm actually running this patch in production now. |
|
@DaanHoogland @weizhouapache can you please review. I've been running it in production with 3 vpc interconnected with private gateways. We also have a weird scenario where we attached 2 L2 networks to a VM that uses a standard network tier acting as a specialized router, and the static routes are working for that as well (previously the ACLs weren't applying for this special case and it was more open than it should have been). |
Description
Static routes were only being added to the main routing table, but policy-based routing (PBR) is active on VPC routers. This caused traffic coming in from specific interfaces to not find the static routes, as they use interface-specific routing tables (Table_ethX).
This fix:
Fixes #12857
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
See #12857 for the tested scenario
How did you try to break this feature and the system with this change?