Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit fec860e

Browse files
committedMar 5, 2025
(1) Insert VNET_ROUTE_TUNNEL table in sonic-vnet.yang file and fix test cases
(2) Fix sample data name constraints
1 parent ba92d31 commit fec860e

File tree

9 files changed

+523
-336
lines changed

9 files changed

+523
-336
lines changed
 

‎src/sonic-yang-models/doc/Configuration.md

+12-11
Original file line numberDiff line numberDiff line change
@@ -2545,23 +2545,24 @@ monitoring sessions for the vnet routes and is optional.
25452545
25462546
### VNET_ROUTE_TUNNEL
25472547
2548-
VNET_ROUTE_TUNNEL table has vnet_name:prefix as the object key, where vnet_name is the name of the VNet and prefix is the prefix associated with the route tunnel. The table includes the following attributes:
2549-
- ENDPOINT: The IP address of the host VM (mandatory), IPv4 address. It is used to identify the endpoint of the tunnel.
2550-
- MAC_ADDRESS: The inner destination MAC address in the encapsulated packet (optional). It should be a 12-hexadecimal digit value.
2548+
VNET_ROUTE_TUNNEL table has vnet_name|prefix as the object key, where vnet_name is the name of the VNet and prefix is the prefix associated with the route tunnel. The table includes the following attributes:
2549+
- ENDPOINT: The endpoint/nexthop tunnel IP (mandatory). It is used to identify the endpoint of the tunnel.
2550+
- MAC_ADDRESS: The inner destination MAC address in the encapsulated packet (optional). It should be a 12-hexadeimal digit value.
25512551
- VXLANID: The VNI value in the encapsulated packet (optional). It should be a numeric value.
25522552
25532553
```
25542554
{
25552555
"VNET_ROUTE_TUNNEL": {
2556-
"Vnet1-1:10.0.0.0/24": {
2557-
"endpoint": "192.168.1.1",
2558-
"mac_address": "F9:22:83:99:22:A2",
2559-
"vxlanid": "10011"
2556+
"Vnet_2000|100.100.1.1/32": {
2557+
"name": "Vnet_2000|100.100.1.1/32",
2558+
"endpoint": "192.168.1.1",
2559+
"mac_address": "F9:22:83:99:22:A2"
25602560
},
2561-
"Vnetv4_v4-0:10.0.1.0/24": {
2562-
"endpoint": "192.168.1.2",
2563-
"mac_address": "F8:22:83:99:22:A2",
2564-
"vxlanid": "10012"
2561+
"Vnetv4_v4-0|10.0.1.0/24": {
2562+
"name": "Vnetv4_v4-0|10.0.1.0/24",
2563+
"endpoint": "192.168.1.2",
2564+
"mac_address": "F8:22:83:99:22:A2",
2565+
"vxlanid": "10012"
25652566
}
25662567
}
25672568
}

‎src/sonic-yang-models/setup.py

-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ def run(self):
176176
'./yang-models/sonic-versions.yang',
177177
'./yang-models/sonic-vlan.yang',
178178
'./yang-models/sonic-vnet.yang',
179-
'./yang-models/sonic-vnet-route-tunnel-vxlan.yang',
180179
'./yang-models/sonic-voq-inband-interface.yang',
181180
'./yang-models/sonic-vxlan.yang',
182181
'./yang-models/sonic-vrf.yang',

‎src/sonic-yang-models/tests/files/sample_config_db.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -2338,7 +2338,8 @@
23382338
}
23392339
},
23402340
"VNET_ROUTE_TUNNEL" : {
2341-
"vnet1:10.0.0.0/24" : {
2341+
"vnet1|10.0.0.0/24" : {
2342+
"name":"vnet1|10.0.0.0/24",
23422343
"endpoint": "192.168.1.2",
23432344
"mac_address": "F9:22:83:99:22:A2",
23442345
"vxlanid": "10011"

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

+51
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,56 @@
2424
"VNET_INVALID_VXLAN_VTEP": {
2525
"desc": "Missing Vxlan_TUNNEL configuration",
2626
"eStr" : [ "points to a non-existing leaf" ]
27+
},
28+
"VNET_ROUTE_TUNNEL_MIN_TEST": {
29+
"desc": "Basic VNET route tunnel configuration with minimal required field - endpoint in VNET_ROUTE_TUNNEL_LIST table."
30+
},
31+
32+
"VNET_ROUTE_TUNNEL_MULTI_TEST": {
33+
"desc": "Multiple VNET route tunnel configurations for different VNETs in VNET_ROUTE_TUNNEL_LIST table."
34+
},
35+
36+
"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."
38+
},
39+
40+
"VNET_ROUTE_TUNNEL_TEST_DUPLICATE_NAME": {
41+
"desc": "VNET route tunnel configuration with duplicate name keys in VNET_ROUTE_TUNNEL_LIST table.",
42+
"eStr": "Duplicated instance of \"VNET_ROUTE_TUNNEL_LIST\" list."
43+
},
44+
45+
"VNET_ROUTE_TUNNEL_TEST_INVALID_ENDPOINT": {
46+
"desc": "VNET route tunnel configuration with invalid endpoint IP value (256.256.256.256) in VNET_ROUTE_TUNNEL_LIST table.",
47+
"eStr": "Value \"256.256.256.256\" does not satisfy the constraint"
48+
},
49+
50+
"VNET_ROUTE_TUNNEL_TEST_INVALID_MAC": {
51+
"desc": "VNET route tunnel configuration with invalid MAC address format (non-hexadecimal characters) in VNET_ROUTE_TUNNEL_LIST table.",
52+
"eStr": "Value \"GG:HH:II:JJ:KK:LL\" does not satisfy the constraint \"[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}\""
53+
},
54+
55+
"VNET_ROUTE_TUNNEL_TEST_INVALID_VXLANID": {
56+
"desc": "VNET route tunnel configuration with invalid VXLAN ID (exceeding max value of 16777215) in VNET_ROUTE_TUNNEL_LIST table.",
57+
"eStr": "Value \"16777216\" does not satisfy the constraint \"1..16777215\""
58+
},
59+
60+
"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)\""
63+
},
64+
65+
"VNET_ROUTE_TUNNEL_TEST_INVALID_PREFIX": {
66+
"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)\""
68+
},
69+
70+
"VNET_ROUTE_TUNNEL_TEST_MISSING_ENDPOINT": {
71+
"desc": "VNET route tunnel configuration with missing mandatory attribute (endpoint) in VNET_ROUTE_TUNNEL_LIST table.",
72+
"eStr": "Missing required element \"endpoint\" in \"VNET_ROUTE_TUNNEL_LIST\"."
73+
},
74+
75+
"VNET_ROUTE_TUNNEL_TEST_NONEXISTENT_VNET": {
76+
"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"
2778
}
2879
}

‎src/sonic-yang-models/tests/yang_model_tests/tests/vnet_route_tunnel_vxlan.json

-58
This file was deleted.

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

+400
Large diffs are not rendered by default.

‎src/sonic-yang-models/tests/yang_model_tests/tests_config/vnet_route_tunnel_vxlan.json

-190
This file was deleted.

‎src/sonic-yang-models/yang-models/sonic-vnet-route-tunnel-vxlan.yang

-74
This file was deleted.

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

+58-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,64 @@ module sonic-vnet {
9898
type yang:mac-address;
9999
}
100100
}
101+
/* end of list VNET_LIST */
101102
}
103+
/* end of container VNET */
104+
105+
container VNET_ROUTE_TUNNEL {
106+
107+
description "ConfigDB VNET_ROUTE_TUNNEL table";
108+
109+
list VNET_ROUTE_TUNNEL_LIST {
110+
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";
119+
}
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
131+
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])))";
133+
}
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";
137+
}
138+
139+
leaf endpoint {
140+
type inet:ipv4-address;
141+
mandatory true;
142+
description "Endpoint/nexthop tunnel IP";
143+
}
144+
145+
leaf mac_address {
146+
type yang:mac-address;
147+
description "Inner dest mac in encapsulated packet";
148+
}
149+
150+
leaf vxlanid {
151+
type stypes:vnid_type;
152+
description "A valid and active vni value in encapsulated packet";
153+
}
154+
}
155+
/* end of list VNET_ROUTE_TUNNEL_LIST */
156+
}
157+
/* end of container VNET_ROUTE_TUNNEL */
102158
}
159+
/* end of container sonic-vnet */
103160
}
104-
161+
/* end of module sonic-vnet */

0 commit comments

Comments
 (0)
Please sign in to comment.