blob: c789c3f1dd0495c84f368ccdbd038c5352a4e1d8 [file] [log] [blame]
Neale Ranns0f26c5a2017-03-01 15:12:11 -08001
2from vpp_interface import VppInterface
Neale Ranns31ed7442018-02-23 05:29:09 -08003from vpp_ip_route import VppRoutePath, VppMplsLabel
Neale Ranns0f26c5a2017-03-01 15:12:11 -08004import socket
5
6
7class VppMPLSTunnelInterface(VppInterface):
8 """
9 VPP MPLS Tunnel interface
10 """
11
Neale Rannsda78f952017-05-24 09:15:43 -070012 def __init__(self, test, paths, is_multicast=0, is_l2=0):
Neale Ranns0f26c5a2017-03-01 15:12:11 -080013 """ Create MPLS Tunnel interface """
14 self._sw_if_index = 0
15 super(VppMPLSTunnelInterface, self).__init__(test)
16 self._test = test
17 self.t_paths = paths
18 self.is_multicast = is_multicast
Neale Rannsda78f952017-05-24 09:15:43 -070019 self.is_l2 = is_l2
Neale Ranns0f26c5a2017-03-01 15:12:11 -080020
21 def add_vpp_config(self):
22 self._sw_if_index = 0xffffffff
23 for path in self.t_paths:
Neale Ranns31ed7442018-02-23 05:29:09 -080024 lstack = path.encode_labels()
25
Neale Ranns0f26c5a2017-03-01 15:12:11 -080026 reply = self.test.vapi.mpls_tunnel_add_del(
27 self._sw_if_index,
28 1, # IPv4 next-hop
29 path.nh_addr,
30 path.nh_itf,
31 path.nh_table_id,
32 path.weight,
Neale Ranns31ed7442018-02-23 05:29:09 -080033 next_hop_out_label_stack=lstack,
34 next_hop_n_out_labels=len(lstack),
Neale Rannsda78f952017-05-24 09:15:43 -070035 is_multicast=self.is_multicast,
36 l2_only=self.is_l2)
Neale Ranns0f26c5a2017-03-01 15:12:11 -080037 self._sw_if_index = reply.sw_if_index
38
39 def remove_vpp_config(self):
40 for path in self.t_paths:
41 reply = self.test.vapi.mpls_tunnel_add_del(
42 self.sw_if_index,
43 1, # IPv4 next-hop
44 path.nh_addr,
45 path.nh_itf,
46 path.nh_table_id,
47 path.weight,
48 next_hop_out_label_stack=path.nh_labels,
49 next_hop_n_out_labels=len(path.nh_labels),
50 is_add=0)