summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorl0crian1 <143656816+l0crian1@users.noreply.github.com>2025-09-14 04:52:09 -0400
committerGitHub <noreply@github.com>2025-09-14 10:52:09 +0200
commiteb3c88023c7768ac9cbb5a84f78a71edcb798137 (patch)
tree98a329e32e29301c3137e642d927af93ce290109
parentad686a956cc8f6f14452798f3d77da2320956b54 (diff)
downloadvyos-1x-eb3c88023c7768ac9cbb5a84f78a71edcb798137.tar.gz
vyos-1x-eb3c88023c7768ac9cbb5a84f78a71edcb798137.zip
route-map: T1124: Allow matching RPKI OVS extended community (#4699)
- Added 'rpki-extcommunity' match condition - Added test to test_policy.py smoketest for rpki-extcommunity match
-rw-r--r--data/templates/frr/policy.frr.j23
-rw-r--r--interface-definitions/policy.xml.in23
-rwxr-xr-xsmoketest/scripts/cli/test_policy.py33
3 files changed, 59 insertions, 0 deletions
diff --git a/data/templates/frr/policy.frr.j2 b/data/templates/frr/policy.frr.j2
index c28633f6f..5d6ac30e0 100644
--- a/data/templates/frr/policy.frr.j2
+++ b/data/templates/frr/policy.frr.j2
@@ -252,6 +252,9 @@ route-map {{ route_map }} {{ rule_config.action }} {{ rule }}
{% if rule_config.match.rpki is vyos_defined %}
match rpki {{ rule_config.match.rpki }}
{% endif %}
+{% if rule_config.match.rpki_extcommunity is vyos_defined %}
+ match rpki-extcommunity {{ rule_config.match.rpki_extcommunity }}
+{% endif %}
{% if rule_config.match.source_vrf is vyos_defined %}
match source-vrf {{ rule_config.match.source_vrf }}
{% endif %}
diff --git a/interface-definitions/policy.xml.in b/interface-definitions/policy.xml.in
index 31e01c68c..d2082fd7a 100644
--- a/interface-definitions/policy.xml.in
+++ b/interface-definitions/policy.xml.in
@@ -1092,6 +1092,29 @@
</constraint>
</properties>
</leafNode>
+ <leafNode name="rpki-extcommunity">
+ <properties>
+ <help>Match RPKI (Origin Validation State) extended community</help>
+ <completionHelp>
+ <list>invalid notfound valid</list>
+ </completionHelp>
+ <valueHelp>
+ <format>invalid</format>
+ <description>Match invalid entries</description>
+ </valueHelp>
+ <valueHelp>
+ <format>notfound</format>
+ <description>Match notfound entries</description>
+ </valueHelp>
+ <valueHelp>
+ <format>valid</format>
+ <description>Match valid entries</description>
+ </valueHelp>
+ <constraint>
+ <regex>(invalid|notfound|valid)</regex>
+ </constraint>
+ </properties>
+ </leafNode>
<leafNode name="source-vrf">
<properties>
<help>Source vrf</help>
diff --git a/smoketest/scripts/cli/test_policy.py b/smoketest/scripts/cli/test_policy.py
index 8849ee182..58d00c3eb 100755
--- a/smoketest/scripts/cli/test_policy.py
+++ b/smoketest/scripts/cli/test_policy.py
@@ -938,6 +938,12 @@ class TestPolicy(VyOSUnitTestSHIM.TestCase):
'tag': tag,
},
},
+ '7' : {
+ 'action' : 'deny',
+ 'match' : {
+ 'rpki-comm-invalid': '',
+ },
+ },
'10' : {
'action' : 'permit',
'match' : {
@@ -946,6 +952,12 @@ class TestPolicy(VyOSUnitTestSHIM.TestCase):
'rpki-not-found': '',
},
},
+ '12' : {
+ 'action' : 'permit',
+ 'match' : {
+ 'rpki-comm-not-found': '',
+ },
+ },
'15' : {
'action' : 'permit',
'match' : {
@@ -956,6 +968,12 @@ class TestPolicy(VyOSUnitTestSHIM.TestCase):
'next' : '',
},
},
+ '17' : {
+ 'action' : 'permit',
+ 'match' : {
+ 'rpki-comm-valid': '',
+ },
+ },
'20' : {
'action' : 'permit',
'match' : {
@@ -1268,6 +1286,12 @@ class TestPolicy(VyOSUnitTestSHIM.TestCase):
self.cli_set(path + ['rule', rule, 'match', 'rpki', 'notfound'])
if 'rpki-valid' in rule_config['match']:
self.cli_set(path + ['rule', rule, 'match', 'rpki', 'valid'])
+ if 'rpki-comm-invalid' in rule_config['match']:
+ self.cli_set(path + ['rule', rule, 'match', 'rpki-extcommunity', 'invalid'])
+ if 'rpki-comm-not-found' in rule_config['match']:
+ self.cli_set(path + ['rule', rule, 'match', 'rpki-extcommunity', 'notfound'])
+ if 'rpki-comm-valid' in rule_config['match']:
+ self.cli_set(path + ['rule', rule, 'match', 'rpki-extcommunity', 'valid'])
if 'protocol' in rule_config['match']:
self.cli_set(path + ['rule', rule, 'match', 'protocol', rule_config['match']['protocol']])
if 'source-vrf' in rule_config['match']:
@@ -1450,6 +1474,15 @@ class TestPolicy(VyOSUnitTestSHIM.TestCase):
if 'rpki-valid' in rule_config['match']:
tmp = f'match rpki valid'
self.assertIn(tmp, config)
+ if 'rpki-comm-invalid' in rule_config['match']:
+ tmp = f'match rpki-extcommunity invalid'
+ self.assertIn(tmp, config)
+ if 'rpki-comm-not-found' in rule_config['match']:
+ tmp = f'match rpki-extcommunity notfound'
+ self.assertIn(tmp, config)
+ if 'rpki-comm-valid' in rule_config['match']:
+ tmp = f'match rpki-extcommunity valid'
+ self.assertIn(tmp, config)
if 'source-vrf' in rule_config['match']:
tmp = f'match source-vrf {rule_config["match"]["source-vrf"]}'
self.assertIn(tmp, config)