X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2Ftest_gbp.py;h=cc26238276a70e68155fa48e717718176ac0110b;hb=refs%2Fchanges%2F12%2F20312%2F2;hp=19ca81b9cfe4d1052ccf529fd0f06e6a4752740e;hpb=286921eef8aa07e9edd83078c0a8397d06dc448c;p=vpp.git diff --git a/test/test_gbp.py b/test/test_gbp.py index 19ca81b9cfe..cc26238276a 100644 --- a/test/test_gbp.py +++ b/test/test_gbp.py @@ -17,7 +17,8 @@ from framework import VppTestCase, VppTestRunner from vpp_object import VppObject from vpp_interface import VppInterface from vpp_ip_route import VppIpRoute, VppRoutePath, VppIpTable, \ - VppIpInterfaceAddress, VppIpInterfaceBind, find_route + VppIpInterfaceAddress, VppIpInterfaceBind, find_route, FibPathProto, \ + FibPathType from vpp_l2 import VppBridgeDomain, VppBridgeDomainPort, \ VppBridgeDomainArpEntry, VppL2FibEntry, find_bridge_domain_port, VppL2Vtr from vpp_sub_interface import L2_VTR_OP, VppDot1QSubint @@ -412,10 +413,10 @@ class VppGbpContractNextHop(): class VppGbpContractRule(): - def __init__(self, action, hash_mode, nhs=[]): + def __init__(self, action, hash_mode, nhs=None): self.action = action self.hash_mode = hash_mode - self.nhs = nhs + self.nhs = [] if nhs is None else nhs def encode(self): nhs = [] @@ -429,6 +430,10 @@ class VppGbpContractRule(): 'n_nhs': len(self.nhs), 'nhs': nhs}} + def __repr__(self): + return '' % ( + self.action, self.hash_mode) + class VppGbpContract(VppObject): """ @@ -438,6 +443,10 @@ class VppGbpContract(VppObject): def __init__(self, test, sclass, dclass, acl_index, rules, allowed_ethertypes): self._test = test + if not isinstance(rules, list): + raise ValueError("'rules' must be a list.") + if not isinstance(allowed_ethertypes, list): + raise ValueError("'allowed_ethertypes' must be a list.") self.acl_index = acl_index self.sclass = sclass self.dclass = dclass @@ -451,23 +460,30 @@ class VppGbpContract(VppObject): for r in self.rules: rules.append(r.encode()) r = self._test.vapi.gbp_contract_add_del( - 1, - self.sclass, - self.dclass, - self.acl_index, - rules, - self.allowed_ethertypes) + is_add=1, + contract={ + 'acl_index': self.acl_index, + 'sclass': self.sclass, + 'dclass': self.dclass, + 'n_rules': len(rules), + 'rules': rules, + 'n_ether_types': len(self.allowed_ethertypes), + 'allowed_ethertypes': self.allowed_ethertypes}) self.stats_index = r.stats_index self._test.registry.register(self, self._test.logger) def remove_vpp_config(self): self._test.vapi.gbp_contract_add_del( - 0, - self.sclass, - self.dclass, - self.acl_index, - [], - self.allowed_ethertypes) + is_add=0, + contract={ + 'acl_index': self.acl_index, + 'sclass': self.sclass, + 'dclass': self.dclass, + 'n_rules': 0, + 'rules': [], + 'n_ether_types': len(self.allowed_ethertypes), + 'allowed_ethertypes': self.allowed_ethertypes} + ) def object_id(self): return "gbp-contract:[%d:%s:%d]" % (self.sclass, @@ -555,7 +571,7 @@ class VppGbpAcl(VppObject): def add_vpp_config(self, rules): - reply = self._test.vapi.acl_add_replace(self.acl_index, + reply = self._test.vapi.acl_add_replace(acl_index=self.acl_index, r=rules, tag=b'GBPTest') self.acl_index = reply.acl_index @@ -840,10 +856,10 @@ class TestGBP(VppTestCase): # add the BD ARP termination entry for BVI IP epg.bd_arp_ip4 = VppBridgeDomainArpEntry(self, epg.bd.bd, str(self.router_mac), - epg.bvi_ip4) + epg.bvi_ip4.address) epg.bd_arp_ip6 = VppBridgeDomainArpEntry(self, epg.bd.bd, str(self.router_mac), - epg.bvi_ip6) + epg.bvi_ip6.address) epg.bd_arp_ip4.add_vpp_config() epg.bd_arp_ip6.add_vpp_config() @@ -916,17 +932,18 @@ class TestGBP(VppTestCase): # add the BD ARP termination entry for floating IP for fip in ep.fips: - ba = VppBridgeDomainArpEntry(self, epg_nat.bd.bd, ep.mac, fip) + ba = VppBridgeDomainArpEntry(self, epg_nat.bd.bd, ep.mac, + fip.address) ba.add_vpp_config() # floating IPs route via EPG recirc - r = VppIpRoute(self, fip.address, fip.length, - [VppRoutePath(fip.address, - ep.recirc.recirc.sw_if_index, - is_dvr=1, - proto=fip.dpo_proto)], - table_id=20, - is_ip6=fip.is_ip6) + r = VppIpRoute( + self, fip.address, fip.length, + [VppRoutePath(fip.address, + ep.recirc.recirc.sw_if_index, + type=FibPathType.FIB_PATH_TYPE_DVR, + proto=fip.dpo_proto)], + table_id=20) r.add_vpp_config() # L2 FIB entries in the NAT EPG BD to bridge the packets from @@ -1169,9 +1186,11 @@ class TestGBP(VppTestCase): self, epgs[0].sclass, epgs[1].sclass, acl_index, [VppGbpContractRule( VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT, + VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP, []), VppGbpContractRule( VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT, + VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP, [])], [ETH_P_IP, ETH_P_IPV6]) c1.add_vpp_config() @@ -1189,9 +1208,11 @@ class TestGBP(VppTestCase): self, epgs[1].sclass, epgs[0].sclass, acl_index, [VppGbpContractRule( VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT, + VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP, []), VppGbpContractRule( VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT, + VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP, [])], [ETH_P_IP, ETH_P_IPV6]) c2.add_vpp_config() @@ -1231,9 +1252,11 @@ class TestGBP(VppTestCase): self, epgs[0].sclass, epgs[2].sclass, acl_index, [VppGbpContractRule( VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT, + VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP, []), VppGbpContractRule( VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT, + VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP, [])], [ETH_P_IP, ETH_P_IPV6]) c3.add_vpp_config() @@ -1336,9 +1359,11 @@ class TestGBP(VppTestCase): self, epgs[0].sclass, epgs[3].sclass, acl_index2, [VppGbpContractRule( VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT, + VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP, []), VppGbpContractRule( VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT, + VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP, [])], [ETH_P_IP, ETH_P_IPV6]) c4.add_vpp_config() @@ -1377,9 +1402,11 @@ class TestGBP(VppTestCase): self, epgs[3].sclass, epgs[0].sclass, acl_index2, [VppGbpContractRule( VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT, + VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP, []), VppGbpContractRule( VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT, + VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP, [])], [ETH_P_IP, ETH_P_IPV6]) c5.add_vpp_config() @@ -1894,9 +1921,11 @@ class TestGBP(VppTestCase): self, epg_220.sclass, epg_330.sclass, acl_index, [VppGbpContractRule( VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT, + VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP, []), VppGbpContractRule( VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT, + VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP, [])], [ETH_P_IP, ETH_P_IPV6]) c1.add_vpp_config() @@ -2062,7 +2091,7 @@ class TestGBP(VppTestCase): # add the BD ARP termination entry for BVI IP epg.bd_arp_ip4 = VppBridgeDomainArpEntry(self, epg.bd.bd, str(self.router_mac), - epg.bvi_ip4) + epg.bvi_ip4.address) epg.bd_arp_ip4.add_vpp_config() # EPG in VPP @@ -2115,9 +2144,11 @@ class TestGBP(VppTestCase): self, epgs[0].sclass, epgs[1].sclass, acl_index, [VppGbpContractRule( VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT, + VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP, []), VppGbpContractRule( VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT, + VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP, [])], [ETH_P_IP, ETH_P_IPV6]) c1.add_vpp_config() @@ -2142,9 +2173,11 @@ class TestGBP(VppTestCase): self, epgs[1].sclass, epgs[0].sclass, acl_index, [VppGbpContractRule( VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT, + VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP, []), VppGbpContractRule( VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT, + VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP, [])], [ETH_P_IP, ETH_P_IPV6]) c2.add_vpp_config() @@ -2169,9 +2202,11 @@ class TestGBP(VppTestCase): self, epgs[0].sclass, epgs[2].sclass, acl_index, [VppGbpContractRule( VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT, + VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP, []), VppGbpContractRule( VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT, + VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP, [])], [ETH_P_IP, ETH_P_IPV6]) c3.add_vpp_config() @@ -3331,9 +3366,11 @@ class TestGBP(VppTestCase): self, epg_221.sclass, epg_220.sclass, acl_index, [VppGbpContractRule( VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT, + VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP, []), VppGbpContractRule( VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT, + VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP, [])], [ETH_P_IP, ETH_P_IPV6]) c4.add_vpp_config() @@ -3747,9 +3784,11 @@ class TestGBP(VppTestCase): self, 4220, 4221, acl_index, [VppGbpContractRule( VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT, + VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP, []), VppGbpContractRule( VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT, + VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP, [])], [ETH_P_IP, ETH_P_IPV6]) c1.add_vpp_config() @@ -3761,9 +3800,11 @@ class TestGBP(VppTestCase): self, 4220, 113, acl_index, [VppGbpContractRule( VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT, + VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP, []), VppGbpContractRule( VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT, + VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP, [])], [ETH_P_IP, ETH_P_IPV6]) c2.add_vpp_config() @@ -3771,9 +3812,11 @@ class TestGBP(VppTestCase): self, 113, 4220, acl_index, [VppGbpContractRule( VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT, + VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP, []), VppGbpContractRule( VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT, + VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP, [])], [ETH_P_IP, ETH_P_IPV6]) c3.add_vpp_config() @@ -3903,9 +3946,11 @@ class TestGBP(VppTestCase): self, 4220, 4222, acl_index, [VppGbpContractRule( VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT, + VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP, []), VppGbpContractRule( VppEnum.vl_api_gbp_rule_action_t.GBP_API_RULE_PERMIT, + VppEnum.vl_api_gbp_hash_mode_t.GBP_API_HASH_MODE_SRC_IP, [])], [ETH_P_IP, ETH_P_IPV6]) c4.add_vpp_config()