Github user karuturi commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1666#discussion_r78733866 --- Diff: systemvm/patches/debian/config/opt/cloud/bin/configure.py --- @@ -145,40 +145,41 @@ def add_rule(self, cidr): logging.debug("Current ACL IP direction is ==> %s", self.direction) if self.direction == 'egress': self.fw.append(["filter", "", " -A FW_OUTBOUND -j FW_EGRESS_RULES"]) + fwr = " -I FW_EGRESS_RULES" + + #In case we have a default rule (accept all or drop all), we have to evaluate the action again. + if rule['type'] == 'all' and not rule['source_cidr_list']: + fwr = " -A FW_EGRESS_RULES" + # For default egress ALLOW or DENY, the logic is inverted. + # Having default_egress_policy == True, means that the default rule should have ACCEPT, + # otherwise DROP. The rule should be appended, not inserted. + if self.rule['default_egress_policy']: + self.rule['action'] = "ACCEPT" + else: + self.rule['action'] = "DROP" + else: + # For other rules added, if default_egress_policy == True, following rules should be DROP, + # otherwise ACCEPT + if self.rule['default_egress_policy']: + self.rule['action'] = "DROP" + else: + self.rule['action'] = "ACCEPT" + if rule['protocol'] == "icmp": self.fw.append(["filter", "front", " -A FW_EGRESS_RULES" + " -s %s " % cidr + " -p %s " % rule['protocol'] + " -m %s " % rule['protocol'] + " --icmp-type %s -j %s" % (icmp_type, self.rule['action'])]) - else: - fwr = " -I FW_EGRESS_RULES" - #In case we have a default rule (accept all or drop all), we have to evaluate the action again. - if rule['type'] == 'all' and not rule['source_cidr_list']: - fwr = " -A FW_EGRESS_RULES" - # For default egress ALLOW or DENY, the logic is inverted. - # Having default_egress_policy == True, means that the default rule should have ACCEPT, - # otherwise DROP. The rule should be appended, not inserted. - if self.rule['default_egress_policy']: - self.rule['action'] = "ACCEPT" - else: - self.rule['action'] = "DROP" - else: - # For other rules added, if default_egress_policy == True, following rules should be DROP, - # otherwise ACCEPT - if self.rule['default_egress_policy']: - self.rule['action'] = "DROP" - else: - self.rule['action'] = "ACCEPT" - - if rule['protocol'] != "all": - fwr += " -s %s " % cidr + \ - " -p %s " % rule['protocol'] + \ - " -m %s " % rule['protocol'] + \ - " --dport %s" % rnge - - self.fw.append(["filter", "", "%s -j %s" % (fwr, rule['action'])]) + + if rule['protocol'] != "all": + fwr += " -s %s " % cidr + \ + " -p %s " % rule['protocol'] + \ + " -m %s " % rule['protocol'] + \ + " --dport %s" % rnge + + self.fw.append(["filter", "", "%s -j %s" % (fwr, rule['action'])]) --- End diff -- Incase of icmp, there will be two iptable rules. Its calling self.fw.append once in if(protocol)==icmp and another time outside. This line should be part of if(protocol != all and protocol != icmp)
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---