From dcc798d7aa30b446cf8c8cb9c6a749de510d8218 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Thu, 21 Nov 2019 06:59:22 +0100 Subject: [PATCH] vpc: fix acl rule with protocol number is not applied correctly in vpc vr (#3678) When add a acl rule with protocol number, the iptables rules in vpc vr is not applied correctly. for example, when add an ingress acl rule (protocol number:50, cidr: 2.2.2.2/32), we expect to have a iptables rule: "-A ACL_INBOUND_eth2 -s 2.2.2.2/32 -p esp -j ACCEPT" the actual rule is "-A ACL_INBOUND_eth2 -j DROP" It is because the rules in json are not correct. network_acl.json.a8c52dca-0278-4e1c-b72b-987ca7121f4f.gz:{"device":"eth2","mac_address":"02:00:7d:27:00:02","private_gateway_acl":false,"nic_ip":"192.168.11.12","nic_netmask":"28","ingress_rules":[{"type":"protocol","protocol":50,"cidr":"ACCEPT","allowed":false},{"type":"all","cidr":"0.0.0.0/0","allowed":true},],"egress_rules":[],"type":"networkacl"} Fixes: #3602 --- .../virtualnetwork/facade/SetNetworkAclConfigItem.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/cloud/agent/resource/virtualnetwork/facade/SetNetworkAclConfigItem.java b/core/src/main/java/com/cloud/agent/resource/virtualnetwork/facade/SetNetworkAclConfigItem.java index 7247766e5c6..c16e9265a49 100644 --- a/core/src/main/java/com/cloud/agent/resource/virtualnetwork/facade/SetNetworkAclConfigItem.java +++ b/core/src/main/java/com/cloud/agent/resource/virtualnetwork/facade/SetNetworkAclConfigItem.java @@ -79,7 +79,7 @@ public class SetNetworkAclConfigItem extends AbstractConfigItemFacade { // If we check the size of the array, it will fail to setup the network. // So, let's catch the exception and continue in the loop. try { - aclRule = new ProtocolAclRule(ruleParts[5], false, Integer.parseInt(ruleParts[1])); + aclRule = new ProtocolAclRule(ruleParts[4], "ACCEPT".equals(ruleParts[5]), Integer.parseInt(ruleParts[1])); } catch (final Exception e) { s_logger.warn("Problem occured when reading the entries in the ruleParts array. Actual array size is '" + ruleParts.length + "', but trying to read from index 5."); continue; @@ -104,4 +104,4 @@ public class SetNetworkAclConfigItem extends AbstractConfigItemFacade { return super.generateConfigItems(configuration); } -} \ No newline at end of file +}