Skip to content

Commit

Permalink
[YANG][vlan-sub-interface] Add vlan field (#15838) (#16057)
Browse files Browse the repository at this point in the history
  • Loading branch information
mssonicbld authored Aug 6, 2023
1 parent 1c3e594 commit 03fc34e
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/sonic-yang-models/tests/files/sample_config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -1087,12 +1087,14 @@
"Ethernet12.10|10.0.1.56/31": {},
"Ethernet12.10|fc00::1:71/126": {},
"Po0003.10": {
"admin_status": "up"
"admin_status": "up",
"vlan": "10"
},
"Po0003.10|10.0.1.58/31": {},
"Po0003.10|fc00::1:75/126": {},
"Eth120.10": {
"admin_status": "up"
"admin_status": "up",
"vlan": "10"
},
"Eth120.10|10.0.1.60/31": {},
"Eth120.10|fc00::1:79/126": {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,9 @@
"desc": "INCORRECT LOOPBACK ACTION IN VLAN_SUB_INTERFACE TABLE.",
"eStrKey" : "Pattern",
"eStr": ["drop|forward"]
},
"VLAN_SUB_INTERFACE_SHORT_NAME_FORMAT_VLAN_CHECK_MUST_CONDITION_FALSE_TEST": {
"desc": "Configure valid short name format vlan sub interface vlan must check condition false.",
"eStrKey": "Must"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"sonic-vlan-sub-interface:VLAN_SUB_INTERFACE": {
"VLAN_SUB_INTERFACE_LIST": [
{
"name": "Eth8.10"
"name": "Eth8.10",
"vlan": 10
}
],
"VLAN_SUB_INTERFACE_IPPREFIX_LIST": [
Expand Down Expand Up @@ -132,7 +133,8 @@
"sonic-vlan-sub-interface:VLAN_SUB_INTERFACE": {
"VLAN_SUB_INTERFACE_LIST": [
{
"name": "Eth8.10"
"name": "Eth8.10",
"vlan": 10
}
],
"VLAN_SUB_INTERFACE_IPPREFIX_LIST": [
Expand Down Expand Up @@ -164,7 +166,8 @@
"sonic-vlan-sub-interface:VLAN_SUB_INTERFACE": {
"VLAN_SUB_INTERFACE_LIST": [
{
"name": "Po0001.10"
"name": "Po0001.10",
"vlan": 10
}
],
"VLAN_SUB_INTERFACE_IPPREFIX_LIST": [
Expand Down Expand Up @@ -305,7 +308,8 @@
"sonic-vlan-sub-interface:VLAN_SUB_INTERFACE": {
"VLAN_SUB_INTERFACE_LIST": [
{
"name": "Po0002.10"
"name": "Po0002.10",
"vlan": 10
}
],
"VLAN_SUB_INTERFACE_IPPREFIX_LIST": [
Expand Down Expand Up @@ -533,5 +537,37 @@
]
}
}
},
"VLAN_SUB_INTERFACE_SHORT_NAME_FORMAT_VLAN_CHECK_MUST_CONDITION_FALSE_TEST": {
"sonic-vlan-sub-interface:sonic-vlan-sub-interface": {
"sonic-vlan-sub-interface:VLAN_SUB_INTERFACE": {
"VLAN_SUB_INTERFACE_LIST": [
{
"name": "Eth8.10"
}
],
"VLAN_SUB_INTERFACE_IPPREFIX_LIST": [
{
"name": "Eth8.10",
"ip-prefix": "10.0.0.1/30"
}
]
}
},
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [
{
"name": "Ethernet8",
"admin_status": "up",
"alias": "Ethernet8/1",
"description": "Ethernet8",
"lanes": "45,46,47,48",
"mtu": 9000,
"speed": 100000
}
]
}
}
}
}
14 changes: 14 additions & 0 deletions src/sonic-yang-models/yang-models/sonic-vlan-sub-interface.yang
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ module sonic-vlan-sub-interface {

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

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

key "name";

leaf name {
Expand Down Expand Up @@ -70,6 +78,12 @@ module sonic-vlan-sub-interface {
description "Packet action when a packet ingress and gets routed on the same IP interface";
type stypes:loopback_action;
}

leaf vlan {
type uint16 {
range 1..4094;
}
}
}

list VLAN_SUB_INTERFACE_IPPREFIX_LIST {
Expand Down

0 comments on commit 03fc34e

Please sign in to comment.