diff options
author | Neale Ranns <nranns@cisco.com> | 2018-12-20 03:01:49 -0800 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2018-12-20 15:00:30 +0000 |
commit | 775f73c6baaf9bc2283e7ab9752c81984823be99 (patch) | |
tree | 7c2496d34a590fae15f917f9e51867fa14aafec5 /test/vpp_ip_route.py | |
parent | a3aaa61e2f2fd81f9653cb678b38519e96e6c6cd (diff) |
FIB: encode the label stack in the FIB path during table dump
Change-Id: I28e8a99b980ad343a4209e673201791b91ceab4e
Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'test/vpp_ip_route.py')
-rw-r--r-- | test/vpp_ip_route.py | 60 |
1 files changed, 52 insertions, 8 deletions
diff --git a/test/vpp_ip_route.py b/test/vpp_ip_route.py index 45609e80786..5a6598eb012 100644 --- a/test/vpp_ip_route.py +++ b/test/vpp_ip_route.py @@ -78,6 +78,24 @@ def find_mroute(test, grp_addr, src_addr, grp_addr_len, return False +def find_mpls_route(test, table_id, label, eos_bit, paths=None): + dump = test.vapi.mpls_fib_dump() + for e in dump: + if label == e.label \ + and eos_bit == e.eos_bit \ + and table_id == e.table_id: + if not paths: + return True + else: + if (len(paths) != len(e.path)): + return False + for i in range(len(paths)): + if (paths[i] != e.path[i]): + return False + return True + return False + + def fib_interface_ip_prefix(test, address, length, sw_if_index): vp = VppIpPrefix(address, length) addrs = test.vapi.ip_address_dump(sw_if_index, is_ipv6=vp.is_ip6) @@ -225,6 +243,23 @@ class VppMplsLabel(object): 'exp': self.exp, 'is_uniform': is_uniform} + def __eq__(self, other): + if isinstance(other, self.__class__): + return (self.value == other.value and + self.ttl == other.ttl and + self.exp == other.exp and + self.mode == other.mode) + elif hasattr(other, 'label'): + return (self.value == other.label and + self.ttl == other.ttl and + self.exp == other.exp and + (self.mode == MplsLspMode.UNIFORM) == other.is_uniform) + else: + return False + + def __ne__(self, other): + return not (self == other) + class VppRoutePath(object): @@ -293,7 +328,21 @@ class VppRoutePath(object): 'label_stack': self.encode_labels()} def __eq__(self, other): - return self.nh_addr == other.nh_addr + if isinstance(other, self.__class__): + return self.nh_addr == other.nh_addr + elif hasattr(other, 'sw_if_index'): + # vl_api_fib_path_t + if (len(self.nh_labels) != other.n_labels): + return False + for i in range(len(self.nh_labels)): + if (self.nh_labels[i] != other.label_stack[i]): + return False + return self.nh_itf == other.sw_if_index + else: + return False + + def __ne__(self, other): + return not (self == other) class VppMRoutePath(VppRoutePath): @@ -725,13 +774,8 @@ class VppMplsRoute(VppObject): is_add=0) def query_vpp_config(self): - dump = self._test.vapi.mpls_fib_dump() - for e in dump: - if self.local_label == e.label \ - and self.eos_bit == e.eos_bit \ - and self.table_id == e.table_id: - return True - return False + return find_mpls_route(self._test, self.table_id, + self.local_label, self.eos_bit) def __str__(self): return self.object_id() |