Skip to content

Commit b9b7266

Browse files
vishesh92dhslove
authored andcommitted
Fix private gateway acl on static routes (apache#10262)
1 parent 5c4e161 commit b9b7266

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

@@ -567,6 +568,23 @@ def fw_vpcrouter(self):
567568
self.fw.append(["mangle", "front",
568569
"-A PREROUTING -s %s -d %s -m state --state NEW -j MARK --set-xmark %s/0xffffffff" %
569570
(self.cl.get_vpccidr(), self.address['network'], hex(100 + int(self.dev[3:])))])
571+
572+
static_routes = CsStaticRoutes("staticroutes", self.config)
573+
if static_routes:
574+
for item in static_routes.get_bag():
575+
if item == "id":
576+
continue
577+
static_route = static_routes.get_bag()[item]
578+
if static_route['ip_address'] == self.address['public_ip'] and not static_route['revoke']:
579+
self.fw.append(["mangle", "",
580+
"-A PREROUTING -m state --state NEW -i %s -s %s ! -d %s/32 -j ACL_OUTBOUND_%s" %
581+
(self.dev, static_route['network'], static_route['ip_address'], self.dev)])
582+
self.fw.append(["filter", "front", "-A FORWARD -d %s -o %s -j ACL_INBOUND_%s" %
583+
(static_route['network'], self.dev, self.dev)])
584+
self.fw.append(["filter", "front",
585+
"-A FORWARD -d %s -o %s -m state --state RELATED,ESTABLISHED -j ACCEPT" %
586+
(static_route['network'], self.dev)])
587+
570588
if self.address["source_nat"]:
571589
self.fw.append(["nat", "front",
572590
"-A POSTROUTING -o %s -j SNAT --to-source %s" %

0 commit comments

Comments
 (0)