summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2026-05-26 08:34:20 +0200
committerGitHub <noreply@github.com>2026-05-26 08:34:20 +0200
commit567e968f5c6ee86360151144bd8239ec2cdca12b (patch)
tree81ef5b86ce6bfc636c944c35b898cc99a3de94b3 /src
parent9534f4202e4430b4a58caa28603e5594178fd745 (diff)
parenta3f1a67981299d281f6831ea077830d37c4c4740 (diff)
downloadvyos-1x-567e968f5c6ee86360151144bd8239ec2cdca12b.tar.gz
vyos-1x-567e968f5c6ee86360151144bd8239ec2cdca12b.zip
Merge pull request #5179 from josephillips85/current
Policy: T8823: validation of GE and LE according FRR instructions
Diffstat (limited to 'src')
-rwxr-xr-xsrc/conf_mode/policy.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/conf_mode/policy.py b/src/conf_mode/policy.py
index 689365724..171ef23fd 100755
--- a/src/conf_mode/policy.py
+++ b/src/conf_mode/policy.py
@@ -167,6 +167,26 @@ def verify(config_dict):
if 'prefix' not in rule_config:
raise ConfigError(f'A prefix {mandatory_error}')
+ mask_len = int(rule_config['prefix'].split('/')[1])
+ ge = dict_search('ge', rule_config)
+ le = dict_search('le', rule_config)
+
+ if ge and int(ge) < mask_len:
+ raise ConfigError(
+ f'{policy_hr} {instance} rule {rule}: "ge" ({ge}) must be >= '
+ f'prefix length ({mask_len})'
+ )
+ if le and int(le) < mask_len:
+ raise ConfigError(
+ f'{policy_hr} {instance} rule {rule}: "le" ({le}) must be >= '
+ f'prefix length ({mask_len})'
+ )
+ if ge and le and int(ge) > int(le):
+ raise ConfigError(
+ f'{policy_hr} {instance} rule {rule}: "ge" ({ge}) must be <= '
+ f'"le" ({le})'
+ )
+
if rule_config in entries:
raise ConfigError(
f'Rule "{rule}" contains a duplicate prefix definition!')