summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorViacheslav Hletenko <v.gletenko@vyos.io>2022-01-25 16:15:57 +0000
committerViacheslav Hletenko <v.gletenko@vyos.io>2022-01-25 16:15:57 +0000
commit5dafe255d6e9cb7747f331b8ecec36b5ca5ce33d (patch)
treecfa7e99cb2feeae660cbce6f691b28757f3db430
parent3249d761843c45fd25de1de31de33df018455bab (diff)
downloadvyos-1x-5dafe255d6e9cb7747f331b8ecec36b5ca5ce33d.tar.gz
vyos-1x-5dafe255d6e9cb7747f331b8ecec36b5ca5ce33d.zip
policy: T4194: Add prefix-list duplication checks
Prefix-list should not be duplicatied as FRR doesn't accept it One option when it can be duplicated when it uses "le" or "ge"
-rwxr-xr-xsrc/conf_mode/policy.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/conf_mode/policy.py b/src/conf_mode/policy.py
index e251396c7..6b1d3bf1a 100755
--- a/src/conf_mode/policy.py
+++ b/src/conf_mode/policy.py
@@ -87,6 +87,7 @@ def verify(policy):
# human readable instance name (hypen instead of underscore)
policy_hr = policy_type.replace('_', '-')
+ entries = []
for rule, rule_config in instance_config['rule'].items():
mandatory_error = f'must be specified for "{policy_hr} {instance} rule {rule}"!'
if 'action' not in rule_config:
@@ -113,6 +114,11 @@ def verify(policy):
if 'prefix' not in rule_config:
raise ConfigError(f'A prefix {mandatory_error}')
+ # Check prefix duplicates
+ if rule_config['prefix'] in entries and ('ge' not in rule_config and 'le' not in rule_config):
+ raise ConfigError(f'Prefix {rule_config["prefix"]} is duplicated!')
+ entries.append(rule_config['prefix'])
+
# route-maps tend to be a bit more complex so they get their own verify() section
if 'route_map' in policy: