From 9425dce22f1bc8393d5ea6b2ae39b4ef70b7fa50 Mon Sep 17 00:00:00 2001 From: Viacheslav Hletenko Date: Fri, 24 Jan 2025 15:26:27 +0000 Subject: GRE: Add ability to configure multipoint mode Add ability to configure multipoint mode. Remote IP address in this case has to be 0.0.0.0 Only one tunnel with the same source IP is allowed in the point-to-multipoint mode set vpp interfaces gre gre0 mode 'point-to-multipoint' set vpp interfaces gre gre0 remote '0.0.0.0' set vpp interfaces gre gre0 source-address '192.0.2.1' --- python/vyos/vpp/interface/gre.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'python') diff --git a/python/vyos/vpp/interface/gre.py b/python/vyos/vpp/interface/gre.py index 65559f294..8f3dbebae 100644 --- a/python/vyos/vpp/interface/gre.py +++ b/python/vyos/vpp/interface/gre.py @@ -38,6 +38,7 @@ class GREInterface: source_address (str): The source IP address for the GRE tunnel. remote (str): The remote IP address for the GRE tunnel. tunnel_type (str): The type of GRE tunnel. Defaults to 'l3'. + mode (str): The mode of the GRE tunnel. Options are 'point-to-point' and 'point-to-multipoint'. Defaults to 'point-to-point'. kernel_interface (str): The associated kernel interface. Defaults to an empty string. instance (int): The instance number derived from the interface name. vpp (VPPControl): An instance of the VPPControl class for interacting with the VPP API. @@ -45,9 +46,14 @@ class GREInterface: # Mapping of tunnel types https://github.com/FDio/vpp/blob/stable/2406/src/plugins/gre/gre.api#L25-L35 TUNNEL_TYPE_MAP = { - "l3": 0, - "teb": 1, - "erspan": 2, + 'l3': 0, + 'teb': 1, + 'erspan': 2, + } + + MODE_MAP = { + 'point-to-point': 0, + 'point-to-multipoint': 1, } def __init__( @@ -56,6 +62,7 @@ class GREInterface: source_address, remote, tunnel_type: str = 'l3', + mode: str = 'point-to-point', kernel_interface: str = '', ): """ @@ -65,6 +72,7 @@ class GREInterface: ifname (str): The interface name. source_address (str): The source IP address for the GRE tunnel. remote (str): The remote IP address for the GRE tunnel. + mode (str): The mode of the GRE tunnel. Options are 'point-to-point' and 'point-to-multipoint'. Defaults to 'point-to-point'. tunnel_type (str): The type of GRE tunnel. Defaults to 'l3'. kernel_interface (str): The associated kernel interface. Defaults to an empty string. """ @@ -73,6 +81,7 @@ class GREInterface: self.src_address = source_address self.dst_address = remote self.tunnel_type = self.TUNNEL_TYPE_MAP[tunnel_type] + self.mode = self.MODE_MAP[mode] self.kernel_interface = kernel_interface self.vpp = VPPControl() @@ -90,6 +99,7 @@ class GREInterface: 'src': self.src_address, 'dst': self.dst_address, 'instance': self.instance, + 'mode': self.mode, 'type': self.tunnel_type, }, ) -- cgit v1.2.3