diff options
| author | aapostoliuk <a.apostoliuk@vyos.io> | 2025-02-26 22:02:09 +0200 | 
|---|---|---|
| committer | aapostoliuk <a.apostoliuk@vyos.io> | 2025-02-26 22:02:09 +0200 | 
| commit | 757fb7c27ed94e67af1e790722f27d55199fe3cc (patch) | |
| tree | 6f35975baced7f2457939812fdda8bf85cf8efda | |
| parent | 4ce3b92f92739570233928980622d97220ffce71 (diff) | |
| download | vyos-1x-757fb7c27ed94e67af1e790722f27d55199fe3cc.tar.gz vyos-1x-757fb7c27ed94e67af1e790722f27d55199fe3cc.zip  | |
policy: T7158: Added match source-vrf to route-map
Added match source-vrf to route-map
| -rw-r--r-- | data/templates/frr/policy.frr.j2 | 3 | ||||
| -rw-r--r-- | interface-definitions/policy.xml.in | 14 | ||||
| -rwxr-xr-x | smoketest/scripts/cli/test_policy.py | 15 | 
3 files changed, 32 insertions, 0 deletions
diff --git a/data/templates/frr/policy.frr.j2 b/data/templates/frr/policy.frr.j2 index ed5876ae9..c28633f6f 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.source_vrf is vyos_defined %} + match source-vrf {{ rule_config.match.source_vrf }} +{%                     endif %}  {%                     if rule_config.match.tag is vyos_defined %}   match tag {{ rule_config.match.tag }}  {%                     endif %} diff --git a/interface-definitions/policy.xml.in b/interface-definitions/policy.xml.in index cbab6173f..faba91ef0 100644 --- a/interface-definitions/policy.xml.in +++ b/interface-definitions/policy.xml.in @@ -1096,6 +1096,20 @@                        </constraint>                      </properties>                    </leafNode> +                  <leafNode name="source-vrf"> +                    <properties> +                      <help>Source vrf</help> +                      #include <include/constraint/vrf.xml.i> +                      <valueHelp> +                        <format>txt</format> +                        <description>VRF instance name</description> +                      </valueHelp> +                      <completionHelp> +                        <path>vrf name</path> +                        <list>default</list> +                      </completionHelp> +                    </properties> +                  </leafNode>                    #include <include/policy/tag.xml.i>                  </children>                </node> diff --git a/smoketest/scripts/cli/test_policy.py b/smoketest/scripts/cli/test_policy.py index 9d4fc0845..985097726 100755 --- a/smoketest/scripts/cli/test_policy.py +++ b/smoketest/scripts/cli/test_policy.py @@ -1149,6 +1149,16 @@ class TestPolicy(VyOSUnitTestSHIM.TestCase):                      },                  },              }, +            'vrf-match': { +                'rule': { +                    '10': { +                        'action': 'permit', +                        'match': { +                            'source-vrf': 'TEST', +                        }, +                    }, +                }, +            },          }          self.cli_set(['policy', 'access-list', access_list, 'rule', '10', 'action', 'permit']) @@ -1260,6 +1270,8 @@ class TestPolicy(VyOSUnitTestSHIM.TestCase):                          self.cli_set(path + ['rule', rule, 'match', 'rpki', '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']: +                        self.cli_set(path + ['rule', rule, 'match', 'source-vrf', rule_config['match']['source-vrf']])                      if 'tag' in rule_config['match']:                          self.cli_set(path + ['rule', rule, 'match', 'tag', rule_config['match']['tag']]) @@ -1438,6 +1450,9 @@ class TestPolicy(VyOSUnitTestSHIM.TestCase):                      if 'rpki-valid' in rule_config['match']:                          tmp = f'match rpki 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)                      if 'tag' in rule_config['match']:                          tmp = f'match tag {rule_config["match"]["tag"]}'                          self.assertIn(tmp, config)  | 
