Skip to content

Conversation

@niallmasterson
Copy link

@niallmasterson niallmasterson commented Dec 3, 2025

Add rib-has-route condition to openconfig-routing-policy

Change Scope

  • Add support for the "rib-has-route" route-policy condition which will check if a route exists in the routing-table. Multiple vendors support this capability which is used for conditional route-advertisements, i.e. the route-policy condition checks if a certain prefix A exists in the routing table, and if so then advertises another prefix B or a default-route.

Platform Implementations

  • Cisco IOS-XR - rib-has-route

https://www.cisco.com/c/en/us/td/docs/iosxr/cisco8000/routing/cumulative/command/reference/b-routing-cr-cisco8000/m-rpl-commands-1.html#wp4036312080

prefix-set PREFIX-TO-TRACK                                                                                                    
  10.10.10.0/24                                                                                                               
end-set                                                                                                                       
! 
route-policy CONDITIONAL-ADVERTISEMENT
  if rib-has-route in PREFIX-TO-TRACK then
    done
  endif
  drop
end-policy
dynamic prefix-list DPL
  match-map PREFIX-TO-CHECK
  prefix-list ipv4 ADV-THIS-PREFIX
!
route-map PREFIX-TO-CHECK permit 10
  match ip address prefix-list PREFIX-TO-TRACK
!
ip prefix-list PREFIX-TO-TRACK seq 10 permit 10.10.10.0/24

ip prefix-list ADV-THIS-PREFIX seq 10 permit 10.20.20.0/24
!
route-map OUTBOUND-POLICY permit 10
  match ip address dynamic prefix-list DPL
policy-options {
    prefix-list ADV-THIS-PREFIX {
        10.20.20.0/24;
    }
    policy-statement OUTBOUND-POLICY {
        term CONDITIONAL-ADVERTISE {
            from {
                prefix-list ADV-THIS-PREFIX;
                condition CHECK-TRACK-ROUTE;
            }                           
            then accept;
        }
    }
    condition CHECK-TRACK-ROUTE {
        if-route-exists {
            10.10.10.0/24;
            table inet.0;
        }
    }
}

Tree View

 module: openconfig-routing-policy
               +--rw statement* [name]
                  +--rw name          -> ../config/name
                  +--rw config
                  |  +--rw name?   string
                  +--ro state
                  |  +--ro name?   string
                  +--rw conditions
                  |  +--rw config
                  |  |  +--rw call-policy?           -> ../../../../../../../policy-definitions/policy-definition/name
                  |  |  +--rw install-protocol-eq?   identityref
                  |  +--ro state
                  |  |  +--ro call-policy?           -> ../../../../../../../policy-definitions/policy-definition/name
                  |  |  +--ro install-protocol-eq?   identityref
                  |  +--rw match-interface
                  |  |  +--rw config
                  |  |  +--ro state
                  |  +--rw match-prefix-set
                  |  |  +--rw config
                  |  |  |  +--rw prefix-set?          -> ../../../../../../../../defined-sets/prefix-sets/prefix-set/config/name
                  |  |  |  +--rw match-set-options?   oc-pol-types:match-set-options-restricted-type
                  |  |  +--ro state
                  |  |     +--ro prefix-set?          -> ../../../../../../../../defined-sets/prefix-sets/prefix-set/config/name
                  |  |     +--ro match-set-options?   oc-pol-types:match-set-options-restricted-type
+                 |  +--rw match-rib-has-route
+                 |  |  +--rw config
+                 |  |  |  +--rw prefix-set?          -> ../../../../../../../../defined-sets/prefix-sets/prefix-set/config/name
+                 |  |  |  +--rw match-set-options?   oc-pol-types:match-set-options-restricted-type
+                 |  |  +--ro state
+                 |  |     +--ro prefix-set?          -> ../../../../../../../../defined-sets/prefix-sets/prefix-set/config/name
+                 |  |     +--ro match-set-options?   oc-pol-types:match-set-options-restricted-type
                  |  +--rw match-neighbor-set
                  |  |  +--rw config
                  |  |  |  +--rw neighbor-set?        -> ../../../../../../../../defined-sets/neighbor-sets/neighbor-set/name
                  |  |  |  +--rw match-set-options?   oc-pol-types:match-set-options-restricted-type
                  |  |  +--ro state
                  |  |     +--ro neighbor-set?        -> ../../../../../../../../defined-sets/neighbor-sets/neighbor-set/name
                  |  |     +--ro match-set-options?   oc-pol-types:match-set-options-restricted-type
                  |  +--rw match-tag-set
                  |     +--rw config
                  |     |  +--rw tag-set?             -> ../../../../../../../../defined-sets/tag-sets/tag-set/name
                  |     |  +--rw match-set-options?   oc-pol-types:match-set-options-restricted-type
                  |     +--ro state
                  |        +--ro tag-set?             -> ../../../../../../../../defined-sets/tag-sets/tag-set/name
                  |        +--ro match-set-options?   oc-pol-types:match-set-options-restricted-type
                  +--rw actions
                     +--rw config
                     |  +--rw policy-result?   policy-result-type
                     +--ro state
                     |  +--ro policy-result?   policy-result-type
                     +--rw set-tag
                        +--rw config

@niallmasterson niallmasterson requested a review from a team as a code owner December 3, 2025 15:00
@niallmasterson niallmasterson changed the title Add rib-has-route condition to openconfig-routing-policy.yang Add rib-has-route condition to openconfig-routing-policy Dec 3, 2025
@jhaas-pfrc
Copy link

Note: At least one implementation has a limitation that the "prefix-set" has exactly one entry. The documentation for one of the other implementations similarly seems to indicate the same restriction.

@niallmasterson
Copy link
Author

Note: At least one implementation has a limitation that the "prefix-set" has exactly one entry. The documentation for one of the other implementations similarly seems to indicate the same restriction.

In the case where the vendor can only support a prefix-set with one entry, they could potentially create multiple conditions to implement the OC intent. i.e. for each entry in the prefix-set create a condition/term. Juniper for example doesn't actually use a prefix-set for the prefix to track. Instead a single prefix is specified under the condition config. So if you wanted to track multiple prefixes with a "match-any", you could create multiple conditions and terms. e.g.

prefix-list ADV-THIS-PREFIX {
    10.20.20.0/24;
}
policy-statement OUTBOUND-POLICY {
    term CONDITIONAL-ADVERTISE {
        from {
            prefix-list ADV-THIS-PREFIX;
            condition CHECK-TRACK-ROUTE;
        }
        then accept;
    }
    term CONDITIONAL-ADVERTISE-1 {
        from {
            prefix-list ADV-THIS-PREFIX;
            condition CHECK-TRACK-ROUTE-1;
        }
        then accept;
    }
}
condition CHECK-TRACK-ROUTE {
    if-route-exists {
        10.10.10.0/24;
        table inet.0;
    }
}
condition CHECK-TRACK-ROUTE-1 {
    if-route-exists {
        20.20.20.0/24;
        table inet.0;
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants