Skip to content

Commit 98bfebd

Browse files
authored
[YANG][Bugfix] Fix incorrect pattern of nexthop-vrf in sonic-static-route.yang (#21642)
#### Why I did it Fix issue #21352 According to the Static Route HLD, the nexthop-vrf field should be optional: <pre> ;Defines IP static route table ; ;Status: stable key = STATIC_ROUTE|vrf-name|prefix ; vrf-name = 1\*15VCHAR ; VRF name prefix = IPv4Prefix / IPv6prefix nexthop = string; List of gateway addresses; ifname = string; List of interfaces distance = string; {0..255};List of distances. Its a Metric used to specify preference of next-hop if this distance is not set, default value 0 will be set when this field is not configured for nexthop(s) nexthop-vrf = string; list of next-hop VRFs. It should be set only if ifname or nexthop IP is not in the current VRF . The value is set to VRF name to which the interface or nexthop IP belongs for route leaks. blackhole = string; List of boolean; true if the next-hop route is blackholed. Default value false will be set when this field is not configured for nexthop(s) </pre> However, in the sonic-static-route.yang the pattern of nexthop-vrf implies the nexthop-vrf is mandatory. <pre> sonic-static-route.yang: ... ... 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"; ... </pre> #### How I did it Correct the pattern of nexthop-vrf. #### How to verify it <pre> admin@sonic:~$ sudo config route add prefix 0.0.0.0/0 nexthop 172.16.0.3 admin@sonic:~$ redis-cli -n 4 127.0.0.1:6379[4]> key *STATIC* (error) ERR unknown command 'key', with args beginning with: '*STATIC*' 127.0.0.1:6379[4]> keys *STATIC* 1) "STATIC_ROUTE|default|0.0.0.0/0" 127.0.0.1:6379[4]> hgetall "STATIC_ROUTE|default|0.0.0.0/0" 1) "blackhole" 2) "false" 3) "distance" 4) "0" 5) "ifname" 6) "" 7) "nexthop" 8) "172.16.0.3" 9) "nexthop-vrf" 10) "" 127.0.0.1:6379[4]> exit admin@sonic:~$ sudo config interface breakout Ethernet8 4x100G -yf Running Breakout Mode : 1x400G Target Breakout Mode : 4x100G Ports to be deleted : { "Ethernet8": "400000" } Ports to be added : { "Ethernet8": "100000", "Ethernet10": "100000", "Ethernet12": "100000", "Ethernet14": "100000" } Breakout process got successfully completed. Please note loaded setting will be lost after system reboot. To preserve setting, run `config save`. </pre>
1 parent a35e23c commit 98bfebd

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

src/sonic-yang-models/tests/yang_model_tests/tests/static_route.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@
5252
"STATIC_ROUTE_TEST_ECMP_NEXTHOP_VRF_INVALID": {
5353
"desc": "Configure with invalid vrf for ECMP",
5454
"eStrKey": "Pattern"
55+
},
56+
"STATIC_ROUTE_TEST_NEXTHOP_EMPTY_VRF": {
57+
"desc": "Configure with null value for VRF"
5558
}
5659

5760
}

src/sonic-yang-models/tests/yang_model_tests/tests_config/static-route.json

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,53 @@
10211021
}]
10221022
}
10231023
}
1024+
},
1025+
"STATIC_ROUTE_TEST_NEXTHOP_EMPTY_VRF": {
1026+
"sonic-port:sonic-port": {
1027+
"sonic-port:PORT": {
1028+
"PORT_LIST": [
1029+
{
1030+
"admin_status": "up",
1031+
"alias": "eth0",
1032+
"description": "Ethernet0",
1033+
"fec": "rs",
1034+
"lanes": "65",
1035+
"mtu": 9000,
1036+
"name": "Ethernet0",
1037+
"speed": 25000
1038+
}
1039+
]
1040+
}
1041+
},
1042+
"sonic-interface:sonic-interface": {
1043+
"sonic-interface:INTERFACE": {
1044+
"INTERFACE_IPPREFIX_LIST": [
1045+
{
1046+
"family": "IPv4",
1047+
"ip-prefix": "1.0.0.1/30",
1048+
"name": "Ethernet0",
1049+
"scope": "global"
1050+
}
1051+
],
1052+
"INTERFACE_LIST": [
1053+
{
1054+
"name": "Ethernet0"
1055+
}
1056+
]
1057+
}
1058+
},
1059+
"sonic-static-route:sonic-static-route": {
1060+
"sonic-static-route:STATIC_ROUTE": {
1061+
"STATIC_ROUTE_LIST": [{
1062+
"prefix": "16.16.16.0/24",
1063+
"vrf_name": "default",
1064+
"nexthop": "1.0.0.5",
1065+
"distance": "1",
1066+
"nexthop-vrf": "",
1067+
"blackhole": "false"
1068+
}]
1069+
}
1070+
}
10241071
}
10251072

10261073
}

src/sonic-yang-models/yang-models/sonic-static-route.yang

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ module sonic-static-route {
111111
}
112112
leaf nexthop-vrf {
113113
type string {
114-
pattern "(((Vrf[a-zA-Z0-9_-]+)|(default)|(mgmt)),)*((Vrf[a-zA-Z0-9_-]+)|(default)|(mgmt))";
114+
pattern "((((Vrf[a-zA-Z0-9_-]+)|(default)|(mgmt)),)*((Vrf[a-zA-Z0-9_-]+)|(default)|(mgmt)))?";
115115
}
116116
description
117117
"VRF name of the nexthop. This is for vrf leaking";

0 commit comments

Comments
 (0)