X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2Ftest_acl_plugin.py;h=f3ab38127166273f38c3da2e17ae429253637cd3;hb=29d22c52061df519c22b1bb58afe461d107899e2;hp=5fcf09c5ee75b3b915d558196397f43c81f20c18;hpb=c43b3f986476ffb4506b7115898e809a6e34f601;p=vpp.git diff --git a/test/test_acl_plugin.py b/test/test_acl_plugin.py index 5fcf09c5ee7..f3ab3812716 100644 --- a/test/test_acl_plugin.py +++ b/test/test_acl_plugin.py @@ -13,6 +13,8 @@ from scapy.layers.inet6 import IPv6ExtHdrFragment from framework import VppTestCase, VppTestRunner from util import Host, ppp +from vpp_lo_interface import VppLoInterface + class TestACLplugin(VppTestCase): """ ACL plugin Test Case """ @@ -247,6 +249,17 @@ class TestACLplugin(VppTestCase): acls=[reply.acl_index]) return + def apply_rules_to(self, rules, tag='', sw_if_index=0xFFFFFFFF): + reply = self.vapi.acl_add_replace(acl_index=4294967295, r=rules, + tag=tag) + self.logger.info("Dumped ACL: " + str( + self.vapi.acl_dump(reply.acl_index))) + # Apply a ACL on the interface as inbound + self.vapi.acl_interface_set_acl_list(sw_if_index=sw_if_index, + n_input=1, + acls=[reply.acl_index]) + return + def etype_whitelist(self, whitelist, n_input): # Apply whitelists on all the interfaces for i in self.pg_interfaces: @@ -1080,7 +1093,8 @@ class TestACLplugin(VppTestCase): self.logger.info("ACLP_TEST_FINISH_0020") def test_0021_udp_deny_port_verify_fragment_deny(self): - """ deny single UDPv4/v6, permit ip any, verify non-initial fragment blocked + """ deny single UDPv4/v6, permit ip any, verify non-initial fragment + blocked """ self.logger.info("ACLP_TEST_START_0021") @@ -1393,5 +1407,31 @@ class TestACLplugin(VppTestCase): self.logger.info("ACLP_TEST_FINISH_0305") + def test_0315_del_intf(self): + """ apply an acl and delete the interface + """ + self.logger.info("ACLP_TEST_START_0315") + + # Add an ACL + rules = [] + rules.append(self.create_rule(self.IPV4, self.DENY, self.PORTS_RANGE_2, + self.proto[self.IP][self.TCP])) + rules.append(self.create_rule(self.IPV4, self.PERMIT, self.PORTS_RANGE, + self.proto[self.IP][self.TCP])) + # deny ip any any in the end + rules.append(self.create_rule(self.IPV4, self.DENY, self.PORTS_ALL, 0)) + + # create an interface + intf = [] + intf.append(VppLoInterface(self)) + + # Apply rules + self.apply_rules_to(rules, "permit ipv4 tcp", intf[0].sw_if_index) + + # Remove the interface + intf[0].remove_vpp_config() + + self.logger.info("ACLP_TEST_FINISH_0315") + if __name__ == '__main__': unittest.main(testRunner=VppTestRunner)