summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2022-01-27 15:11:39 +0100
committerGitHub <noreply@github.com>2022-01-27 15:11:39 +0100
commita414fa198a96ac5557bc1bd827e8dc18c3150825 (patch)
treec03f61b280e081c8fc4cb08bd10fdd54d3d6dc81
parente2924920618b9d6a6b933ebcb3c36b98669f9f32 (diff)
parent5dafe255d6e9cb7747f331b8ecec36b5ca5ce33d (diff)
downloadvyos-1x-a414fa198a96ac5557bc1bd827e8dc18c3150825.tar.gz
vyos-1x-a414fa198a96ac5557bc1bd827e8dc18c3150825.zip
Merge pull request #1190 from sever-sever/T4194
policy: T4194: Add prefix-list duplication checks
-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: