This patch adds new device Ip6GreDevice to setup a ip6gre tunnel device.
v2:
Use "t_ip6gre" for the _name_template to avoid confusion with the gre
devices.
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
---
lnst/Devices/Ip6GreDevice.py | 44 ++++++++++++++++++++++++++++++++++++
lnst/Devices/__init__.py | 2 ++
2 files changed, 46 insertions(+)
create mode 100644 lnst/Devices/Ip6GreDevice.py
diff --git a/lnst/Devices/Ip6GreDevice.py b/lnst/Devices/Ip6GreDevice.py
new file mode 100644
index 00000000..873d00ed
--- /dev/null
+++ b/lnst/Devices/Ip6GreDevice.py
@@ -0,0 +1,44 @@
+"""
+Defines the Ip6GreDevice class.
+
+Copyright 2021 Red Hat, Inc.
+Licensed under the GNU General Public License, version 2 as
+published by the Free Software Foundation; see COPYING for details.
+"""
+
+__author__ = """
+jtluka(a)redhat.com (Jan Tluka)
+"""
+
+from lnst.Common.IpAddress import ipaddress
+from lnst.Devices.SoftDevice import SoftDevice
+
+
+class Ip6GreDevice(SoftDevice):
+ _name_template = "t_ip6gre"
+ _link_type = "ip6gre"
+ _mandatory_opts = ["remote"]
+
+ @property
+ def local(self):
+ try:
+ return ipaddress(self._get_linkinfo_data_attr("IFLA_IP6GRE_LOCAL"))
+ except:
+ return None
+
+ @local.setter
+ def local(self, val):
+ self._set_linkinfo_data_attr("IFLA_IP6GRE_LOCAL", str(ipaddress(val)))
+ self._nl_link_sync("set")
+
+ @property
+ def remote(self):
+ try:
+ return ipaddress(self._get_linkinfo_data_attr("IFLA_IP6GRE_REMOTE"))
+ except:
+ return None
+
+ @remote.setter
+ def remote(self, val):
+ self._set_linkinfo_data_attr("IFLA_IP6GRE_REMOTE", str(ipaddress(val)))
+ self._nl_link_sync("set")
diff --git a/lnst/Devices/__init__.py b/lnst/Devices/__init__.py
index ddc462e8..2a604de8 100644
--- a/lnst/Devices/__init__.py
+++ b/lnst/Devices/__init__.py
@@ -8,6 +8,7 @@ from lnst.Devices.MacvlanDevice import MacvlanDevice
from lnst.Devices.VlanDevice import VlanDevice
from lnst.Devices.VxlanDevice import VxlanDevice
from lnst.Devices.GreDevice import GreDevice
+from lnst.Devices.Ip6GreDevice import Ip6GreDevice
from lnst.Devices.VtiDevice import VtiDevice, Vti6Device
from lnst.Devices.VethDevice import VethDevice, PairedVethDevice
from lnst.Devices.VethPair import VethPair
@@ -22,6 +23,7 @@ device_classes = [
("VlanDevice", VlanDevice),
("VxlanDevice", VxlanDevice),
("GreDevice", GreDevice),
+ ("Ip6GreDevice", Ip6GreDevice),
("VethDevice", VethDevice),
("PairedVethDevice", PairedVethDevice),
("VtiDevice", VtiDevice),
--
2.26.3