2016-11-15 09:46:51 +00:00
|
|
|
|
|
|
|
from vpp_interface import VppInterface
|
|
|
|
import socket
|
|
|
|
|
|
|
|
|
|
|
|
class VppGreInterface(VppInterface):
|
|
|
|
"""
|
|
|
|
VPP GRE interface
|
|
|
|
"""
|
|
|
|
|
2018-02-13 17:15:23 -05:00
|
|
|
def __init__(self, test, src_ip, dst_ip, outer_fib_id=0, type=0,
|
|
|
|
session=0):
|
2017-12-14 08:51:32 -08:00
|
|
|
""" 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
|
|
|
|
self.t_outer_fib = outer_fib_id
|
2018-02-13 17:15:23 -05:00
|
|
|
self.t_type = type
|
|
|
|
self.t_session = session
|
2016-11-15 09:46:51 +00:00
|
|
|
|
|
|
|
def add_vpp_config(self):
|
|
|
|
s = socket.inet_pton(socket.AF_INET, self.t_src)
|
|
|
|
d = socket.inet_pton(socket.AF_INET, self.t_dst)
|
|
|
|
r = self.test.vapi.gre_tunnel_add_del(s, d,
|
|
|
|
outer_fib_id=self.t_outer_fib,
|
2018-02-13 17:15:23 -05:00
|
|
|
tunnel_type=self.t_type,
|
|
|
|
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)
|
2016-11-15 09:46:51 +00:00
|
|
|
|
|
|
|
def remove_vpp_config(self):
|
|
|
|
s = socket.inet_pton(socket.AF_INET, self.t_src)
|
|
|
|
d = socket.inet_pton(socket.AF_INET, self.t_dst)
|
|
|
|
self.unconfig()
|
2017-09-20 08:26:30 +02:00
|
|
|
self.test.vapi.gre_tunnel_add_del(s, d,
|
|
|
|
outer_fib_id=self.t_outer_fib,
|
2018-02-13 17:15:23 -05:00
|
|
|
tunnel_type=self.t_type,
|
|
|
|
session_id=self.t_session,
|
2017-09-20 08:26:30 +02:00
|
|
|
is_add=0)
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.object_id()
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
class VppGre6Interface(VppInterface):
|
|
|
|
"""
|
|
|
|
VPP GRE IPv6 interface
|
|
|
|
"""
|
|
|
|
|
2018-02-13 17:15:23 -05:00
|
|
|
def __init__(self, test, src_ip, dst_ip, outer_fib_id=0, type=0,
|
|
|
|
session=0):
|
2017-12-14 08:51:32 -08:00
|
|
|
""" Create VPP GRE interface """
|
2018-06-24 22:49:33 +02:00
|
|
|
super(VppGre6Interface, self).__init__(test)
|
2016-09-30 15:47:03 +01:00
|
|
|
self.t_src = src_ip
|
|
|
|
self.t_dst = dst_ip
|
|
|
|
self.t_outer_fib = outer_fib_id
|
2018-02-13 17:15:23 -05:00
|
|
|
self.t_type = type
|
|
|
|
self.t_session = session
|
2016-09-30 15:47:03 +01:00
|
|
|
|
|
|
|
def add_vpp_config(self):
|
|
|
|
s = socket.inet_pton(socket.AF_INET6, self.t_src)
|
|
|
|
d = socket.inet_pton(socket.AF_INET6, self.t_dst)
|
|
|
|
r = self.test.vapi.gre_tunnel_add_del(s, d,
|
|
|
|
outer_fib_id=self.t_outer_fib,
|
2018-02-13 17:15:23 -05:00
|
|
|
tunnel_type=self.t_type,
|
|
|
|
session_id=self.t_session,
|
2016-09-30 15:47:03 +01:00
|
|
|
is_ip6=1)
|
2018-06-24 22:49:33 +02:00
|
|
|
self.set_sw_if_index(r.sw_if_index)
|
2016-09-30 15:47:03 +01:00
|
|
|
self.generate_remote_hosts()
|
2018-05-23 20:22:20 +02:00
|
|
|
self.test.registry.register(self, self.test.logger)
|
2016-09-30 15:47:03 +01:00
|
|
|
|
|
|
|
def remove_vpp_config(self):
|
|
|
|
s = socket.inet_pton(socket.AF_INET6, self.t_src)
|
|
|
|
d = socket.inet_pton(socket.AF_INET6, self.t_dst)
|
|
|
|
self.unconfig()
|
2017-09-20 08:26:30 +02:00
|
|
|
self.test.vapi.gre_tunnel_add_del(s, d,
|
|
|
|
outer_fib_id=self.t_outer_fib,
|
2018-02-13 17:15:23 -05:00
|
|
|
tunnel_type=self.t_type,
|
|
|
|
session_id=self.t_session,
|
2017-09-20 08:26:30 +02:00
|
|
|
is_add=0,
|
|
|
|
is_ip6=1)
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.object_id()
|
|
|
|
|
|
|
|
def object_id(self):
|
|
|
|
return "gre-%d" % self._sw_if_index
|