Skip to content

Commit 12f526b

Browse files
voloshanenkoyadvr
authored andcommitted
CLOUDSTACK-10200: Fix ACL_INBOUND/OUTBOUND rules for PrivateGateway (#2367)
We found bug in ACL rules for PrivateGateway for VPC At a glance - rules not applied - switching Allow All or Deny All (default ACL) - showed as completed - but rules missed. Result - traffic via PrivateGateway blocked by next DROP rule in next chains How to reproduce: Enable PrivateGateway for Cloudstack Create VPC Provision new PrivateGateway inside VPC with some VLAN Change ACL (optional step to show that problem not in initial configuration but in config itself) Expected: ACL rules applied (inserted) into correspondig ACL_INBOUND/OUTBOUND chanins for PrivateGateway interface (ethX) based on ACL which user choose Current: No rules inserted. ACL_INBOUND/OUTBOUND_ethX - empty. Traffic blocked by next DROP rule in FORWARD chain Affect - all our corporate customers blocked with access to their own nets via PG and vice-versa. Root cause: Issue happened because of CsNetFilter.py logic for inserting rules for ACL_INBOUND/OUTBOUND chains. We choose rule numebr to isnert right before last DROP rule - but forget about fact - that if chain empty - we also return 0 as insert position. Which not true for iptables - numeration started from 0. So we need very small patch to handle this special case - if number of rules inside chain equal to zero - return 1, else - return count of rules inside chain. It's found only one - just because be default for PrivateGateway - we didn't insert any "service rules" (if SourceNat for PrivateGteway not ticked) - and we have by default empty ACL_INBOUND/OUTBOUND chains. Because same insert happened for all VPC networks (but when we call this insert - we already have at least 1 rule inside chains - and we successfully can process)
1 parent 0e3ddb2 commit 12f526b

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

systemvm/patches/debian/config/opt/cloud/bin/cs/CsNetfilter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def compare(self, list):
168168
if isinstance(fw[1], int):
169169
# if the rule is for ACLs, we want to insert them in order, right before the DROP all
170170
if rule_chain.startswith("ACL_INBOUND") or rule_chain.startswith("ACL_OUTBOUND"):
171-
rule_count = self.chain.get_count(rule_chain)
171+
rule_count = self.chain.get_count(rule_chain) if self.chain.get_count(rule_chain) > 0 else 1
172172
cpy = cpy.replace("-A %s" % new_rule.get_chain(), '-I %s %s' % (new_rule.get_chain(), rule_count))
173173
else:
174174
cpy = cpy.replace("-A %s" % new_rule.get_chain(), '-I %s %s' % (new_rule.get_chain(), fw[1]))

0 commit comments

Comments
 (0)