Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,36 @@
},
"STATIC_ROUTE_TEST_NEXTHOP_EMPTY_VRF": {
"desc": "Configure with null value for VRF"
},
"STATIC_ROUTE_TEMPLATE_TEST": {
"desc": "Configure a default-VRF static route using the bare-prefix (template) key"
},
"STATIC_ROUTE_TEMPLATE_TEST_WITH_DISTANCE": {
"desc": "Configure distance on a bare-prefix static route"
},
"STATIC_ROUTE_TEMPLATE_TEST_WITH_BLACKHOLE": {
"desc": "Configure blackhole on a bare-prefix static route"
},
"STATIC_ROUTE_TEMPLATE_TEST_WITH_NEXTHOP_VRF": {
"desc": "Configure nexthop-vrf on a bare-prefix static route"
},
"STATIC_ROUTE_TEMPLATE_TEST_WITH_TAG": {
"desc": "Configure a route tag on a bare-prefix static route"
},
"STATIC_ROUTE_TEST_WITH_TAG": {
"desc": "Configure a route tag on a VRF-qualified static route"
},
"STATIC_ROUTE_TEMPLATE_TEST_DISTANCE_INVALID": {
"desc": "Configure an out-of-range distance on a bare-prefix static route",
"eStrKey": "Pattern"
},
"STATIC_ROUTE_TEMPLATE_TEST_TAG_INVALID": {
"desc": "Configure an out-of-range tag on a bare-prefix static route",
"eStrKey": "Pattern"
},
"STATIC_ROUTE_TEST_TAG_INVALID": {
"desc": "Configure an out-of-range tag on a VRF-qualified static route",
"eStrKey": "Pattern"
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,124 @@
}]
}
}
},
"STATIC_ROUTE_TEMPLATE_TEST": {
"sonic-static-route:sonic-static-route": {
"sonic-static-route:STATIC_ROUTE": {
"STATIC_ROUTE_TEMPLATE_LIST": [
{
"prefix": "100.100.100.0/24",
"nexthop": "10.10.10.1"
}
]
}
}
},
"STATIC_ROUTE_TEMPLATE_TEST_WITH_DISTANCE": {
"sonic-static-route:sonic-static-route": {
"sonic-static-route:STATIC_ROUTE": {
"STATIC_ROUTE_TEMPLATE_LIST": [
{
"prefix": "100.100.101.0/24",
"nexthop": "10.10.10.1",
"distance": "5"
}
]
}
}
},
"STATIC_ROUTE_TEMPLATE_TEST_WITH_BLACKHOLE": {
"sonic-static-route:sonic-static-route": {
"sonic-static-route:STATIC_ROUTE": {
"STATIC_ROUTE_TEMPLATE_LIST": [
{
"prefix": "100.100.102.0/24",
"nexthop": "0.0.0.0",
"blackhole": "true"
}
]
}
}
},
"STATIC_ROUTE_TEMPLATE_TEST_WITH_NEXTHOP_VRF": {
"sonic-static-route:sonic-static-route": {
"sonic-static-route:STATIC_ROUTE": {
"STATIC_ROUTE_TEMPLATE_LIST": [
{
"prefix": "100.100.103.0/24",
"nexthop": "10.10.10.1",
"nexthop-vrf": "default"
}
]
}
}
},
"STATIC_ROUTE_TEMPLATE_TEST_WITH_TAG": {
"sonic-static-route:sonic-static-route": {
"sonic-static-route:STATIC_ROUTE": {
"STATIC_ROUTE_TEMPLATE_LIST": [
{
"prefix": "100.100.105.0/24",
"nexthop": "10.10.10.1",
"tag": "1234"
}
]
}
}
},
"STATIC_ROUTE_TEST_WITH_TAG": {
"sonic-static-route:sonic-static-route": {
"sonic-static-route:STATIC_ROUTE": {
"STATIC_ROUTE_LIST": [
{
"vrf_name": "default",
"prefix": "100.100.106.0/24",
"nexthop": "10.10.10.1",
"tag": "1234"
}
]
}
}
},
"STATIC_ROUTE_TEMPLATE_TEST_DISTANCE_INVALID": {
"sonic-static-route:sonic-static-route": {
"sonic-static-route:STATIC_ROUTE": {
"STATIC_ROUTE_TEMPLATE_LIST": [
{
"prefix": "100.100.107.0/24",
"nexthop": "10.10.10.1",
"distance": "300"
}
]
}
}
},
"STATIC_ROUTE_TEMPLATE_TEST_TAG_INVALID": {
"sonic-static-route:sonic-static-route": {
"sonic-static-route:STATIC_ROUTE": {
"STATIC_ROUTE_TEMPLATE_LIST": [
{
"prefix": "100.100.108.0/24",
"nexthop": "10.10.10.1",
"tag": "99999999999"
}
]
}
}
},
"STATIC_ROUTE_TEST_TAG_INVALID": {
"sonic-static-route:sonic-static-route": {
"sonic-static-route:STATIC_ROUTE": {
"STATIC_ROUTE_LIST": [
{
"vrf_name": "default",
"prefix": "100.100.109.0/24",
"nexthop": "10.10.10.1",
"tag": "99999999999"
}
]
}
}
}

}
Expand Down
67 changes: 64 additions & 3 deletions src/sonic-yang-models/yang-models/sonic-static-route.yang
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ module sonic-static-route {
description
"STATIC ROUTE yang Module for SONiC OS";

revision 2026-07-21 {
description
"Align STATIC_ROUTE_TEMPLATE_LIST with STATIC_ROUTE_LIST (distance, nexthop-vrf, blackhole)
and add the route tag attribute to both lists.";
}

revision 2022-03-17 {
description
"First Revision";
Expand Down Expand Up @@ -47,6 +53,48 @@ module sonic-static-route {
default "false";
description "Advertise this static route to BGP, comma-separated per nexthop.";
}
leaf distance {
type string {
pattern "((25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?),)*(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)";
}
default "0";
description
"Administrative Distance (preference) of the entry. The
preference defines the order of selection when multiple
sources (protocols, static, etc.) contribute to the same
prefix entry. The lower the preference, the more preferable the
prefix is. When this value is not specified, the preference is
inherited from the default preference of the implementation for
static routes. Comma-separated list with one entry per nexthop.";
}
leaf nexthop-vrf {
type string {
pattern "((((Vrf[a-zA-Z0-9_-]+)|(default)|(mgmt)),)*((Vrf[a-zA-Z0-9_-]+)|(default)|(mgmt)))?";
}
description
"VRF name of the nexthop, used for VRF leaking. Comma-separated list with one
entry per nexthop.";
}
leaf blackhole {
type string {
pattern "((true|false),)*(true|false)";
}
default "false";
description
"blackhole refers to a route that, if matched, discards the message silently.
Comma-separated list with one entry per nexthop.";
}
leaf tag {
type string {
pattern "(0|[1-9][0-9]{0,9})(,(0|[1-9][0-9]{0,9}))*";
}
default "0";
description
"Route tag applied to the static route (0-4294967295), comma-separated for multiple nexthops.
Value 0 means no tag is applied. Matches the FRR `tag (1-4294967295)` static-route parameter,
with 0 reserved to express the absence of a tag.
Note: Pattern allows up to 10 digits; values above 4294967295 will be rejected by application logic.";
}
leaf bfd {
type string {
pattern "((true|false),)*(true|false)";
Expand Down Expand Up @@ -108,22 +156,35 @@ module sonic-static-route {
prefix entry. The lower the preference, the more preferable the
prefix is. When this value is not specified, the preference is
inherited from the default preference of the implementation for
static routes.";
static routes. Comma-separated list with one entry per nexthop.";
}
leaf nexthop-vrf {
type string {
pattern "((((Vrf[a-zA-Z0-9_-]+)|(default)|(mgmt)),)*((Vrf[a-zA-Z0-9_-]+)|(default)|(mgmt)))?";
}
description
"VRF name of the nexthop. This is for vrf leaking";
"VRF name of the nexthop, used for VRF leaking. Comma-separated list with one
entry per nexthop.";
}
leaf blackhole {
type string {
pattern "((true|false),)*(true|false)";
}
default "false";
description
"blackhole refers to a route that, if matched, discards the message silently.";
"blackhole refers to a route that, if matched, discards the message silently.
Comma-separated list with one entry per nexthop.";
}
leaf tag {
type string {
pattern "(0|[1-9][0-9]{0,9})(,(0|[1-9][0-9]{0,9}))*";
}
default "0";
description
"Route tag applied to the static route (0-4294967295), comma-separated for multiple nexthops.
Value 0 means no tag is applied. Matches the FRR `tag (1-4294967295)` static-route parameter,
with 0 reserved to express the absence of a tag.
Note: Pattern allows up to 10 digits; values above 4294967295 will be rejected by application logic.";
}
} /* end of list STATIC_ROUTE_LIST */
} /* end of container STATIC_ROUTE */
Expand Down
Loading