confd: add support for setting preference on static routes

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2024-09-26 15:49:45 +02:00
parent dd3f1c39d1
commit 752b1f4a94
3 changed files with 48 additions and 4 deletions
+5 -3
View File
@@ -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;
}
+1 -1
View File
@@ -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"
@@ -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;