Skip to content

Commit ae1d7cc

Browse files
authored
Fix private gateway acl on static routes (#10262)
1 parent aa6c581 commit ae1d7cc

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

systemvm/debian/opt/cloud/bin/cs/CsAddress.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from CsApp import CsApache, CsDnsmasq, CsPasswdSvc
2525
from CsRoute import CsRoute
2626
from CsRule import CsRule
27+
from CsStaticRoutes import CsStaticRoutes
2728

2829
VRRP_TYPES = ['guest']
2930

@@ -553,6 +554,23 @@ def fw_vpcrouter(self):
553554
self.fw.append(["mangle", "front",
554555
"-A PREROUTING -s %s -d %s -m state --state NEW -j MARK --set-xmark %s/0xffffffff" %
555556
(self.cl.get_vpccidr(), self.address['network'], hex(100 + int(self.dev[3:])))])
557+
558+
static_routes = CsStaticRoutes("staticroutes", self.config)
559+
if static_routes:
560+
for item in static_routes.get_bag():
561+
if item == "id":
562+
continue
563+
static_route = static_routes.get_bag()[item]
564+
if static_route['ip_address'] == self.address['public_ip'] and not static_route['revoke']:
565+
self.fw.append(["mangle", "",
566+
"-A PREROUTING -m state --state NEW -i %s -s %s ! -d %s/32 -j ACL_OUTBOUND_%s" %
567+
(self.dev, static_route['network'], static_route['ip_address'], self.dev)])
568+
self.fw.append(["filter", "front", "-A FORWARD -d %s -o %s -j ACL_INBOUND_%s" %
569+
(static_route['network'], self.dev, self.dev)])
570+
self.fw.append(["filter", "front",
571+
"-A FORWARD -d %s -o %s -m state --state RELATED,ESTABLISHED -j ACCEPT" %
572+
(static_route['network'], self.dev)])
573+
556574
if self.address["source_nat"]:
557575
self.fw.append(["nat", "front",
558576
"-A POSTROUTING -o %s -j SNAT --to-source %s" %

0 commit comments

Comments
 (0)