summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2019-11-24 10:40:56 +0100
committerChristian Poessinger <christian@poessinger.com>2019-11-24 10:44:20 +0100
commitc078dac303d1e427f9612f7ff1996800f5076b47 (patch)
tree20a6c0f00880bb0440f3fdb96b5606c2a4230665 /python
parent9ab56f29f07a3c94a92bb7e1ffa54fcb4762a8fb (diff)
downloadvyos-1x-c078dac303d1e427f9612f7ff1996800f5076b47.tar.gz
vyos-1x-c078dac303d1e427f9612f7ff1996800f5076b47.zip
geneve: T1799: add Generic Network Virtualization Encapsulation
Diffstat (limited to 'python')
-rw-r--r--python/vyos/ifconfig.py39
1 files changed, 38 insertions, 1 deletions
diff --git a/python/vyos/ifconfig.py b/python/vyos/ifconfig.py
index 279d948b7..f487e6a5b 100644
--- a/python/vyos/ifconfig.py
+++ b/python/vyos/ifconfig.py
@@ -1609,7 +1609,7 @@ class WireGuardIf(Interface):
class VXLANIf(Interface, ):
"""
The VXLAN protocol is a tunnelling protocol designed to solve the
- problem of limited VLAN IDs (4096) in IEEE 802.1q. With VXLAN the
+ problem of limited VLAN IDs (4096) in IEEE 802.1q. With VXLAN the
size of the identifier is expanded to 24 bits (16777216).
VXLAN is described by IETF RFC 7348, and has been implemented by a
@@ -1668,3 +1668,40 @@ class VXLANIf(Interface, ):
'remote': ''
}
return config
+
+class GeneveIf(Interface, ):
+ """
+ Geneve: Generic Network Virtualization Encapsulation
+
+ For more information please refer to:
+ https://tools.ietf.org/html/draft-gross-geneve-00
+ https://www.redhat.com/en/blog/what-geneve
+ https://developers.redhat.com/blog/2019/05/17/an-introduction-to-linux-virtual-interfaces-tunnels/#geneve
+ https://lwn.net/Articles/644938/
+ """
+ def __init__(self, ifname, config=''):
+ if config:
+ self._ifname = ifname
+
+ if not os.path.exists('/sys/class/net/{}'.format(self._ifname)):
+ cmd = 'ip link add name {} type geneve id {} remote {}' \
+ .format(self._ifname, config['vni'], config['remote'])
+ self._cmd(cmd)
+
+ super().__init__(ifname, type='geneve')
+
+ @staticmethod
+ def get_config():
+ """
+ GENEVE interfaces require a configuration when they are added using
+ iproute2. This static method will provide the configuration dictionary
+ used by this class.
+
+ Example:
+ >> dict = GeneveIf().get_config()
+ """
+ config = {
+ 'vni': 0,
+ 'remote': ''
+ }
+ return config