[YANG][vlan-sub-intf] Enforce Linux interface name length (#10646)

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.
This commit is contained in:
Longxiang Lyu 2022-04-25 14:44:40 +08:00 committed by GitHub
parent 5cd6bc4ce2
commit d8c27b6ed2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 94 additions and 5 deletions

View File

@ -9,6 +9,10 @@
"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"
@ -16,6 +20,9 @@
"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"

View File

@ -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": {
@ -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": {

View File

@ -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";
}