summaryrefslogtreecommitdiff
path: root/src/conf_mode
diff options
context:
space:
mode:
authorNataliia S <81954790+natali-rs1985@users.noreply.github.com>2024-07-08 18:51:40 +0300
committerMergify <37929162+mergify[bot]@users.noreply.github.com>2024-07-26 09:36:35 +0000
commita80813920040e8e0351c3504b9e385b5c579d6a8 (patch)
tree58fbc75edce564e1da7bceb005d0bcf29fffcc4e /src/conf_mode
parent24881b05629918eb26fbffb6ee63a49a1f858527 (diff)
downloadvyos-1x-a80813920040e8e0351c3504b9e385b5c579d6a8.tar.gz
vyos-1x-a80813920040e8e0351c3504b9e385b5c579d6a8.zip
vxlan: T6505: Support VXLAN VLAN-VNI range mapping in CLI (#3756)mergify/bp/sagitta/pr-3756
(cherry picked from commit 115e99630a317cab62c6f99e0461f6ce2c1edaf3)
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-xsrc/conf_mode/interfaces_vxlan.py29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/conf_mode/interfaces_vxlan.py b/src/conf_mode/interfaces_vxlan.py
index bc4918a52..68646e8ff 100755
--- a/src/conf_mode/interfaces_vxlan.py
+++ b/src/conf_mode/interfaces_vxlan.py
@@ -179,13 +179,36 @@ def verify(vxlan):
'is member of a bridge interface!')
vnis_used = []
+ vlans_used = []
for vif, vif_config in vxlan['vlan_to_vni'].items():
if 'vni' not in vif_config:
raise ConfigError(f'Must define VNI for VLAN "{vif}"!')
vni = vif_config['vni']
- if vni in vnis_used:
- raise ConfigError(f'VNI "{vni}" is already assigned to a different VLAN!')
- vnis_used.append(vni)
+
+ err_msg = f'VLAN range "{vif}" does not match VNI range "{vni}"!'
+ vif_range, vni_range = list(map(int, vif.split('-'))), list(map(int, vni.split('-')))
+
+ if len(vif_range) != len(vni_range):
+ raise ConfigError(err_msg)
+
+ if len(vif_range) > 1:
+ if vni_range[0] > vni_range[-1] or vif_range[0] > vif_range[-1]:
+ raise ConfigError('The upper bound of the range must be greater than the lower bound!')
+ vni_range = range(vni_range[0], vni_range[1] + 1)
+ vif_range = range(vif_range[0], vif_range[1] + 1)
+
+ if len(vif_range) != len(vni_range):
+ raise ConfigError(err_msg)
+
+ for vni_id in vni_range:
+ if vni_id in vnis_used:
+ raise ConfigError(f'VNI "{vni_id}" is already assigned to a different VLAN!')
+ vnis_used.append(vni_id)
+
+ for vif_id in vif_range:
+ if vif_id in vlans_used:
+ raise ConfigError(f'VLAN "{vif_id}" is already in use!')
+ vlans_used.append(vif_id)
if dict_search('parameters.neighbor_suppress', vxlan) != None:
if 'is_bridge_member' not in vxlan: