diff --git a/src/confd/src/ietf-routing.c b/src/confd/src/ietf-routing.c index e5ec4cfe..46e0cc2b 100644 --- a/src/confd/src/ietf-routing.c +++ b/src/confd/src/ietf-routing.c @@ -187,12 +187,14 @@ debug ospf nssa\n\ return 0; } -static int parse_route(struct lyd_node *parent, FILE *fp, char *ip) +static int parse_route(struct lyd_node *parent, FILE *fp, const char *ip) { - const char *outgoing_interface, *next_hop_address, *special_next_hop, *destination_prefix; + const char *outgoing_interface, *next_hop_address, *special_next_hop, + *destination_prefix, *route_preference; struct lyd_node *next_hop; destination_prefix = lydx_get_cattr(parent, "destination-prefix"); + route_preference = lydx_get_cattr(parent, "route-preference"); next_hop = lydx_get_child(parent, "next-hop"); outgoing_interface = lydx_get_cattr(next_hop, "outgoing-interface"); next_hop_address = lydx_get_cattr(next_hop, "next-hop-address"); @@ -211,7 +213,7 @@ static int parse_route(struct lyd_node *parent, FILE *fp, char *ip) fputs("reject", fp); else if (strcmp(special_next_hop, "receive") == 0) fputs("Null0", fp); - fputs("\n", fp); + fprintf(fp, " %s\n", route_preference); return SR_ERR_OK; } diff --git a/src/confd/yang/confd.inc b/src/confd/yang/confd.inc index 539e5bd6..d2091178 100644 --- a/src/confd/yang/confd.inc +++ b/src/confd/yang/confd.inc @@ -27,7 +27,7 @@ MODULES=( "ieee802-dot1q-types@2022-10-29.yang" "infix-ip@2024-09-16.yang" "infix-if-type@2024-01-29.yang" - "infix-routing@2024-09-22.yang" + "infix-routing@2024-09-23.yang" "ieee802-dot1ab-lldp@2022-03-15.yang" "infix-lldp@2023-08-23.yang" "infix-dhcp-client@2024-09-20.yang" diff --git a/src/confd/yang/infix-routing@2024-09-22.yang b/src/confd/yang/infix-routing@2024-09-23.yang similarity index 93% rename from src/confd/yang/infix-routing@2024-09-22.yang rename to src/confd/yang/infix-routing@2024-09-23.yang index b8b9f3b7..1f1f633b 100644 --- a/src/confd/yang/infix-routing@2024-09-22.yang +++ b/src/confd/yang/infix-routing@2024-09-23.yang @@ -22,6 +22,14 @@ module infix-routing { prefix rt-types; } + organization "KernelKit"; + contact "kernelkit@googlegroups.com"; + description "Deviations and augments for ietf-routing and ietf-ospf."; + + revision 2024-09-23 { + description "Augment static routes with optional route-preference (distance)."; + reference "internal"; + } revision 2024-09-22 { description "- Enable OSPF route metrics in RIB - Enable 'active' route flag for RIB @@ -119,12 +127,46 @@ module infix-routing { } /* Static routes */ + typedef distance { + description "Capped IETF route-preference, 0-255, for distance."; + type rt:route-preference { + range "0..255"; + } + } + + grouping route-pref { + leaf route-preference { + description "Adjust preference between routes of same destination prefix. + + This attribute, also known as 'administrative distance', allows + for selecting the preferred route among routes with the same + destination prefix. A smaller value indicates a route that is + more preferred."; + type distance; + } + } + deviation "/rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/rt:static-routes/v4ur:ipv4/v4ur:route/v4ur:next-hop/v4ur:next-hop-options/v4ur:next-hop-list" { deviate not-supported; } deviation "/rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/rt:static-routes/v6ur:ipv6/v6ur:route/v6ur:next-hop/v6ur:next-hop-options/v6ur:next-hop-list" { deviate not-supported; } + augment "/rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/rt:static-routes/v4ur:ipv4/v4ur:route" { + uses route-pref { + refine route-preference { + default "1"; + } + } + } + augment "/rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/rt:static-routes/v6ur:ipv6/v6ur:route" { + uses route-pref { + refine route-preference { + default "1"; + } + } + } + /* show routes */ deviation "/rt:routing/rt:ribs/rt:rib/rt:default-rib" { deviate not-supported;