summaryrefslogtreecommitdiffstats
path: root/test/vpp_ip_route.py
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2018-02-23 05:29:09 -0800
committerDamjan Marion <dmarion.lists@gmail.com>2018-03-09 11:59:58 +0000
commit31ed74407643595fdce206e9d7487108fb8b33ab (patch)
treec22c3703c30b7d457b858fe899f56e57613cbb52 /test/vpp_ip_route.py
parent8f931a47b0fa58d5d33a792062650a42ff8bef70 (diff)
MPLS Unifom mode
- support both pipe and uniform modes for all MPLS LSP - all API programming for output-labels requires that the mode (and associated data) is specificed - API changes in MPLS, BIER and IP are involved - new DPO [sub] types for MPLS labels to handle the two modes. Change-Id: I87b76401e996f10dfbdbe4552ff6b19af958783c Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'test/vpp_ip_route.py')
-rw-r--r--test/vpp_ip_route.py44
1 files changed, 38 insertions, 6 deletions
diff --git a/test/vpp_ip_route.py b/test/vpp_ip_route.py
index 2d34f55efdf..ca0ae1ad47d 100644
--- a/test/vpp_ip_route.py
+++ b/test/vpp_ip_route.py
@@ -38,6 +38,11 @@ class DpoProto:
DPO_PROTO_NSH = 5
+class MplsLspMode:
+ PIPE = 0
+ UNIFORM = 1
+
+
def find_route(test, ip_addr, len, table_id=0, inet=AF_INET):
if inet == AF_INET:
s = 4
@@ -95,6 +100,21 @@ class VppIpTable(VppObject):
self.table_id))
+class VppMplsLabel(object):
+ def __init__(self, value, mode=MplsLspMode.PIPE, ttl=64, exp=0):
+ self.value = value
+ self.mode = mode
+ self.ttl = ttl
+ self.exp = exp
+
+ def encode(self):
+ is_uniform = 0 if self.mode is MplsLspMode.PIPE else 1
+ return {'label': self.value,
+ 'ttl': self.ttl,
+ 'exp': self.exp,
+ 'is_uniform': is_uniform}
+
+
class VppRoutePath(object):
def __init__(
@@ -138,6 +158,16 @@ class VppRoutePath(object):
self.next_hop_id = next_hop_id
self.is_dvr = is_dvr
+ def encode_labels(self):
+ lstack = []
+ for l in self.nh_labels:
+ if type(l) == VppMplsLabel:
+ lstack.append(l.encode())
+ else:
+ lstack.append({'label': l,
+ 'ttl': 255})
+ return lstack
+
class VppMRoutePath(VppRoutePath):
@@ -195,15 +225,16 @@ class VppIpRoute(VppObject):
is_ipv6=self.is_ip6)
else:
for path in self.paths:
+ lstack = path.encode_labels()
+
self._test.vapi.ip_add_del_route(
self.dest_addr,
self.dest_addr_len,
path.nh_addr,
path.nh_itf,
table_id=self.table_id,
- next_hop_out_label_stack=path.nh_labels,
- next_hop_n_out_labels=len(
- path.nh_labels),
+ next_hop_out_label_stack=lstack,
+ next_hop_n_out_labels=len(lstack),
next_hop_via_label=path.nh_via_label,
next_hop_table_id=path.nh_table_id,
next_hop_id=path.next_hop_id,
@@ -513,6 +544,8 @@ class VppMplsRoute(VppObject):
def add_vpp_config(self):
is_multipath = len(self.paths) > 1
for path in self.paths:
+ lstack = path.encode_labels()
+
self._test.vapi.mpls_route_add_del(
self.local_label,
self.eos_bit,
@@ -524,9 +557,8 @@ class VppMplsRoute(VppObject):
table_id=self.table_id,
is_interface_rx=path.is_interface_rx,
is_rpf_id=path.is_rpf_id,
- next_hop_out_label_stack=path.nh_labels,
- next_hop_n_out_labels=len(
- path.nh_labels),
+ next_hop_out_label_stack=lstack,
+ next_hop_n_out_labels=len(lstack),
next_hop_via_label=path.nh_via_label,
next_hop_table_id=path.nh_table_id)
self._test.registry.register(self, self._test.logger)