Skip to content

Commit

Permalink
[YANG][vlan-sub-intf] Enforce Linux interface name length (#10646)
Browse files Browse the repository at this point in the history
Why I did it
Allow portchannel vlan sub intf long name format as long as it follows Linux interface name length limit(<16).

How I did it
Modify the leaf name check.

How to verify it
Test case passes.
  • Loading branch information
lolyu authored Apr 25, 2022
1 parent 5cd6bc4 commit d8c27b6
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,20 @@
"desc": "Configure vlan sub interface must condition false.",
"eStrKey": "Must"
},
"VLAN_SUB_INTERFACE_NAME_LENGTH_LIMIT_MUST_CONDITION_FALSE_TEST": {
"desc": "Configure vlan sub interface name length must condition false.",
"eStrKey": "Must"
},
"VLAN_SUB_INTERFACE_SHORT_NAME_FORMAT_MUST_CONDITION_FALSE_TEST": {
"desc": "Configure short name format vlan sub interface must condition false.",
"eStrKey": "Must"
},
"VLAN_SUB_INTERFACE_PO_SHORT_NAME_FORMAT_MUST_CONDITION_TRUE_TEST": {
"desc": "Configure valid portchannel short name format vlan sub interface must condition true."
},
"VLAN_SUB_INTERFACE_PO_MUST_CONDITION_TRUE_TEST": {
"desc": "Configure portchannel long name format vlan sub interface must condition true."
},
"VLAN_SUB_INTERFACE_PO_MUST_CONDITION_FALSE_TEST": {
"desc": "Configure portchannel long name format vlan sub interface must condition false.",
"eStrKey": "Must"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,38 @@
}
}
},
"VLAN_SUB_INTERFACE_NAME_LENGTH_LIMIT_MUST_CONDITION_FALSE_TEST": {
"sonic-vlan-sub-interface:sonic-vlan-sub-interface": {
"sonic-vlan-sub-interface:VLAN_SUB_INTERFACE": {
"VLAN_SUB_INTERFACE_LIST": [
{
"name": "Ethernet12000.10"
}
],
"VLAN_SUB_INTERFACE_IPPREFIX_LIST": [
{
"name": "Ethernet12000.10",
"ip-prefix": "10.0.0.1/30"
}
]
}
},
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [
{
"name": "Ethernet12000",
"admin_status": "up",
"alias": "Ethernet12000/1",
"description": "Ethernet12000",
"lanes": "49,50,51,52",
"mtu": 9000,
"speed": 100000
}
]
}
}
},
"VLAN_SUB_INTERFACE_SHORT_NAME_FORMAT_MUST_CONDITION_FALSE_TEST": {
"sonic-vlan-sub-interface:sonic-vlan-sub-interface": {
"sonic-vlan-sub-interface:VLAN_SUB_INTERFACE": {
Expand Down Expand Up @@ -177,6 +209,56 @@
}
}
},
"VLAN_SUB_INTERFACE_PO_MUST_CONDITION_TRUE_TEST": {
"sonic-vlan-sub-interface:sonic-vlan-sub-interface": {
"sonic-vlan-sub-interface:VLAN_SUB_INTERFACE": {
"VLAN_SUB_INTERFACE_LIST": [
{
"name": "PortChannel01.8"
}
],
"VLAN_SUB_INTERFACE_IPPREFIX_LIST": [
{
"name": "PortChannel01.8",
"ip-prefix": "10.0.0.1/30"
}
]
}
},
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [
{
"admin_status": "up",
"alias": "eth0",
"description": "Ethernet0",
"lanes": "65",
"mtu": 9000,
"name": "Ethernet0",
"tpid": "0x8100",
"speed": 25000
}
]
}
},
"sonic-portchannel:sonic-portchannel": {
"sonic-portchannel:PORTCHANNEL": {
"PORTCHANNEL_LIST": [
{
"admin_status": "up",
"members": [
"Ethernet0"
],
"min_links": "1",
"mtu": "9100",
"tpid": "0x8100",
"lacp_key": "auto",
"name": "PortChannel01"
}
]
}
}
},
"VLAN_SUB_INTERFACE_PO_MUST_CONDITION_FALSE_TEST": {
"sonic-vlan-sub-interface:sonic-vlan-sub-interface": {
"sonic-vlan-sub-interface:VLAN_SUB_INTERFACE": {
Expand Down
10 changes: 5 additions & 5 deletions src/sonic-yang-models/yang-models/sonic-vlan-sub-interface.yang
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ module sonic-vlan-sub-interface {
key "name";

leaf name {
must "(substring-before(current(), '.') = /port:sonic-port/port:PORT/port:PORT_LIST/port:name) or " +
"(starts-with(substring-before(current(), '.'), 'Eth') and " +
"concat('Ethernet', substring-after(substring-before(current(), '.'), 'Eth')) = /port:sonic-port/port:PORT/port:PORT_LIST/port:name) or " +
"(starts-with(substring-before(current(), '.'), 'Po') and " +
"concat('PortChannel', substring-after(substring-before(current(), '.'), 'Po')) = /lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name)"
must "(string-length(current()) <= 15) and " +
"((substring-before(current(), '.') = /port:sonic-port/port:PORT/port:PORT_LIST/port:name) or " +
"(starts-with(substring-before(current(), '.'), 'Eth') and concat('Ethernet', substring-after(substring-before(current(), '.'), 'Eth')) = /port:sonic-port/port:PORT/port:PORT_LIST/port:name) or " +
"(substring-before(current(), '.') = /lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name) or " +
"(starts-with(substring-before(current(), '.'), 'Po') and concat('PortChannel', substring-after(substring-before(current(), '.'), 'Po')) = /lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name))"
{
error-message "Must condition not satisfied, please follow vlan sub interface naming convention";
}
Expand Down

0 comments on commit d8c27b6

Please sign in to comment.