cloudstack/systemvm/debian/opt/cloud/bin/cs
Brad House - Nexthop 83f705ddc5
Static Routes with nexthop non-functional for private gateways (#12859)
* Fix static routes to be added to PBR tables in VPC routers

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 #12857

* Add iptables FORWARD rules for nexthop-based static routes

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 #12857

* network matching grep fix, don't let 1.2.3.4/32 match 11.2.3.4/32
2026-04-16 16:15:43 +05:30
..
CsAddress.py Static Routes with nexthop non-functional for private gateways (#12859) 2026-04-16 16:15:43 +05:30
CsApp.py Upgrade to JRE17 and Upgrade System VMs/VRs to Python3 and Debian 12 (#8497) 2024-02-26 18:07:50 +05:30
CsBgpPeers.py feature: Dynamic and Static Routing (#9470) 2024-09-06 08:55:17 +05:30
CsConfig.py Netris Network Plugin Integration with CloudStack (#10458) 2025-07-25 15:26:42 +05:30
CsDatabag.py Netris Network Plugin Integration with CloudStack (#10458) 2025-07-25 15:26:42 +05:30
CsDhcp.py VR: fix dns list in redundant VPC VRs (#12161) 2026-01-28 13:09:10 +01:00
CsFile.py Merge branch '4.19' 2024-11-07 11:33:50 +01:00
CsGuestNetwork.py Netris Network Plugin Integration with CloudStack (#10458) 2025-07-25 15:26:42 +05:30
CsHelper.py Static Routes with nexthop non-functional for private gateways (#12859) 2026-04-16 16:15:43 +05:30
CsLoadBalancer.py Improvement: SSL offloading with Virtual Router (#11468) 2025-09-11 16:37:18 +05:30
CsMonitor.py Upgrade to JRE17 and Upgrade System VMs/VRs to Python3 and Debian 12 (#8497) 2024-02-26 18:07:50 +05:30
CsNetfilter.py IPv6 firewall: accept packets from related and established connections (#10970) 2025-09-10 16:37:17 +02:00
CsProcess.py Upgrade to JRE17 and Upgrade System VMs/VRs to Python3 and Debian 12 (#8497) 2024-02-26 18:07:50 +05:30
CsRedundant.py Upgrade to JRE17 and Upgrade System VMs/VRs to Python3 and Debian 12 (#8497) 2024-02-26 18:07:50 +05:30
CsRoute.py Merge branch '4.20' into 4.22 2025-12-22 13:23:37 +01:00
CsRule.py Upgrade to JRE17 and Upgrade System VMs/VRs to Python3 and Debian 12 (#8497) 2024-02-26 18:07:50 +05:30
CsStaticRoutes.py Static Routes with nexthop non-functional for private gateways (#12859) 2026-04-16 16:15:43 +05:30
CsVpcGuestNetwork.py Netris Network Plugin Integration with CloudStack (#10458) 2025-07-25 15:26:42 +05:30
__init__.py VR: fix logging is not working and logs are not appended to /var/log/cloud.log (#4466) 2020-11-20 10:40:02 +00:00