diff options
author | Neale Ranns <nranns@cisco.com> | 2016-11-02 14:20:04 +0000 |
---|---|---|
committer | Damjan Marion <dmarion.lists@gmail.com> | 2016-12-02 11:09:36 +0000 |
commit | ad422ed7eaafe993d5b530395cb11a708f2ed922 (patch) | |
tree | 6122391863894f619d13037581f8365ca3796f8f /test/vpp_ip_route.py | |
parent | caffe0980adc852e6f6afaa2723bd5dd14658de3 (diff) |
MPLS infrastructure improvments
- deprecate MPLSoEth and MPLSoGRE; replace with generic MPLS tunnel.
- deprecates CLI 'mpls encap ..'; replace with addition of MPLS out label to a route/tunnel.
- support for MPLS 'routes', e.g. MPLS x-connects.
- deprecates CLI 'mpls decap ..'; replace with 'mpls route .. '
Change-Id: Ibda46544912f880d0200f22bf9ff9b52828fcc2f
Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'test/vpp_ip_route.py')
-rw-r--r-- | test/vpp_ip_route.py | 75 |
1 files changed, 72 insertions, 3 deletions
diff --git a/test/vpp_ip_route.py b/test/vpp_ip_route.py index 78e6aaa23b9..1dc8c1abb0f 100644 --- a/test/vpp_ip_route.py +++ b/test/vpp_ip_route.py @@ -6,13 +6,19 @@ import socket +# from vnet/vnet/mpls/mpls_types.h +MPLS_IETF_MAX_LABEL = 0xfffff +MPLS_LABEL_INVALID = MPLS_IETF_MAX_LABEL + 1 -class IpPath: - def __init__(self, nh_addr, nh_sw_if_index, nh_table_id=0): +class RoutePath: + + def __init__(self, nh_addr, nh_sw_if_index, nh_table_id=0, labels=[], nh_via_label=MPLS_LABEL_INVALID): self.nh_addr = socket.inet_pton(socket.AF_INET, nh_addr) self.nh_itf = nh_sw_if_index self.nh_table_id = nh_table_id + self.nh_via_label = nh_via_label + self.nh_labels = labels class IpRoute: @@ -34,7 +40,11 @@ class IpRoute: self.dest_addr_len, path.nh_addr, path.nh_itf, - table_id=self.table_id) + table_id=self.table_id, + next_hop_out_label_stack=path.nh_labels, + next_hop_n_out_labels=len( + path.nh_labels), + next_hop_via_label=path.nh_via_label) def remove_vpp_config(self): for path in self.paths: @@ -44,3 +54,62 @@ class IpRoute: path.nh_itf, table_id=self.table_id, is_add=0) + + +class MplsIpBind: + """ + MPLS to IP Binding + """ + + def __init__(self, test, local_label, dest_addr, dest_addr_len): + self._test = test + self.dest_addr = socket.inet_pton(socket.AF_INET, dest_addr) + self.dest_addr_len = dest_addr_len + self.local_label = local_label + + def add_vpp_config(self): + self._test.vapi.mpls_ip_bind_unbind(self.local_label, + self.dest_addr, + self.dest_addr_len) + + def remove_vpp_config(self): + self._test.vapi.mpls_ip_bind_unbind(self.local_label, + self.dest_addr, + self.dest_addr_len, + is_bind=0) + + +class MplsRoute: + """ + MPLS Route + """ + + def __init__(self, test, local_label, eos_bit, paths, table_id=0): + self._test = test + self.paths = paths + self.local_label = local_label + self.eos_bit = eos_bit + self.table_id = table_id + + def add_vpp_config(self): + for path in self.paths: + self._test.vapi.mpls_route_add_del(self.local_label, + self.eos_bit, + 1, + 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_via_label=path.nh_via_label) + + def remove_vpp_config(self): + for path in self.paths: + self._test.vapi.mpls_route_add_del(self.local_label, + self.eos_bit, + 1, + path.nh_addr, + path.nh_itf, + table_id=self.table_id, + is_add=0) |