This is to support so called lightweight tunnels when tunnel metadata
is defined externally, e.g. using 'ip route .. encap' command.
Since the external flag makes any mandatory options irrelevant, the
mandatory options are defined dynamically.
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
---
lnst/Devices/GreDevice.py | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/lnst/Devices/GreDevice.py b/lnst/Devices/GreDevice.py
index d1affbc3..5abf9fd4 100644
--- a/lnst/Devices/GreDevice.py
+++ b/lnst/Devices/GreDevice.py
@@ -17,7 +17,12 @@ from lnst.Devices.SoftDevice import SoftDevice
class GreDevice(SoftDevice):
_name_template = "t_gre"
_link_type = "gre"
- _mandatory_opts = ["remote"]
+
+ def __init__(self, ifmanager, *args, **kwargs):
+ if "external" not in kwargs:
+ self._mandatory_opts = ["remote"]
+
+ super(GreDevice, self).__init__(ifmanager, *args, **kwargs)
@property
def local(self):
@@ -41,4 +46,13 @@ class GreDevice(SoftDevice):
@remote.setter
def remote(self, val):
self._set_linkinfo_data_attr("IFLA_GRE_REMOTE", str(ipaddress(val)))
+
+ @property
+ def external(self):
+ return self._get_linkinfo_data_attr("IFLA_GRE_COLLECT_METADATA") is not
None
+
+ @external.setter
+ def external(self, val):
+ if val:
+ self._set_linkinfo_data_attr("IFLA_GRE_COLLECT_METADATA", True)
self._nl_link_sync("set")
--
2.26.3