Neale Ranns | 0f26c5a | 2017-03-01 15:12:11 -0800 | [diff] [blame] | 1 | |
| 2 | from vpp_interface import VppInterface |
| 3 | from vpp_ip_route import VppRoutePath |
| 4 | import socket |
| 5 | |
| 6 | |
| 7 | class VppMPLSTunnelInterface(VppInterface): |
| 8 | """ |
| 9 | VPP MPLS Tunnel interface |
| 10 | """ |
| 11 | |
Neale Ranns | da78f95 | 2017-05-24 09:15:43 -0700 | [diff] [blame] | 12 | def __init__(self, test, paths, is_multicast=0, is_l2=0): |
Neale Ranns | 0f26c5a | 2017-03-01 15:12:11 -0800 | [diff] [blame] | 13 | """ 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 Ranns | da78f95 | 2017-05-24 09:15:43 -0700 | [diff] [blame] | 19 | self.is_l2 = is_l2 |
Neale Ranns | 0f26c5a | 2017-03-01 15:12:11 -0800 | [diff] [blame] | 20 | |
| 21 | def add_vpp_config(self): |
| 22 | self._sw_if_index = 0xffffffff |
| 23 | for path in self.t_paths: |
| 24 | reply = self.test.vapi.mpls_tunnel_add_del( |
| 25 | self._sw_if_index, |
| 26 | 1, # IPv4 next-hop |
| 27 | path.nh_addr, |
| 28 | path.nh_itf, |
| 29 | path.nh_table_id, |
| 30 | path.weight, |
| 31 | next_hop_out_label_stack=path.nh_labels, |
| 32 | next_hop_n_out_labels=len(path.nh_labels), |
Neale Ranns | da78f95 | 2017-05-24 09:15:43 -0700 | [diff] [blame] | 33 | is_multicast=self.is_multicast, |
| 34 | l2_only=self.is_l2) |
Neale Ranns | 0f26c5a | 2017-03-01 15:12:11 -0800 | [diff] [blame] | 35 | self._sw_if_index = reply.sw_if_index |
| 36 | |
| 37 | def remove_vpp_config(self): |
| 38 | for path in self.t_paths: |
| 39 | reply = self.test.vapi.mpls_tunnel_add_del( |
| 40 | 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) |