Skip to content

feat(iosxr): Implement Route Policies - #467

Open
sven-rosenzweig wants to merge 1 commit into
mainfrom
feat/routing_policies
Open

feat(iosxr): Implement Route Policies#467
sven-rosenzweig wants to merge 1 commit into
mainfrom
feat/routing_policies

Conversation

@sven-rosenzweig

Copy link
Copy Markdown
Contributor

Compared with OpenConfig and Cisco NX-OS, IOS-XR-based route policies are more powerful and feature-rich. However, we currently do not need most of these advanced features. Instead, we adapt to the simpler route-map configuration model (sequence, condition, action, and disposition).

Route maps work by iterating over each entry in order of their sequence number. If a condition matches, the configured action is executed and processing stops after a match is found. The default action when no match is found is to pass.

We assume the same behavior with route policies: after each condition check, we set the policy result to "done" (which stops processing and accepts the route) or "drop" (which stops processing and rejects the route). At the end, if no match is found, the route is accepted by default.

Some key aspects that make Route Policies richer than route maps:

  • Support for if/else control flow
  • Referencing other RPLs within each other, creating nested blocks of policy logic
  • Boolean operators (and, not, or)
  • Parameterized route policy configuration
  • Wildcard support in setting values

Yang support for Cisco IOS XR route policy support also differs from other OS models. It simply accepts one single policy string, being correctly formatted in the way mentioned above:

route-policy <name>
  if <sample statement> then
     set <sample set action>
     done
  endif
end-policy

https://github.com/YangModels/yang/blob/ad7aa9d483c592661c1df3d38bdfc99dc01cba56/vendor/cisco/xr/2522/Cisco-IOS-XR-um-route-policy-cfg.yang#L81-L94

@sven-rosenzweig
sven-rosenzweig force-pushed the feat/routing_policies branch 2 times, most recently from 2a2e616 to 49935ee Compare July 27, 2026 10:07
Compared with OpenConfig and Cisco NX-OS, IOS-XR-based route policies are more
powerful and feature-rich. However, we currently do not need most of these
advanced features. Instead, we adapt to the simpler route-map configuration
model (sequence, condition, action, and disposition).

Route maps work by iterating over each entry in order of their sequence number.
If a condition matches, the configured action is executed and processing stops
after a match is found. The default action when no match is found is to pass.

We assume the same behavior with route policies: after each condition check, we
set the policy result to "done" (which stops processing and accepts the route)
or "drop" (which stops processing and rejects the route). At the end, if no
match is found, the route is accepted by default.

Some key aspects that make Route Policies richer than route maps:
* Support for if/else control flow
* Referencing other RPLs within each other, creating nested blocks of
  policy logic
* Boolean operators (and, not, or)
* Parameterized route policy configuration
* Wildcard support in setting values

Yang support for Cisco IOS XR route policy support also differs from other OS models.
It simply accepts one single policy string, being correctly formatted in
the way mentioned above:
```
route-policy <name>
  if <sample statement> then
     set <sample set action>
     done
  endif
end-policy
```

https://github.com/YangModels/yang/blob/ad7aa9d483c592661c1df3d38bdfc99dc01cba56/vendor/cisco/xr/2522/Cisco-IOS-XR-um-route-policy-cfg.yang#L81-L94

Signed-off-by: Sven Rosenzweig <sven.rosenzweig@sap.com>
@sven-rosenzweig
sven-rosenzweig force-pushed the feat/routing_policies branch from 49935ee to a8eda25 Compare July 27, 2026 10:17
@github-actions

Copy link
Copy Markdown

Merging this branch will increase overall coverage

Impacted Packages Coverage Δ 🤖
github.com/ironcore-dev/network-operator/internal/provider/cisco/iosxr 44.96% (+8.89%) 👍

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/ironcore-dev/network-operator/internal/provider/cisco/iosxr/provider.go 21.96% (-0.74%) 214 (+7) 47 167 (+7) 👎
github.com/ironcore-dev/network-operator/internal/provider/cisco/iosxr/route_policies.go 73.87% (+73.87%) 111 (+108) 82 (+82) 29 (+26) 🌟

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files

  • github.com/ironcore-dev/network-operator/internal/provider/cisco/iosxr/route_policies_test.go

@sven-rosenzweig
sven-rosenzweig marked this pull request as ready for review July 27, 2026 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant