From a099681c56339ebcffd4aea9d2e232db07ed2cc0 Mon Sep 17 00:00:00 2001 From: Shuotian Cheng Date: Wed, 21 Nov 2018 08:41:56 -0800 Subject: [PATCH] [acl_loader]: Fix IP match bug for checking IP version (#387) Add .version to get the version of the IP Signed-off-by: Shu0T1an ChenG --- acl_loader/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/acl_loader/main.py b/acl_loader/main.py index 26e963a3207b..fd8e70832b03 100644 --- a/acl_loader/main.py +++ b/acl_loader/main.py @@ -271,14 +271,14 @@ def convert_ip(self, table_name, rule_idx, rule): if rule.ip.config.source_ip_address: source_ip_address = rule.ip.config.source_ip_address.encode("ascii") - if ipaddr.IPNetwork(source_ip_address) == 4: + if ipaddr.IPNetwork(source_ip_address).version == 4: rule_props["SRC_IP"] = source_ip_address else: rule_props["SRC_IPV6"] = source_ip_address if rule.ip.config.destination_ip_address: destination_ip_address = rule.ip.config.destination_ip_address.encode("ascii") - if ipaddr.IPNetwork(destination_ip_address) == 4: + if ipaddr.IPNetwork(destination_ip_address).version == 4: rule_props["DST_IP"] = destination_ip_address else: rule_props["DST_IPV6"] = destination_ip_address