2016-11-15 09:46:51 +00:00
|
|
|
from vpp_interface import VppInterface
|
2019-04-16 07:15:35 +00:00
|
|
|
from vpp_papi import VppEnum
|
2016-11-15 09:46:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
class VppGreInterface(VppInterface):
|
|
|
|
"""
|
|
|
|
VPP GRE interface
|
|
|
|
"""
|
|
|
|
|
2022-04-26 19:02:15 +02:00
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
test,
|
|
|
|
src_ip,
|
|
|
|
dst_ip,
|
|
|
|
outer_table_id=0,
|
|
|
|
type=None,
|
|
|
|
mode=None,
|
|
|
|
flags=0,
|
|
|
|
session=0,
|
|
|
|
):
|
|
|
|
"""Create VPP GRE interface"""
|
2018-06-24 22:49:33 +02:00
|
|
|
super(VppGreInterface, self).__init__(test)
|
2016-11-15 09:46:51 +00:00
|
|
|
self.t_src = src_ip
|
|
|
|
self.t_dst = dst_ip
|
2019-04-18 10:23:56 +00:00
|
|
|
self.t_outer_table = outer_table_id
|
2018-02-13 17:15:23 -05:00
|
|
|
self.t_session = session
|
2019-12-31 05:13:14 +00:00
|
|
|
self.t_flags = flags
|
2019-04-16 07:15:35 +00:00
|
|
|
self.t_type = type
|
|
|
|
if not self.t_type:
|
2022-04-26 19:02:15 +02:00
|
|
|
self.t_type = VppEnum.vl_api_gre_tunnel_type_t.GRE_API_TUNNEL_TYPE_L3
|
2019-04-18 10:23:56 +00:00
|
|
|
self.t_mode = mode
|
|
|
|
if not self.t_mode:
|
2022-04-26 19:02:15 +02:00
|
|
|
self.t_mode = VppEnum.vl_api_tunnel_mode_t.TUNNEL_API_MODE_P2P
|
2016-11-15 09:46:51 +00:00
|
|
|
|
|
|
|
def add_vpp_config(self):
|
2019-04-18 10:23:56 +00:00
|
|
|
r = self.test.vapi.gre_tunnel_add_del(
|
2019-12-31 05:13:14 +00:00
|
|
|
is_add=1,
|
|
|
|
tunnel={
|
2022-04-26 19:02:15 +02:00
|
|
|
"src": self.t_src,
|
|
|
|
"dst": self.t_dst,
|
|
|
|
"outer_table_id": self.t_outer_table,
|
|
|
|
"instance": 0xFFFFFFFF,
|
|
|
|
"type": self.t_type,
|
|
|
|
"mode": self.t_mode,
|
|
|
|
"flags": self.t_flags,
|
|
|
|
"session_id": self.t_session,
|
|
|
|
},
|
|
|
|
)
|
2018-06-24 22:49:33 +02:00
|
|
|
self.set_sw_if_index(r.sw_if_index)
|
2016-11-28 16:10:59 +00:00
|
|
|
self.generate_remote_hosts()
|
2018-05-23 20:22:20 +02:00
|
|
|
self.test.registry.register(self, self.test.logger)
|
2019-08-04 02:41:57 -07:00
|
|
|
return self
|
2016-11-15 09:46:51 +00:00
|
|
|
|
|
|
|
def remove_vpp_config(self):
|
|
|
|
self.unconfig()
|
2019-12-31 05:13:14 +00:00
|
|
|
self.test.vapi.gre_tunnel_add_del(
|
|
|
|
is_add=0,
|
|
|
|
tunnel={
|
2022-04-26 19:02:15 +02:00
|
|
|
"src": self.t_src,
|
|
|
|
"dst": self.t_dst,
|
|
|
|
"outer_table_id": self.t_outer_table,
|
|
|
|
"instance": 0xFFFFFFFF,
|
|
|
|
"type": self.t_type,
|
|
|
|
"mode": self.t_mode,
|
|
|
|
"flags": self.t_flags,
|
|
|
|
"session_id": self.t_session,
|
|
|
|
},
|
|
|
|
)
|
2017-09-20 08:26:30 +02:00
|
|
|
|
|
|
|
def object_id(self):
|
2018-05-23 20:22:20 +02:00
|
|
|
return "gre-%d" % self.sw_if_index
|
2016-09-30 15:47:03 +01:00
|
|
|
|
2019-04-16 07:15:35 +00:00
|
|
|
def query_vpp_config(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
return self.test.vapi.gre_tunnel_dump(sw_if_index=self._sw_if_index)
|
2019-09-26 16:20:19 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def remote_ip(self):
|
|
|
|
return self.t_dst
|
|
|
|
|
|
|
|
@property
|
|
|
|
def local_ip(self):
|
|
|
|
return self.t_src
|