diff options
Diffstat (limited to 'test/test_abf.py')
-rw-r--r-- | test/test_abf.py | 41 |
1 files changed, 9 insertions, 32 deletions
diff --git a/test/test_abf.py b/test/test_abf.py index 350af0dce07..221a793fed3 100644 --- a/test/test_abf.py +++ b/test/test_abf.py @@ -5,7 +5,8 @@ import unittest from framework import VppTestCase, VppTestRunner from vpp_ip import DpoProto -from vpp_ip_route import VppIpRoute, VppRoutePath, VppMplsLabel, VppIpTable +from vpp_ip_route import VppIpRoute, VppRoutePath, VppMplsLabel, \ + VppIpTable, FibPathProto from scapy.packet import Raw from scapy.layers.l2 import Ether @@ -45,30 +46,9 @@ class VppAbfPolicy(VppObject): self.policy_id = policy_id self.acl = acl self.paths = paths - - def encode_paths(self): - br_paths = [] - for p in self.paths: - lstack = [] - for l in p.nh_labels: - if type(l) == VppMplsLabel: - lstack.append(l.encode()) - else: - lstack.append({'label': l, 'ttl': 255}) - n_labels = len(lstack) - while (len(lstack) < 16): - lstack.append({}) - br_paths.append({'next_hop': p.nh_addr, - 'weight': 1, - 'afi': p.proto, - 'sw_if_index': 0xffffffff, - 'preference': 0, - 'table_id': p.nh_table_id, - 'next_hop_id': p.next_hop_id, - 'is_udp_encap': p.is_udp_encap, - 'n_labels': n_labels, - 'label_stack': lstack}) - return br_paths + self.encoded_paths = [] + for path in self.paths: + self.encoded_paths.append(path.encode()) def add_vpp_config(self): self._test.vapi.abf_policy_add_del( @@ -76,7 +56,7 @@ class VppAbfPolicy(VppObject): {'policy_id': self.policy_id, 'acl_index': self.acl.acl_index, 'n_paths': len(self.paths), - 'paths': self.encode_paths()}) + 'paths': self.encoded_paths}) self._test.registry.register(self, self._test.logger) def remove_vpp_config(self): @@ -85,7 +65,7 @@ class VppAbfPolicy(VppObject): {'policy_id': self.policy_id, 'acl_index': self.acl.acl_index, 'n_paths': len(self.paths), - 'paths': self.encode_paths()}) + 'paths': self.encoded_paths}) def query_vpp_config(self): return find_abf_policy(self._test, self.policy_id) @@ -324,8 +304,7 @@ class TestAbf(VppTestCase): # abf_1 = VppAbfPolicy(self, 10, acl_1, [VppRoutePath("3001::1", - 0xffffffff, - proto=DpoProto.DPO_PROTO_IP6)]) + 0xffffffff)]) abf_1.add_vpp_config() attach_1 = VppAbfAttach(self, 10, self.pg0.sw_if_index, @@ -352,9 +331,7 @@ class TestAbf(VppTestCase): # route = VppIpRoute(self, "3001::1", 32, [VppRoutePath(self.pg1.remote_ip6, - self.pg1.sw_if_index, - proto=DpoProto.DPO_PROTO_IP6)], - is_ip6=1) + self.pg1.sw_if_index)]) route.add_vpp_config() # |