blob: 46dce365a3804130766803cfe42db0118383565f [file] [log] [blame]
Neale Ranns177bbdc2016-11-15 09:46:51 +00001
2from vpp_interface import VppInterface
3import socket
4
5
6class VppGreInterface(VppInterface):
7 """
8 VPP GRE interface
9 """
10
John Loa43ccae2018-02-13 17:15:23 -050011 def __init__(self, test, src_ip, dst_ip, outer_fib_id=0, type=0,
12 session=0):
Neale Ranns33ce60d2017-12-14 08:51:32 -080013 """ Create VPP GRE interface """
Klement Sekerab9ef2732018-06-24 22:49:33 +020014 super(VppGreInterface, self).__init__(test)
Neale Ranns177bbdc2016-11-15 09:46:51 +000015 self.t_src = src_ip
16 self.t_dst = dst_ip
17 self.t_outer_fib = outer_fib_id
John Loa43ccae2018-02-13 17:15:23 -050018 self.t_type = type
19 self.t_session = session
Neale Ranns177bbdc2016-11-15 09:46:51 +000020
21 def add_vpp_config(self):
22 s = socket.inet_pton(socket.AF_INET, self.t_src)
23 d = socket.inet_pton(socket.AF_INET, self.t_dst)
Ole Troane1ade682019-03-04 23:55:43 +010024 r = self.test.vapi.gre_add_del_tunnel(s, d,
Neale Ranns177bbdc2016-11-15 09:46:51 +000025 outer_fib_id=self.t_outer_fib,
John Loa43ccae2018-02-13 17:15:23 -050026 tunnel_type=self.t_type,
27 session_id=self.t_session)
Klement Sekerab9ef2732018-06-24 22:49:33 +020028 self.set_sw_if_index(r.sw_if_index)
Neale Ranns39f99732016-11-28 16:10:59 +000029 self.generate_remote_hosts()
Klement Sekerac798bc52018-05-23 20:22:20 +020030 self.test.registry.register(self, self.test.logger)
Neale Ranns177bbdc2016-11-15 09:46:51 +000031
32 def remove_vpp_config(self):
33 s = socket.inet_pton(socket.AF_INET, self.t_src)
34 d = socket.inet_pton(socket.AF_INET, self.t_dst)
35 self.unconfig()
Ole Troane1ade682019-03-04 23:55:43 +010036 self.test.vapi.gre_add_del_tunnel(s, d,
Klement Sekera75e7d132017-09-20 08:26:30 +020037 outer_fib_id=self.t_outer_fib,
John Loa43ccae2018-02-13 17:15:23 -050038 tunnel_type=self.t_type,
39 session_id=self.t_session,
Klement Sekera75e7d132017-09-20 08:26:30 +020040 is_add=0)
41
Klement Sekera75e7d132017-09-20 08:26:30 +020042 def object_id(self):
Klement Sekerac798bc52018-05-23 20:22:20 +020043 return "gre-%d" % self.sw_if_index
Ciara Loftus7eac9162016-09-30 15:47:03 +010044
45
46class VppGre6Interface(VppInterface):
47 """
48 VPP GRE IPv6 interface
49 """
50
John Loa43ccae2018-02-13 17:15:23 -050051 def __init__(self, test, src_ip, dst_ip, outer_fib_id=0, type=0,
52 session=0):
Neale Ranns33ce60d2017-12-14 08:51:32 -080053 """ Create VPP GRE interface """
Klement Sekerab9ef2732018-06-24 22:49:33 +020054 super(VppGre6Interface, self).__init__(test)
Ciara Loftus7eac9162016-09-30 15:47:03 +010055 self.t_src = src_ip
56 self.t_dst = dst_ip
57 self.t_outer_fib = outer_fib_id
John Loa43ccae2018-02-13 17:15:23 -050058 self.t_type = type
59 self.t_session = session
Ciara Loftus7eac9162016-09-30 15:47:03 +010060
61 def add_vpp_config(self):
62 s = socket.inet_pton(socket.AF_INET6, self.t_src)
63 d = socket.inet_pton(socket.AF_INET6, self.t_dst)
Ole Troane1ade682019-03-04 23:55:43 +010064 r = self.test.vapi.gre_add_del_tunnel(s, d,
Ciara Loftus7eac9162016-09-30 15:47:03 +010065 outer_fib_id=self.t_outer_fib,
John Loa43ccae2018-02-13 17:15:23 -050066 tunnel_type=self.t_type,
67 session_id=self.t_session,
Ciara Loftus7eac9162016-09-30 15:47:03 +010068 is_ip6=1)
Klement Sekerab9ef2732018-06-24 22:49:33 +020069 self.set_sw_if_index(r.sw_if_index)
Ciara Loftus7eac9162016-09-30 15:47:03 +010070 self.generate_remote_hosts()
Klement Sekerac798bc52018-05-23 20:22:20 +020071 self.test.registry.register(self, self.test.logger)
Ciara Loftus7eac9162016-09-30 15:47:03 +010072
73 def remove_vpp_config(self):
74 s = socket.inet_pton(socket.AF_INET6, self.t_src)
75 d = socket.inet_pton(socket.AF_INET6, self.t_dst)
76 self.unconfig()
Ole Troane1ade682019-03-04 23:55:43 +010077 self.test.vapi.gre_add_del_tunnel(s, d,
Klement Sekera75e7d132017-09-20 08:26:30 +020078 outer_fib_id=self.t_outer_fib,
John Loa43ccae2018-02-13 17:15:23 -050079 tunnel_type=self.t_type,
80 session_id=self.t_session,
Klement Sekera75e7d132017-09-20 08:26:30 +020081 is_add=0,
82 is_ip6=1)
83
Klement Sekera75e7d132017-09-20 08:26:30 +020084 def object_id(self):
85 return "gre-%d" % self._sw_if_index