Skip to content

Commit 95f9f44

Browse files
mssonicbldlolyu
andauthored
[YANG][vlan-sub-interface] Add vlan field (#15838) (#16469)
* [YANG][vlan-sub-interface] Add `vlan` field * Fix typo * Fix UT --------- Signed-off-by: Longxiang Lyu <[email protected]> Co-authored-by: Longxiang Lyu <[email protected]>
1 parent 86b4d38 commit 95f9f44

File tree

4 files changed

+62
-6
lines changed

4 files changed

+62
-6
lines changed

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -996,12 +996,14 @@
996996
"Ethernet12.10|10.0.1.56/31": {},
997997
"Ethernet12.10|fc00::1:71/126": {},
998998
"Po0003.10": {
999-
"admin_status": "up"
999+
"admin_status": "up",
1000+
"vlan": "10"
10001001
},
10011002
"Po0003.10|10.0.1.58/31": {},
10021003
"Po0003.10|fc00::1:75/126": {},
10031004
"Eth120.10": {
1004-
"admin_status": "up"
1005+
"admin_status": "up",
1006+
"vlan": "10"
10051007
},
10061008
"Eth120.10|10.0.1.60/31": {},
10071009
"Eth120.10|fc00::1:79/126": {}

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

+4
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,9 @@
5555
"desc": "INCORRECT LOOPBACK ACTION IN VLAN_SUB_INTERFACE TABLE.",
5656
"eStrKey" : "Pattern",
5757
"eStr": ["drop|forward"]
58+
},
59+
"VLAN_SUB_INTERFACE_SHORT_NAME_FORMAT_VLAN_CHECK_MUST_CONDITION_FALSE_TEST": {
60+
"desc": "Configure valid short name format vlan sub interface vlan must check condition false.",
61+
"eStrKey": "Must"
5862
}
5963
}

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

+40-4
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
"sonic-vlan-sub-interface:VLAN_SUB_INTERFACE": {
3737
"VLAN_SUB_INTERFACE_LIST": [
3838
{
39-
"name": "Eth8.10"
39+
"name": "Eth8.10",
40+
"vlan": 10
4041
}
4142
],
4243
"VLAN_SUB_INTERFACE_IPPREFIX_LIST": [
@@ -132,7 +133,8 @@
132133
"sonic-vlan-sub-interface:VLAN_SUB_INTERFACE": {
133134
"VLAN_SUB_INTERFACE_LIST": [
134135
{
135-
"name": "Eth8.10"
136+
"name": "Eth8.10",
137+
"vlan": 10
136138
}
137139
],
138140
"VLAN_SUB_INTERFACE_IPPREFIX_LIST": [
@@ -164,7 +166,8 @@
164166
"sonic-vlan-sub-interface:VLAN_SUB_INTERFACE": {
165167
"VLAN_SUB_INTERFACE_LIST": [
166168
{
167-
"name": "Po0001.10"
169+
"name": "Po0001.10",
170+
"vlan": 10
168171
}
169172
],
170173
"VLAN_SUB_INTERFACE_IPPREFIX_LIST": [
@@ -305,7 +308,8 @@
305308
"sonic-vlan-sub-interface:VLAN_SUB_INTERFACE": {
306309
"VLAN_SUB_INTERFACE_LIST": [
307310
{
308-
"name": "Po0002.10"
311+
"name": "Po0002.10",
312+
"vlan": 10
309313
}
310314
],
311315
"VLAN_SUB_INTERFACE_IPPREFIX_LIST": [
@@ -533,5 +537,37 @@
533537
]
534538
}
535539
}
540+
},
541+
"VLAN_SUB_INTERFACE_SHORT_NAME_FORMAT_VLAN_CHECK_MUST_CONDITION_FALSE_TEST": {
542+
"sonic-vlan-sub-interface:sonic-vlan-sub-interface": {
543+
"sonic-vlan-sub-interface:VLAN_SUB_INTERFACE": {
544+
"VLAN_SUB_INTERFACE_LIST": [
545+
{
546+
"name": "Eth8.10"
547+
}
548+
],
549+
"VLAN_SUB_INTERFACE_IPPREFIX_LIST": [
550+
{
551+
"name": "Eth8.10",
552+
"ip-prefix": "10.0.0.1/30"
553+
}
554+
]
555+
}
556+
},
557+
"sonic-port:sonic-port": {
558+
"sonic-port:PORT": {
559+
"PORT_LIST": [
560+
{
561+
"name": "Ethernet8",
562+
"admin_status": "up",
563+
"alias": "Ethernet8/1",
564+
"description": "Ethernet8",
565+
"lanes": "45,46,47,48",
566+
"mtu": 9000,
567+
"speed": 100000
568+
}
569+
]
570+
}
571+
}
536572
}
537573
}

src/sonic-yang-models/yang-models/sonic-vlan-sub-interface.yang

+14
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ module sonic-vlan-sub-interface {
3737

3838
description "VLAN_SUB_INTERFACE part of config_db.json with vrf";
3939

40+
// encap vlan is mandatory for short name subinterfaces
41+
must "(substring-before(name, '.') = /port:sonic-port/port:PORT/port:PORT_LIST/port:name) or " +
42+
"(substring-before(name, '.') = /lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name) or " +
43+
"vlan"
44+
{
45+
error-message "Must condition not satisfied, no encap vlan provided for short-name format vlan sub interface";
46+
}
47+
4048
key "name";
4149

4250
leaf name {
@@ -70,6 +78,12 @@ module sonic-vlan-sub-interface {
7078
description "Packet action when a packet ingress and gets routed on the same IP interface";
7179
type stypes:loopback_action;
7280
}
81+
82+
leaf vlan {
83+
type uint16 {
84+
range 1..4094;
85+
}
86+
}
7387
}
7488

7589
list VLAN_SUB_INTERFACE_IPPREFIX_LIST {

0 commit comments

Comments
 (0)