2017-03-01 15:12:11 -08:00
|
|
|
|
|
|
|
from vpp_interface import VppInterface
|
|
|
|
|
|
|
|
|
|
|
|
class VppMPLSTunnelInterface(VppInterface):
|
|
|
|
"""
|
|
|
|
VPP MPLS Tunnel interface
|
|
|
|
"""
|
|
|
|
|
2017-05-24 09:15:43 -07:00
|
|
|
def __init__(self, test, paths, is_multicast=0, is_l2=0):
|
2017-03-01 15:12:11 -08:00
|
|
|
""" Create MPLS Tunnel interface """
|
2018-06-24 22:49:33 +02:00
|
|
|
super(VppMPLSTunnelInterface, self).__init__(test)
|
2017-03-01 15:12:11 -08:00
|
|
|
self.t_paths = paths
|
|
|
|
self.is_multicast = is_multicast
|
2017-05-24 09:15:43 -07:00
|
|
|
self.is_l2 = is_l2
|
2017-03-01 15:12:11 -08:00
|
|
|
|
|
|
|
def add_vpp_config(self):
|
2018-05-30 10:32:21 +02:00
|
|
|
sw_if_index = 0xffffffff
|
2017-03-01 15:12:11 -08:00
|
|
|
for path in self.t_paths:
|
2018-02-23 05:29:09 -08:00
|
|
|
lstack = path.encode_labels()
|
|
|
|
|
2017-03-01 15:12:11 -08:00
|
|
|
reply = self.test.vapi.mpls_tunnel_add_del(
|
2018-05-30 10:32:21 +02:00
|
|
|
sw_if_index,
|
2017-03-01 15:12:11 -08:00
|
|
|
1, # IPv4 next-hop
|
|
|
|
path.nh_addr,
|
|
|
|
path.nh_itf,
|
|
|
|
path.nh_table_id,
|
|
|
|
path.weight,
|
2018-02-23 05:29:09 -08:00
|
|
|
next_hop_out_label_stack=lstack,
|
|
|
|
next_hop_n_out_labels=len(lstack),
|
2017-05-24 09:15:43 -07:00
|
|
|
is_multicast=self.is_multicast,
|
|
|
|
l2_only=self.is_l2)
|
2018-05-30 10:32:21 +02:00
|
|
|
sw_if_index = reply.sw_if_index
|
2018-06-24 22:49:33 +02:00
|
|
|
self.set_sw_if_index(sw_if_index)
|
2017-03-01 15:12:11 -08:00
|
|
|
|
|
|
|
def remove_vpp_config(self):
|
|
|
|
for path in self.t_paths:
|
2018-05-30 10:32:21 +02:00
|
|
|
self.test.vapi.mpls_tunnel_add_del(
|
2017-03-01 15:12:11 -08:00
|
|
|
self.sw_if_index,
|
|
|
|
1, # IPv4 next-hop
|
|
|
|
path.nh_addr,
|
|
|
|
path.nh_itf,
|
|
|
|
path.nh_table_id,
|
|
|
|
path.weight,
|
|
|
|
next_hop_out_label_stack=path.nh_labels,
|
|
|
|
next_hop_n_out_labels=len(path.nh_labels),
|
|
|
|
is_add=0)
|