Skip to content

Commit c9f8488

Browse files
committed
Fix
1 parent cebfe3c commit c9f8488

File tree

3 files changed

+51
-44
lines changed

3 files changed

+51
-44
lines changed

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
},
3535

3636
"VNET_ROUTE_TUNNEL_COMPLETE_TEST": {
37-
"desc": "Complete VNET route tunnel configuration with all optional fields (including mac_address and vxlanid)in VNET_ROUTE_TUNNEL_LIST table."
37+
"desc": "Complete VNET route tunnel configuration with all optional fields (including mac_address and vxlanid) in VNET_ROUTE_TUNNEL_LIST table."
3838
},
3939

4040
"VNET_ROUTE_TUNNEL_TEST_DUPLICATE_NAME": {
@@ -58,13 +58,13 @@
5858
},
5959

6060
"VNET_ROUTE_TUNNEL_TEST_INVALID_NAME_FORMAT": {
61-
"desc": "VNET route tunnel configuration with invalid name format (missing pipe and prefix) in VNET_ROUTE_TUNNEL_LIST table.",
62-
"eStr": "Value \"Vnet1\" does not satisfy the constraint \"[^|]+[|]((([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2])))\" (range, length, or pattern)\""
61+
"desc": "VNET route tunnel configuration with invalid name format (missing prefix) in VNET_ROUTE_TUNNEL_LIST table.",
62+
"eStr": "Missing required element \"prefix\" in \"VNET_ROUTE_TUNNEL_LIST\""
6363
},
6464

6565
"VNET_ROUTE_TUNNEL_TEST_INVALID_PREFIX": {
6666
"desc": "VNET route tunnel configuration with invalid prefix format (300.168.1.0/24) in name field.",
67-
"eStr": "Value \"Vnet1|300.168.1.0/24\" does not satisfy the constraint \"[^|]+[|]((([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2])))\" (range, length, or pattern)\""
67+
"eStr": "Value \"300.168.1.0/24\" does not satisfy the constraint \"((([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2])))\" (range, length, or pattern)\""
6868
},
6969

7070
"VNET_ROUTE_TUNNEL_TEST_MISSING_ENDPOINT": {
@@ -74,6 +74,6 @@
7474

7575
"VNET_ROUTE_TUNNEL_TEST_NONEXISTENT_VNET": {
7676
"desc": "VNET route tunnel configuration referencing a non-existent VNET name, violating the must condition.",
77-
"eStr": "VNET name in the key must reference a valid VNET in the VNET table"
77+
"eStr": "Leafref \"/sonic-vnet:sonic-vnet/sonic-vnet:VNET/sonic-vnet:VNET_LIST/sonic-vnet:name\" of value \"NonexistentVnet\" points to a non-existing leaf"
7878
}
7979
}

src/sonic-yang-models/tests/yang_model_tests/tests_config/vnet.json

+25-13
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,8 @@
206206
"sonic-vnet:VNET_ROUTE_TUNNEL": {
207207
"VNET_ROUTE_TUNNEL_LIST": [
208208
{
209-
"name": "Vnet1|10.0.0.0/24",
209+
"vnet_name": "Vnet1",
210+
"prefix": "10.0.0.0/24",
210211
"endpoint": "192.168.1.1"
211212
}
212213
]
@@ -245,12 +246,14 @@
245246
"sonic-vnet:VNET_ROUTE_TUNNEL": {
246247
"VNET_ROUTE_TUNNEL_LIST": [
247248
{
248-
"name": "Vnet1|10.0.0.0/24",
249+
"vnet_name": "Vnet1",
250+
"prefix":"10.0.0.0/24",
249251
"endpoint": "192.168.1.1",
250252
"vxlanid": "10011"
251253
},
252254
{
253-
"name": "Vnet2|10.0.1.0/24",
255+
"vnet_name": "Vnet2",
256+
"prefix":"10.0.1.0/24",
254257
"endpoint": "192.168.1.2",
255258
"vxlanid": "10012"
256259
}
@@ -285,7 +288,8 @@
285288
"sonic-vnet:VNET_ROUTE_TUNNEL": {
286289
"VNET_ROUTE_TUNNEL_LIST": [
287290
{
288-
"name": "Vnet1|10.0.0.0/24",
291+
"vnet_name": "Vnet1",
292+
"prefix":"10.0.0.0/24",
289293
"endpoint": "192.168.1.1",
290294
"mac_address": "00:aa:bb:cc:dd:ee",
291295
"vxlanid": "10011"
@@ -321,12 +325,14 @@
321325
"sonic-vnet:VNET_ROUTE_TUNNEL": {
322326
"VNET_ROUTE_TUNNEL_LIST": [
323327
{
324-
"name": "Vnet1|10.0.0.0/24",
328+
"vnet_name": "Vnet1",
329+
"prefix":"10.0.0.0/24",
325330
"endpoint": "192.168.1.1",
326331
"vxlanid": "10011"
327332
},
328333
{
329-
"name": "Vnet1|10.0.0.0/24",
334+
"vnet_name": "Vnet1",
335+
"prefix":"10.0.0.0/24",
330336
"endpoint": "192.168.1.2",
331337
"vxlanid": "10012"
332338
}
@@ -361,7 +367,8 @@
361367
"sonic-vnet:VNET_ROUTE_TUNNEL": {
362368
"VNET_ROUTE_TUNNEL_LIST": [
363369
{
364-
"name": "Vnet1|10.0.0.0/24",
370+
"vnet_name": "Vnet1",
371+
"prefix":"10.0.0.0/24",
365372
"endpoint": "256.256.256.256",
366373
"vxlanid": "10011"
367374
}
@@ -396,7 +403,8 @@
396403
"sonic-vnet:VNET_ROUTE_TUNNEL": {
397404
"VNET_ROUTE_TUNNEL_LIST": [
398405
{
399-
"name": "Vnet1|10.0.0.0/24",
406+
"vnet_name": "Vnet1",
407+
"prefix":"10.0.0.0/24",
400408
"endpoint": "192.168.1.1",
401409
"mac_address": "GG:HH:II:JJ:KK:LL",
402410
"vxlanid": "10011"
@@ -432,7 +440,8 @@
432440
"sonic-vnet:VNET_ROUTE_TUNNEL": {
433441
"VNET_ROUTE_TUNNEL_LIST": [
434442
{
435-
"name": "Vnet1|10.0.0.0/24",
443+
"vnet_name": "Vnet1",
444+
"prefix":"10.0.0.0/24",
436445
"endpoint": "192.168.1.1",
437446
"vxlanid": "16777216"
438447
}
@@ -467,7 +476,7 @@
467476
"sonic-vnet:VNET_ROUTE_TUNNEL": {
468477
"VNET_ROUTE_TUNNEL_LIST": [
469478
{
470-
"name": "Vnet1",
479+
"vnet_name": "Vnet1",
471480
"endpoint": "192.168.1.1",
472481
"vxlanid": "10011"
473482
}
@@ -502,7 +511,8 @@
502511
"sonic-vnet:VNET_ROUTE_TUNNEL": {
503512
"VNET_ROUTE_TUNNEL_LIST": [
504513
{
505-
"name": "Vnet1|300.168.1.0/24",
514+
"vnet_name": "Vnet1",
515+
"prefix":"300.168.1.0/24",
506516
"endpoint": "192.168.1.1",
507517
"vxlanid": "10011"
508518
}
@@ -537,7 +547,8 @@
537547
"sonic-vnet:VNET_ROUTE_TUNNEL": {
538548
"VNET_ROUTE_TUNNEL_LIST": [
539549
{
540-
"name": "Vnet1|10.0.0.0/24",
550+
"vnet_name": "Vnet1",
551+
"prefix":"10.0.0.0/24",
541552
"vxlanid": "10011"
542553
}
543554
]
@@ -571,7 +582,8 @@
571582
"sonic-vnet:VNET_ROUTE_TUNNEL": {
572583
"VNET_ROUTE_TUNNEL_LIST": [
573584
{
574-
"name": "NonexistentVnet|10.0.0.0/24",
585+
"vnet_name": "NonexistentVnet",
586+
"prefix":"10.0.0.0/24",
575587
"endpoint": "192.168.1.1",
576588
"vxlanid": "10011"
577589
}

src/sonic-yang-models/yang-models/sonic-vnet.yang

+21-26
Original file line numberDiff line numberDiff line change
@@ -107,49 +107,44 @@ module sonic-vnet {
107107
description "ConfigDB VNET_ROUTE_TUNNEL table";
108108

109109
list VNET_ROUTE_TUNNEL_LIST {
110+
key "vnet_name prefix";
110111

111-
key "name";
112-
113-
leaf name {
114-
115-
// Must condition to verify the vnet name before the pipe references a valid VNET
116-
must "substring-before(current(), '|') = /svnet:sonic-vnet/svnet:VNET/svnet:VNET_LIST/svnet:name"
117-
{
118-
error-message "VNET name in the key must reference a valid VNET in the VNET table";
112+
leaf vnet_name {
113+
description "VNET name";
114+
type leafref {
115+
path "/svnet:sonic-vnet/svnet:VNET/svnet:VNET_LIST/svnet:name";
119116
}
120-
121-
// Pattern enforce proper format: <vnet_name>|<ipv4_prefix>
122-
// The IPv4 prefix pattern matches IPv4 CIDR standards (e.g. 192.169.1.0/24)
123-
// VNET name:
124-
// [^|]+ - One or more characters that are not pipes
125-
// | - A pipe separator
126-
// IPv4 address:
127-
// (([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3} - First three components with dot
128-
// ([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]) - Last component
129-
// / - Slash for prefix length
130-
// (([1-2][0-9])|(3[0-2])) - Prefix length from 0 to 32
117+
}
118+
119+
leaf prefix {
120+
description "IPv4 prefix in CIDR format";
121+
122+
/* Pattern enforces proper format: <vnet_name>|<ipv4_prefix>
123+
The IPv4 prefix pattern matches IPv4 CIDR standards
124+
IPv4 address:
125+
(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3} - First three octets with dot
126+
([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]) - Last octet
127+
/ - Slash for prefix length
128+
(([1-2][0-9])|(3[0-2])) - Prefix length from 0 to 32 */
131129
type string {
132-
pattern "[^|]+[|]((([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2])))";
130+
pattern "((([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2])))";
133131
}
134-
135-
description "Combined key of vnet_name|prefix (e.g., 'Vnet1-1|10.0.0.0/24') where
136-
vnet_name must exist in the VNET table and prefix is in IPv4 CIDR format";
137132
}
138133

139134
leaf endpoint {
135+
description "Endpoint/nexthop tunnel IP";
140136
type inet:ipv4-address;
141137
mandatory true;
142-
description "Endpoint/nexthop tunnel IP";
143138
}
144139

145140
leaf mac_address {
146-
type yang:mac-address;
147141
description "Inner dest mac in encapsulated packet";
142+
type yang:mac-address;
148143
}
149144

150145
leaf vxlanid {
151-
type stypes:vnid_type;
152146
description "A valid and active vni value in encapsulated packet";
147+
type stypes:vnid_type;
153148
}
154149
}
155150
/* end of list VNET_ROUTE_TUNNEL_LIST */

0 commit comments

Comments
 (0)