blob: fca2c1f86c8725b77b7d348f02a5966a7e6404c1 [file] [log] [blame]
Neale Ranns177bbdc2016-11-15 09:46:51 +00001
2from vpp_interface import VppInterface
3import socket
Neale Ranns5a8844b2019-04-16 07:15:35 +00004from vpp_papi import VppEnum
Neale Ranns177bbdc2016-11-15 09:46:51 +00005
6
7class VppGreInterface(VppInterface):
8 """
9 VPP GRE interface
10 """
11
Neale Ranns5a8844b2019-04-16 07:15:35 +000012 def __init__(self, test, src_ip, dst_ip, outer_fib_id=0, type=None,
John Loa43ccae2018-02-13 17:15:23 -050013 session=0):
Neale Ranns33ce60d2017-12-14 08:51:32 -080014 """ Create VPP GRE interface """
Klement Sekerab9ef2732018-06-24 22:49:33 +020015 super(VppGreInterface, self).__init__(test)
Neale Ranns177bbdc2016-11-15 09:46:51 +000016 self.t_src = src_ip
17 self.t_dst = dst_ip
18 self.t_outer_fib = outer_fib_id
John Loa43ccae2018-02-13 17:15:23 -050019 self.t_session = session
Neale Ranns5a8844b2019-04-16 07:15:35 +000020 self.t_type = type
21 if not self.t_type:
22 self.t_type = (VppEnum.vl_api_gre_tunnel_type_t.
23 GRE_API_TUNNEL_TYPE_L3)
Neale Ranns177bbdc2016-11-15 09:46:51 +000024
25 def add_vpp_config(self):
Neale Ranns5a8844b2019-04-16 07:15:35 +000026 r = self.test.vapi.gre_tunnel_add_del(self.t_src,
27 self.t_dst,
Neale Ranns177bbdc2016-11-15 09:46:51 +000028 outer_fib_id=self.t_outer_fib,
John Loa43ccae2018-02-13 17:15:23 -050029 tunnel_type=self.t_type,
30 session_id=self.t_session)
Klement Sekerab9ef2732018-06-24 22:49:33 +020031 self.set_sw_if_index(r.sw_if_index)
Neale Ranns39f99732016-11-28 16:10:59 +000032 self.generate_remote_hosts()
Klement Sekerac798bc52018-05-23 20:22:20 +020033 self.test.registry.register(self, self.test.logger)
Neale Rannsadb17a82019-08-04 02:41:57 -070034 return self
Neale Ranns177bbdc2016-11-15 09:46:51 +000035
36 def remove_vpp_config(self):
Neale Ranns177bbdc2016-11-15 09:46:51 +000037 self.unconfig()
Neale Ranns5a8844b2019-04-16 07:15:35 +000038 self.test.vapi.gre_tunnel_add_del(self.t_src,
39 self.t_dst,
Klement Sekera75e7d132017-09-20 08:26:30 +020040 outer_fib_id=self.t_outer_fib,
John Loa43ccae2018-02-13 17:15:23 -050041 tunnel_type=self.t_type,
42 session_id=self.t_session,
Klement Sekera75e7d132017-09-20 08:26:30 +020043 is_add=0)
44
Klement Sekera75e7d132017-09-20 08:26:30 +020045 def object_id(self):
Klement Sekerac798bc52018-05-23 20:22:20 +020046 return "gre-%d" % self.sw_if_index
Ciara Loftus7eac9162016-09-30 15:47:03 +010047
Neale Ranns5a8844b2019-04-16 07:15:35 +000048 def query_vpp_config(self):
49 return (self.test.vapi.gre_tunnel_dump(
50 sw_if_index=self._sw_if_index))