From 0c0e73045b1898610eef9309b9f5927254356710 Mon Sep 17 00:00:00 2001 From: Rafael Zalamena Date: Fri, 27 Sep 2019 19:32:10 -0300 Subject: [PATCH] yang: update route map model Important changes: * Rename top container `route-map` to `lib`; * Rename list `instance` to `route-map`; * Move route map repeated data to list `entry`; * Use interface reference instead of typedef'ed string; * Remove some zebra specific route map conditions; * Protect `tag` set value with `when "./action = 'tag'"`; Signed-off-by: Rafael Zalamena --- yang/frr-route-map.yang | 565 +++++++++++++++++++--------------------- 1 file changed, 272 insertions(+), 293 deletions(-) diff --git a/yang/frr-route-map.yang b/yang/frr-route-map.yang index 0ce40b474b..34a7e28a77 100644 --- a/yang/frr-route-map.yang +++ b/yang/frr-route-map.yang @@ -9,6 +9,9 @@ module frr-route-map { import frr-filter { prefix filter; } + import frr-interface { + prefix frr-interface; + } organization "Free Range Routing"; contact @@ -38,367 +41,343 @@ module frr-route-map { /* * Operational data. */ - container route-map { - list instance { + container lib { + list route-map { description "Route map instance"; - key "name sequence"; + key "name"; leaf name { description "Route map instance name"; type route-map-name; } - leaf sequence { - description - "Route map instance priority (low number means higher priority)"; - type route-map-sequence; - } + list entry { + description "Route map entry"; - leaf description { - description "Route map description"; - type string; - } + key "sequence"; - leaf action { - description - "Route map actions: permit (executes action), deny (quits evaluation)"; - mandatory true; - type enumeration { - enum permit { - description - "Executes configured action and permits the prefix/route - if the conditions matched. An alternative exit action can - be configured to continue processing the route map list - or jump to process another route map."; - value 0; - } - enum deny { - description - "If all conditions are met the prefix/route is denied and - route map processing stops."; - value 1; - } + leaf sequence { + description + "Route map instance priority (low number means higher priority)"; + type route-map-sequence; } - } - - list match-condition { - description "Route map match conditions"; - key "condition"; + leaf description { + description "Route map description"; + type string; + } - leaf condition { - description "Match condition"; + leaf action { + description + "Route map actions: permit (executes action), deny (quits evaluation)"; + mandatory true; type enumeration { - enum interface { - description "Match interface"; + enum permit { + description + "Executes configured action and permits the prefix/route + if the conditions matched. An alternative exit action can + be configured to continue processing the route map list + or jump to process another route map."; value 0; } - enum ipv4-address-list { - description "Match an IPv4 access-list"; + enum deny { + description + "If all conditions are met the prefix/route is denied and + route map processing stops."; value 1; } - enum ipv4-prefix-list { - description "Match an IPv4 prefix-list"; - value 2; - } - enum ipv4-prefix-length { - description "Match an IPv4 prefix length"; - value 3; - } - enum ipv4-next-hop-list { - description "Match an IPv4 next-hop"; - value 4; - } - enum ipv4-next-hop-prefix-list { - description "Match an IPv4 next-hop prefix list"; - value 5; - } - enum ipv4-next-hop-prefix-length { - description "Match an IPv4 next-hop prefix length"; - value 6; - } - enum ipv4-next-hop-type { - description "Match an IPv4 next-hop type"; - value 7; - } - enum ipv6-address-list { - description "Match an IPv6 access-list"; - value 8; - } - enum ipv6-prefix-list { - description "Match an IPv6 prefix-list"; - value 9; - } - enum ipv6-prefix-length { - description "Match an IPv6 prefix length"; - value 10; - } - enum ipv6-next-hop { - description "Match an IPv6 next-hop"; - value 11; - } - enum ipv6-next-hop-type { - description "Match an IPv6 next-hop type"; - value 12; - } - enum metric { - description "Match a route metric"; - value 13; + } + } + + leaf call { + description + "Call another route map before calling `exit-policy`. If the + called route map returns deny then this route map will also + return deny"; + type route-map-name; + } + + leaf exit-policy { + description "What do to after route map successful match, set and call"; + type enumeration { + enum permit-or-deny { + description "End route map evaluation and return"; + value 0; } - enum tag { - description "Match a route tag"; - value 14; + enum next { + description + "Proceed evaluating next route map entry per sequence"; + value 1; } - - /* - * Protocol YANG models should augment the parent node to - * contain the routing protocol specific value. The protocol - * must also augment `condition-value` to include its specific - * values or expand the `when` statement on the existing cases. - */ - enum routing-protocol-specific { - description "Match a routing protocol specific type"; - value 100; + enum goto { + description + "Go to route map entry with the provided sequence number"; + value 2; } } + default "permit-or-deny"; } - choice condition-value { + leaf goto-value { + when "../exit-policy = 'goto'"; description - "Value to match (interpretation depends on condition type)"; - case access-list-num { - when "./condition = 'ipv4-address-list' or - ./condition = 'ipv4-next-hop-list'"; - leaf access-list-num { - type filter:access-list-standard; - } - } - case access-list-num-extended { - when "./condition = 'ipv4-address-list' or - ./condition = 'ipv4-next-hop-list'"; - leaf access-list-num-extended { - type filter:access-list-extended; + "Sequence number to jump (when using `goto` exit policy)"; + mandatory true; + type route-map-sequence; + } + + list match-condition { + description "Route map match conditions"; + + key "condition"; + + leaf condition { + description "Match condition"; + type enumeration { + enum interface { + description "Match interface"; + value 0; + } + enum ipv4-address-list { + description "Match an IPv4 access-list"; + value 1; + } + enum ipv4-prefix-list { + description "Match an IPv4 prefix-list"; + value 2; + } + enum ipv4-next-hop-list { + description "Match an IPv4 next-hop"; + value 3; + } + enum ipv4-next-hop-prefix-list { + description "Match an IPv4 next-hop prefix list"; + value 4; + } + enum ipv4-next-hop-type { + description "Match an IPv4 next-hop type"; + value 5; + } + enum ipv6-address-list { + description "Match an IPv6 access-list"; + value 6; + } + enum ipv6-prefix-list { + description "Match an IPv6 prefix-list"; + value 7; + } + enum ipv6-next-hop-type { + description "Match an IPv6 next-hop type"; + value 8; + } + enum metric { + description "Match a route metric"; + value 9; + } + enum tag { + description "Match a route tag"; + value 10; + } + + /* + * Protocol YANG models should augment the parent node to + * contain the routing protocol specific value. The protocol + * must also augment `condition-value` to include its specific + * values or expand the `when` statement on the existing cases. + */ + enum routing-protocol-specific { + description "Match a routing protocol specific type"; + value 100; + } } } - case list-name { - when "./condition = 'ipv4-address-list' or - ./condition = 'ipv4-prefix-list' or - ./condition = 'ipv4-next-hop-list' or - ./condition = 'ipv4-next-hop-prefix-list' or - ./condition = 'ipv6-address-list' or - ./condition = 'ipv6-prefix-list'"; - leaf list-name { - type filter:access-list-name; + + choice condition-value { + description + "Value to match (interpretation depends on condition type)"; + mandatory true; + case interface { + when "./condition = 'interface'"; + leaf interface { + type frr-interface:interface-ref; + } } - } - case ipv6-address { - when "./condition = 'ipv6-next-hop'"; - leaf ipv6-address { - type inet:ipv6-address; + case access-list-num { + when "./condition = 'ipv4-address-list' or + ./condition = 'ipv4-next-hop-list'"; + leaf access-list-num { + type filter:access-list-standard; + } } - } - case ipv4-prefix-length { - when "./condition = 'ipv4-prefix-length' or - ./condition = 'ipv4-next-hop-prefix-length'"; - leaf ipv4-prefix-length { - type uint8 { - range "0..32"; + case access-list-num-extended { + when "./condition = 'ipv4-address-list' or + ./condition = 'ipv4-next-hop-list'"; + leaf access-list-num-extended { + type filter:access-list-extended; } } - } - case ipv6-prefix-length { - when "./condition = 'ipv6-prefix-length'"; - leaf ipv6-prefix-length { - type uint8 { - range "0..128"; + case list-name { + when "./condition = 'ipv4-address-list' or + ./condition = 'ipv4-prefix-list' or + ./condition = 'ipv4-next-hop-list' or + ./condition = 'ipv4-next-hop-prefix-list' or + ./condition = 'ipv6-address-list' or + ./condition = 'ipv6-prefix-list'"; + leaf list-name { + type filter:access-list-name; } } - } - case ipv4-next-hop-type { - when "./condition = 'ipv4-next-hop-type'"; - leaf ipv4-next-hop-type { - type enumeration { - enum blackhole { - value 0; + case ipv4-next-hop-type { + when "./condition = 'ipv4-next-hop-type'"; + leaf ipv4-next-hop-type { + type enumeration { + enum blackhole { + value 0; + } } } } - } - case ipv6-next-hop-type { - when "./condition = 'ipv6-next-hop-type'"; - leaf ipv6-next-hop-type { - type enumeration { - enum blackhole { - value 0; + case ipv6-next-hop-type { + when "./condition = 'ipv6-next-hop-type'"; + leaf ipv6-next-hop-type { + type enumeration { + enum blackhole { + value 0; + } } } } - } - case metric { - when "./condition = 'metric'"; - leaf metric { - type uint32 { - range "1..4294967295"; + case metric { + when "./condition = 'metric'"; + leaf metric { + type uint32 { + range "1..4294967295"; + } } } - } - case tag { - when "./condition = 'tag'"; - leaf tag { - type uint32 { - range "1..4294967295"; + case tag { + when "./condition = 'tag'"; + leaf tag { + type uint32 { + range "1..4294967295"; + } } } } } - } - list set-action { - description "Route map set actions"; + list set-action { + description "Route map set actions"; - key "action"; + key "action"; - leaf action { - description "Action to do when the route map matches"; - type enumeration { - enum ipv4-next-hop { - description "Set IPv4 address of the next hop"; - value 0; - } - enum ipv6-next-hop { - description "Set IPv6 address of the next hop"; - value 1; - } - enum metric { - description "Set prefix/route metric"; - value 2; - } - enum tag { - description "Set tag"; - value 3; - } + leaf action { + description "Action to do when the route map matches"; + type enumeration { + enum ipv4-next-hop { + description "Set IPv4 address of the next hop"; + value 0; + } + enum ipv6-next-hop { + description "Set IPv6 address of the next hop"; + value 1; + } + enum metric { + description "Set prefix/route metric"; + value 2; + } + enum tag { + description "Set tag"; + value 3; + } - /* - * Protocol YANG models should augment the parent node to - * contain the routing protocol specific value. The protocol - * must also augment `action-value` to include its specific - * values or expand the `when` statement on the existing cases. - */ - enum routing-protocol-specific { - description "Set a routing protocol specific action"; - value 100; + /* + * Protocol YANG models should augment the parent node to + * contain the routing protocol specific value. The protocol + * must also augment `action-value` to include its specific + * values or expand the `when` statement on the existing cases. + */ + enum routing-protocol-specific { + description "Set a routing protocol specific action"; + value 100; + } } } - } - choice action-value { - description - "Value to set (interpretation depends on action-type)"; - case ipv4-address { - when "./action = 'ipv4-next-hop'"; - leaf ipv4-address { - description "IPv4 address"; - type inet:ipv4-address; + choice action-value { + description + "Value to set (interpretation depends on action-type)"; + case ipv4-address { + when "./action = 'ipv4-next-hop'"; + leaf ipv4-address { + description "IPv4 address"; + type inet:ipv4-address; + } } - } - case ipv6-address { - when "./action = 'ipv6-next-hop'"; - leaf ipv6-address { - description "IPv6 address"; - type inet:ipv6-address; + case ipv6-address { + when "./action = 'ipv6-next-hop'"; + leaf ipv6-address { + description "IPv6 address"; + type inet:ipv6-address; + } } - } - case metric { - when "./action = 'metric'"; - choice metric-value { - description "Metric to set or use"; - case value { - leaf value { - description "Use the following metric value"; - type uint32 { - range "0..4294967295"; + case metric { + when "./action = 'metric'"; + choice metric-value { + description "Metric to set or use"; + case value { + leaf value { + description "Use the following metric value"; + type uint32 { + range "0..4294967295"; + } } } - } - case add-metric { - leaf add-metric { - description "Add unit to metric"; - type boolean; + case add-metric { + leaf add-metric { + description "Add unit to metric"; + type boolean; + } } - } - case subtract-metric { - leaf subtract-metric { - description "Subtract unit from metric"; - type boolean; + case subtract-metric { + leaf subtract-metric { + description "Subtract unit from metric"; + type boolean; + } } - } - case use-round-trip-time { - leaf use-round-trip-time { - description "Use the round trip time as metric"; - type boolean; + case use-round-trip-time { + leaf use-round-trip-time { + description "Use the round trip time as metric"; + type boolean; + } } - } - case add-round-trip-time { - leaf add-round-trip-time { - description "Add round trip time to metric"; - type boolean; + case add-round-trip-time { + leaf add-round-trip-time { + description "Add round trip time to metric"; + type boolean; + } } - } - case subtract-round-trip-time { - leaf subtract-round-trip-time { - description "Subtract round trip time to metric"; - type boolean; + case subtract-round-trip-time { + leaf subtract-round-trip-time { + description "Subtract round trip time to metric"; + type boolean; + } } } } - } - case tag { - leaf tag { - description "Tag value"; - type uint32 { - range "0..4294967295"; + case tag { + when "./action = 'tag'"; + leaf tag { + description "Tag value"; + type uint32 { + range "0..4294967295"; + } } } } } } - - leaf call { - description - "Call another route map before calling `exit-policy`. If the - called route map returns deny then this route map will also - return deny"; - type string; - } - - leaf exit-policy { - description "What do to after route map successful match, set and call"; - type enumeration { - enum permit-or-deny { - description "End route map evaluation and return"; - value 0; - } - enum next { - description - "Proceed evaluating next route map entry per sequence"; - value 1; - } - enum goto { - description - "Go to route map entry with the provided sequence number"; - value 2; - } - } - default "permit-or-deny"; - } - - leaf goto-value { - when "../exit-policy = 'goto'"; - description - "Sequence number to jump (when using `goto` exit policy)"; - type route-map-sequence; - } } } } -- 2.39.5