blob: 2e0ed67ce83c70e37c87ac9dd2e4c08d3f0d0c4c [file] [log] [blame]
Neale Ranns0f26c5a2017-03-01 15:12:11 -08001
2from vpp_interface import VppInterface
Neale Ranns0f26c5a2017-03-01 15:12:11 -08003
4
5class VppMPLSTunnelInterface(VppInterface):
6 """
7 VPP MPLS Tunnel interface
8 """
9
Neale Rannsda78f952017-05-24 09:15:43 -070010 def __init__(self, test, paths, is_multicast=0, is_l2=0):
Neale Ranns0f26c5a2017-03-01 15:12:11 -080011 """ Create MPLS Tunnel interface """
Neale Ranns0f26c5a2017-03-01 15:12:11 -080012 self._test = test
13 self.t_paths = paths
14 self.is_multicast = is_multicast
Neale Rannsda78f952017-05-24 09:15:43 -070015 self.is_l2 = is_l2
Neale Ranns0f26c5a2017-03-01 15:12:11 -080016
17 def add_vpp_config(self):
Klement Sekeraff4ba352018-05-30 10:32:21 +020018 sw_if_index = 0xffffffff
Neale Ranns0f26c5a2017-03-01 15:12:11 -080019 for path in self.t_paths:
Neale Ranns31ed7442018-02-23 05:29:09 -080020 lstack = path.encode_labels()
21
Neale Ranns0f26c5a2017-03-01 15:12:11 -080022 reply = self.test.vapi.mpls_tunnel_add_del(
Klement Sekeraff4ba352018-05-30 10:32:21 +020023 sw_if_index,
Neale Ranns0f26c5a2017-03-01 15:12:11 -080024 1, # IPv4 next-hop
25 path.nh_addr,
26 path.nh_itf,
27 path.nh_table_id,
28 path.weight,
Neale Ranns31ed7442018-02-23 05:29:09 -080029 next_hop_out_label_stack=lstack,
30 next_hop_n_out_labels=len(lstack),
Neale Rannsda78f952017-05-24 09:15:43 -070031 is_multicast=self.is_multicast,
32 l2_only=self.is_l2)
Klement Sekeraff4ba352018-05-30 10:32:21 +020033 sw_if_index = reply.sw_if_index
34 self._sw_if_index = sw_if_index
35 super(VppMPLSTunnelInterface, self).__init__(self.test)
Neale Ranns0f26c5a2017-03-01 15:12:11 -080036
37 def remove_vpp_config(self):
38 for path in self.t_paths:
Klement Sekeraff4ba352018-05-30 10:32:21 +020039 self.test.vapi.mpls_tunnel_add_del(
Neale Ranns0f26c5a2017-03-01 15:12:11 -080040 self.sw_if_index,
41 1, # IPv4 next-hop
42 path.nh_addr,
43 path.nh_itf,
44 path.nh_table_id,
45 path.weight,
46 next_hop_out_label_stack=path.nh_labels,
47 next_hop_n_out_labels=len(path.nh_labels),
48 is_add=0)