Skip to content

Commit 9186de7

Browse files
committed
Fix private gateway acl on static routes
1 parent 2aa2e92 commit 9186de7

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

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

Lines changed: 15 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

@@ -551,6 +552,20 @@ def fw_vpcrouter(self):
551552
self.fw.append(["mangle", "front",
552553
"-A PREROUTING -s %s -d %s -m state --state NEW -j MARK --set-xmark %s/0xffffffff" %
553554
(self.cl.get_vpccidr(), self.address['network'], hex(100 + int(self.dev[3:])))])
555+
556+
static_routes = CsStaticRoutes("staticroutes", self.config)
557+
if static_routes:
558+
for item in static_routes.get_bag():
559+
if item == "id":
560+
continue
561+
static_route = static_routes.get_bag()[item]
562+
if static_route['ip_address'] == self.address['public_ip'] and not static_route['revoke']:
563+
self.fw.append(["mangle", "",
564+
"-A PREROUTING -m state --state NEW -i %s -s %s ! -d %s -j ACL_OUTBOUND_%s" %
565+
(self.dev, self.address['network'], static_route['network'], self.dev)])
566+
self.fw.append(["filter", "", "-A FORWARD -d %s -o %s -j ACL_INBOUND_%s" %
567+
(static_route['network'], self.dev, self.dev)])
568+
554569
if self.address["source_nat"]:
555570
self.fw.append(["nat", "front",
556571
"-A POSTROUTING -o %s -j SNAT --to-source %s" %

0 commit comments

Comments
 (0)