diff options
Diffstat (limited to 'test/vpp_bier.py')
-rw-r--r-- | test/vpp_bier.py | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/test/vpp_bier.py b/test/vpp_bier.py index ef9a9ab75ec..7566b1f95ab 100644 --- a/test/vpp_bier.py +++ b/test/vpp_bier.py @@ -4,7 +4,7 @@ import socket from vpp_object import VppObject -from vpp_ip_route import MPLS_LABEL_INVALID, VppRoutePath +from vpp_ip_route import MPLS_LABEL_INVALID, VppRoutePath, VppMplsLabel class BIER_HDR_PAYLOAD: @@ -120,11 +120,34 @@ class VppBierRoute(VppObject): self.bp = bp 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': 0, + '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 + def add_vpp_config(self): self._test.vapi.bier_route_add_del( self.tbl_id, self.bp, - self.paths, + self.encode_paths(), is_add=1) self._test.registry.register(self, self._test.logger) @@ -132,7 +155,7 @@ class VppBierRoute(VppObject): self._test.vapi.bier_route_add_del( self.tbl_id, self.bp, - self.paths, + self.encode_paths(), is_add=0) def __str__(self): |