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' --- src/conf_mode/vpp_interfaces_gre.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/conf_mode/vpp_interfaces_gre.py b/src/conf_mode/vpp_interfaces_gre.py index 4cb1a71ea..334725994 100644 --- a/src/conf_mode/vpp_interfaces_gre.py +++ b/src/conf_mode/vpp_interfaces_gre.py @@ -124,13 +124,27 @@ def verify(config): return None # source-address and remote are mandatory options - required_keys = {'source_address', 'remote', 'tunnel_type'} + required_keys = {'source_address', 'remote', 'mode', 'tunnel_type'} if not all(key in config for key in required_keys): missing_keys = required_keys - set(config.keys()) raise ConfigError( f"Required options are missing: {', '.join(missing_keys).replace('_', '-')}" ) + # check multipoint mode + if config.get('mode') == 'point-to-multipoint': + # For multipoint mode, remote IP must be 0.0.0.0 + if config.get('remote') != '0.0.0.0': + raise ConfigError('For point-to-multipoint mode, remote must be 0.0.0.0') + # Only one multipoint GRE tunnel is allowed from the same source address + for ifname, iface in config.get('vpp_interfaces', {}).items(): + if iface.get('mode') == 'point-to-multipoint' and iface.get( + 'source_address' + ) == config.get('source_address'): + raise ConfigError( + 'Only one multipoint GRE tunnel is allowed from the same source address' + ) + # Change 'vpp interfaces gre greX kernel-interface vpp-tunX' # => 'vpp interfaces gre greX kernel-interface vpp-tunY' # check if we have kernel interface config 'vpp kernel-interface vpp-tunX' @@ -159,8 +173,9 @@ def apply(config): src_addr = config.get('source_address') dst_addr = config.get('remote') kernel_interface = config.get('kernel_interface', '') + mode = config.get('mode') tunnel_type = config.get('tunnel_type') - i = GREInterface(ifname, src_addr, dst_addr, tunnel_type, kernel_interface) + i = GREInterface(ifname, src_addr, dst_addr, tunnel_type, mode, kernel_interface) i.add() # Add kernel-interface (LCP) if interface is not exist -- cgit v1.2.3