From d145ffa41ac630d2d834829c09306927752aff83 Mon Sep 17 00:00:00 2001 From: Wajahat Razi Date: Tue, 10 Dec 2024 23:53:31 +0500 Subject: [PATCH 1/5] Updating YANG model for PVST & MST --- src/sonic-yang-models/setup.py | 2 + .../tests/yang_model_tests/tests/stp.json | 148 +++++++ .../yang_model_tests/tests_config/stp.json | 302 +++++++++++++ .../yang-models/sonic-stp.yang | 406 ++++++++++++++++++ 4 files changed, 858 insertions(+) create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests/stp.json create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests_config/stp.json create mode 100644 src/sonic-yang-models/yang-models/sonic-stp.yang diff --git a/src/sonic-yang-models/setup.py b/src/sonic-yang-models/setup.py index 60dba6c410aa..c28d610e4989 100644 --- a/src/sonic-yang-models/setup.py +++ b/src/sonic-yang-models/setup.py @@ -207,6 +207,7 @@ def run(self): './yang-models/sonic-xcvrd-log.yang', './yang-models/sonic-grpcclient.yang', './yang-models/sonic-serial-console.yang', + './yang-models/sonic-stp.yang', './yang-models/sonic-smart-switch.yang',]), ('cvlyang-models', ['./cvlyang-models/sonic-acl.yang', './cvlyang-models/sonic-banner.yang', @@ -287,6 +288,7 @@ def run(self): './cvlyang-models/sonic-macsec.yang', './cvlyang-models/sonic-bmp.yang', './cvlyang-models/sonic-serial-console.yang', + './yang-models/sonic-stp.yang', './cvlyang-models/sonic-bgp-sentinel.yang']), ], zip_safe=False, diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/stp.json b/src/sonic-yang-models/tests/yang_model_tests/tests/stp.json new file mode 100644 index 000000000000..5b2aab731cc4 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/stp.json @@ -0,0 +1,148 @@ +{ + "STP_GLOBAL_CONFIG_TEST": { + "desc": "Configure STP globally with valid mode (mst or pvst)." + }, + "STP_GLOBAL_INVALID_PRIORITY": { + "desc": "Configure an invalid priority value in the STP global settings.", + "eStrKey": "InvalidValue", + "eStr": ["priority"] + }, + "STP_GLOBAL_INVALID_MODE_TEST": { + "desc": "Configure STP globally with an invalid mode.", + "eStrKey": "InvalidSTPMode", + "eStr": ["Invalid STP mode value. Valid values are 'mst' or 'pvst'."] + }, + "STP_GLOBAL_CONFIG_NO_MODE_NEG_TEST": { + "desc": "Configure STP globally without specifying a mode.", + "eStrKey": "Mandatory", + "eStr": ["STP mode must be specified."] + }, + "STP_GLOBAL_INVALID_ROOTGUARD_TIMEOUT": { + "desc": "Configure an invalid root guard timeout in global STP settings.", + "eStrKey": "InvalidRootguardTimeout", + "eStr": ["Root-guard Timeout must be between 5 and 600 seconds."] + }, + "STP_VLAN_VALID_CONFIG_TEST": { + "desc": "Configure PVST VLAN with valid parameters (priority and VLAN ID)." + }, + "STP_VLAN_INVALID_VLAN_ID_NEG_TEST": { + "desc": "Configure PVST VLAN with an invalid VLAN ID.", + "eStrKey": "InvalidVlanID", + "eStr": ["VLAN ID must be between 1 and 4095."] + }, + "STP_VLAN_INVALID_PRIORITY_NEG_TEST": { + "desc": "Configure PVST VLAN with an invalid bridge priority.", + "eStrKey": "InvalidPriority", + "eStr": ["Bridge priority must be between 0 and 61440."] + }, + "STP_VLAN_MISSING_PRIORITY_NEG_TEST": { + "desc": "Configure PVST VLAN without specifying priority.", + "eStrKey": "Mandatory", + "eStr": ["Bridge priority must be specified for PVST VLAN."] + }, + "STP_VLAN_DUPLICATE_CONFIG_NEG_TEST": { + "desc": "Configure PVST VLAN with a duplicate VLAN ID.", + "eStrKey": "DuplicateVlanID", + "eStr": ["Duplicate VLAN ID detected."] + }, + "STP_INTERFACE_VALID_CONFIG_TEST": { + "desc": "Configure STP parameters on an interface with valid values." + }, + "STP_INTERFACE_INVALID_COST_NEG_TEST": { + "desc": "Configure an invalid path cost for an interface.", + "eStrKey": "InvalidPathCost", + "eStr": ["Path cost must be between 1 and 200000000."] + }, + "STP_INTERFACE_DUPLICATE_NEG_TEST": { + "desc": "Configure duplicate STP parameters for the same interface.", + "eStrKey": "DuplicateInterfaceConfig", + "eStr": ["Duplicate interface configuration detected."] + }, + "STP_INTERFACE_INVALID_PORTFAST_NEG_TEST": { + "desc": "Configure portfast on MST mode interface.", + "eStrKey": "InvalidPortfast", + "eStr": ["Configuration not allowed in MST mode"] + }, + "STP_MST_GLOBAL_CONFIG_TEST": { + "desc": "Configure MSTP globally with valid parameters." + }, + "STP_MST_REGION_NAME_MISSING_NEG_TEST": { + "desc": "Configure MSTP region without specifying a name.", + "eStrKey": "Mandatory", + "eStr": ["MST region name must be provided."] + }, + "STP_MST_REGION_NAME_INVALID_NEG_TEST": { + "desc": "Configure MSTP with an invalid region name.", + "eStrKey": "InvalidValue", + "eStr": ["MST region name must be between 1 and 32 characters."] + }, + "STP_MST_INSTANCE_VALID_CONFIG_TEST": { + "desc": "Configure MSTP instance with valid instance ID and VLAN mapping." + }, + "STP_MST_INSTANCE_DUPLICATE_ID_NEG_TEST": { + "desc": "Configure MSTP instance with a duplicate instance ID.", + "eStrKey": "DuplicateInstanceID", + "eStr": ["Duplicate MSTP instance ID detected."] + }, + "STP_MST_INSTANCE_INVALID_VLAN_NEG_TEST": { + "desc": "Configure MSTP instance with an invalid VLAN list.", + "eStrKey": "InvalidVlanList", + "eStr": ["VLAN list contains invalid or out-of-range VLAN IDs."] + }, + "STP_MST_INSTANCE_MISSING_VLAN_NEG_TEST": { + "desc": "Configure MSTP instance without associating VLANs.", + "eStrKey": "Mandatory", + "eStr": ["At least one VLAN must be associated with the MSTP instance."] + }, + "STP_MST_PORT_CONFIG_TEST": { + "desc": "Configure MSTP parameters on a port with valid settings." + }, + "STP_MST_PORT_INVALID_PRIORITY_NEG_TEST": { + "desc": "Configure MSTP port with an invalid port priority.", + "eStrKey": "InvalidPortPriority", + "eStr": ["Port priority must be between 0 and 240."] + }, + "STP_MST_PORT_INVALID_COST_NEG_TEST": { + "desc": "Configure MSTP port with an invalid path cost.", + "eStrKey": "InvalidPathCost", + "eStr": ["Path cost must be between 1 and 20000000."] + }, + "STP_MST_PORT_DUPLICATE_NEG_TEST": { + "desc": "Configure MSTP parameters with duplicate port settings.", + "eStrKey": "DuplicatePortConfig", + "eStr": ["Duplicate MSTP port configuration detected."] + }, + "STP_MST_PORT_EDGE_PORT_NEG_TEST": { + "desc": "Configure MSTP port with edge-port enabled in non-MST mode.", + "eStrKey": "InvalidEdgePort", + "eStr": ["Edge-port configuration is only allowed in MST mode."] + }, + "STP_MST_PORT_LINK_TYPE_TEST": { + "desc": "Configure MSTP port with valid link type (auto, shared, point-to-point)." + }, + "STP_MST_PORT_INVALID_LINK_TYPE_NEG_TEST": { + "desc": "Configure MSTP port with an invalid link type.", + "eStrKey": "InvalidLinkType", + "eStr": ["Link type must be 'auto', 'shared', or 'point-to-point'."] + }, + "STP_MST_PORT_CONFIG_DUPLICATE_EDGE_PORT_NEG_TEST": { + "desc": "Configure MSTP port with duplicate edge-port configuration.", + "eStrKey": "DuplicateEdgePortConfig", + "eStr": ["Duplicate edge-port configuration detected."] + }, + "STP_PORT_EDGE_PORT_TEST": { + "desc": "Configure edge port settings on an interface." + }, + "STP_PORT_LINK_TYPE_TEST": { + "desc": "Configure link type settings on an interface." + }, + "STP_MST_HOLD_COUNT_TEST": { + "desc": "Configure MST hold count with valid settings." + }, + "STP_MST_HELLO_TIME_TEST": { + "desc": "Configure MST hello time with valid settings." + }, + "STP_MST_MAX_HOPS_TEST": { + "desc": "Configure MST max hops with valid settings." + } +} \ No newline at end of file diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/stp.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/stp.json new file mode 100644 index 000000000000..6f806c6055d1 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/stp.json @@ -0,0 +1,302 @@ +{ + "MSTP_TEST": { + "sonic-stp:sonic-stp": { + "sonic-stp:STP_GLOBAL": { + "mode": "mst", + "forward_delay": 15, + "hello_time": 2, + "max_age": 20, + "rootguard_timeout": 30, + "priority": 32768 + } + } + }, + "MSTP_TEST_WRONG_MODE": { + "sonic-stp:sonic-stp": { + "sonic-stp:STP_GLOBAL": { + "mode": "unknown_mode" + } + } + }, + "MSTP_TEST_WRONG_INSTANCE": { + "sonic-stp:sonic-stp": { + "sonic-stp:STP_MST_INST": { + "STP_MST_INST_LIST": [ + { + "instance": 5000, + "vlan": ["10", "20", "30"] + } + ] + } + } + }, + "MSTP_TEST_WRONG_PRIORITY": { + "sonic-stp:sonic-stp": { + "sonic-stp:STP_GLOBAL": { + "priority": 1000 + } + } + }, + "MSTP_TEST_WITHOUT_NAME": { + "sonic-stp:sonic-stp": { + "sonic-stp:STP_MST": { + "name": "", + "revision": 1, + "max_hops": 20, + "hello_time": 2, + "max_age": 20, + "forward_delay": 15 + } + } + }, + "MSTP_TEST_MISSING_VLAN": { + "sonic-stp:sonic-stp": { + "sonic-stp:STP_MST_INST": { + "STP_MST_INST_LIST": [ + { + "instance": 1, + "vlan": [] + } + ] + } + } + }, + "MSTP_TEST_INVALID_VLAN_LIST": { + "sonic-stp:sonic-stp": { + "sonic-stp:STP_MST_INST": { + "STP_MST_INST_LIST": [ + { + "instance": 1, + "vlan": ["vlan1", "vlan2", "vlan3"] + } + ] + } + } + }, + "MSTP_TEST_MAX_HOPS_EXCEEDED": { + "sonic-stp:sonic-stp": { + "sonic-stp:STP_MST": { + "max_hops": 300 + } + } + }, + "MSTP_TEST_WRONG_HELLO_TIME": { + "sonic-stp:sonic-stp": { + "sonic-stp:STP_MST": { + "hello_time": 15 + } + } + }, + "MSTP_TEST_INVALID_FORWARD_DELAY": { + "sonic-stp:sonic-stp": { + "sonic-stp:STP_MST": { + "forward_delay": 2 + } + } + }, + "MSTP_TEST_DUPLICATE_INSTANCE": { + "sonic-stp:sonic-stp": { + "sonic-stp:STP_MST_INST": { + "STP_MST_INST_LIST": [ + { + "instance": 1, + "vlan": ["10", "20"] + }, + { + "instance": 1, + "vlan": ["30", "40"] + } + ] + } + } + }, + "MSTP_TEST_GLOBAL_WITH_INVALID_MODE": { + "sonic-stp:sonic-stp": { + "sonic-stp:STP_GLOBAL": { + "mode": "invalid_mode" + } + } + }, + "PVST_TEST": { + "sonic-stp:sonic-stp": { + "sonic-stp:STP_GLOBAL": { + "mode": "pvst", + "forward_delay": 15, + "hello_time": 2, + "max_age": 20, + "rootguard_timeout": 30, + "priority": 32768 + } + } + }, + "PVST_TEST_WRONG_MODE": { + "sonic-stp:sonic-stp": { + "sonic-stp:STP_GLOBAL": { + "mode": "unknown_mode" + } + } + }, + "PVST_TEST_WRONG_PRIORITY": { + "sonic-stp:sonic-stp": { + "sonic-stp:STP_GLOBAL": { + "priority": 1000 + } + } + }, + "PVST_TEST_INVALID_VLAN_ID": { + "sonic-stp:sonic-stp": { + "sonic-stp:STP_VLAN": { + "STP_VLAN_LIST": [ + { + "vlanid": 5000, + "vlan": 5000 + } + ] + } + } + }, + "PVST_TEST_MISSING_VLAN": { + "sonic-stp:sonic-stp": { + "sonic-stp:STP_VLAN": { + "STP_VLAN_LIST": [ + { + "vlanid": [], + "vlan": [] + } + ] + } + } + }, + "PVST_TEST_DUPLICATE_VLAN": { + "sonic-stp:sonic-stp": { + "sonic-stp:STP_VLAN": { + "STP_VLAN_LIST": [ + { + "vlanid": 10 + }, + { + "vlanid": 10, + "vlan": 10 + }, + { + "vlan": 10, + "vlanid": 10 + }, + { + "vlanid": 10 + } + ] + } + } + }, + "PVST_TEST_VLAN_WITHOUT_PRIORITY": { + "sonic-stp:sonic-stp": { + "sonic-stp:STP_VLAN": { + "STP_VLAN_LIST": [ + { + "vlanid": 10, + "vlan": 10 + } + ] + } + } + }, + "PVST_TEST_INVALID_PRIORITY": { + "sonic-stp:sonic-stp": { + "sonic-stp:STP_VLAN": { + "STP_VLAN_LIST": [ + { + "vlanid": 10, + "vlan": 10, + "priority": 1000 + } + ] + } + } + }, + "PVST_TEST_INVALID_PATH_COST": { + "sonic-stp:sonic-stp": { + "sonic-stp:STP_PORT": { + "STP_PORT_LIST": [ + { + "ifname": "Ethernet0", + "path_cost": -1 + } + ] + } + } + }, + "MSTP_TEST_VALID_INTERFACE_CONFIG": { + "sonic-stp:sonic-stp": { + "sonic-stp:STP_PORT": { + "STP_PORT_LIST": [ + { + "ifname": "Ethernet0", + "enabled": true, + "root_guard": false, + "bpdu_guard": false, + "bpdu_guard_do_disable": false, + "path_cost": 20000, + "priority": 128, + "portfast": false, + "uplink_fast": false, + "edge_port": true, + "link_type": "auto" + } + ] + } + } + }, + "MSTP_TEST_INVALID_INTERFACE_PRIORITY": { + "sonic-stp:sonic-stp": { + "sonic-stp:STP_PORT": { + "STP_PORT_LIST": [ + { + "ifname": "Ethernet0", + "priority": 300 + } + ] + } + } + }, + "MSTP_TEST_DUPLICATE_INTERFACE_CONFIG": { + "sonic-stp:sonic-stp": { + "sonic-stp:STP_PORT": { + "STP_PORT_LIST": [ + { + "ifname": "Ethernet0", + "path_cost": 20000 + }, + { + "ifname": "Ethernet0", + "path_cost": 20000 + } + ] + } + } + }, + "MSTP_TEST_INVALID_EDGE_PORT": { + "sonic-stp:sonic-stp": { + "sonic-stp:STP_PORT": { + "STP_PORT_LIST": [ + { + "ifname": "Ethernet0", + "edge_port": true + } + ] + } + } + }, + "MSTP_TEST_INVALID_LINK_TYPE": { + "sonic-stp:sonic-stp": { + "sonic-stp:STP_PORT": { + "STP_PORT_LIST": [ + { + "ifname": "Ethernet0", + "link_type": "invalid_type" + } + ] + } + } + } +} \ No newline at end of file diff --git a/src/sonic-yang-models/yang-models/sonic-stp.yang b/src/sonic-yang-models/yang-models/sonic-stp.yang new file mode 100644 index 000000000000..aa272880dd1e --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-stp.yang @@ -0,0 +1,406 @@ +module sonic-stp { + namespace "http://github.com/sonic-net/sonic-stp"; + prefix stp; + yang-version 1.1; + + import sonic-extension { + prefix sonic-ext; + } + + description "SONiC STP YANG model for PVST and MST configurations"; + + revision 2024-11-24 { + description "Version01 for combined PVST and MST configurations."; + } + + grouping vlanModeAttr { + leaf forward_delay { + type uint8 { + range "4..30" { + error-message "Invalid Forwarding Delay value."; + } + } + units seconds; + default 15; + description + "The delay used by STP bridges to transition root and + designated ports to forwarding"; + } + + leaf hello_time { + type uint8 { + range "1..10" { + error-message "Invalid Hello Time value."; + } + } + units seconds; + default 2; + description + "The interval between periodic transmissions of + configuration messages by designated ports"; + } + + leaf max_age { + type uint8 { + range "6..40" { + error-message "Invalid Maximum Age Time value."; + } + } + units seconds; + default 20; + description + "The maximum age of the information transmitted by the + bridge when it is the root bridge"; + } + + leaf priority { + type uint16 { + range "0..61440" { + error-message "Invalid Bridge Priority value."; + } + } + default 32768; + description + "The manageable component of the Bridge Identifier"; + } + } + + grouping interfaceAttr { + leaf path_cost { + type uint64 { + range "1..200000000" { + error-message "Invalid Port Path Cost value."; + } + } + default 200; + description + "The port's contribution, when it is the Root Port, + to the Root Path Cost for the Bridge"; + } + + leaf priority { + type uint8 { + range "0..240" { + error-message "Invalid Port Priority value."; + } + } + default 128; + description + "The manageable component of the Port Identifier, + also known as the Port Priority"; + } + } + + container sonic-spanning-tree { + + container STP { + list STP_LIST { + max-elements 1; + key "keyleaf"; + leaf keyleaf { + type enumeration { + enum GLOBAL; + } + description + "Key node identifier. It's value is always GLOBAL"; + } + + leaf mode { + type enumeration { + enum pvst; + enum mst; + } + mandatory true; + description + "Spanning tree mode"; + } + + leaf rootguard_timeout { + must "../../../STP/STP_LIST[keyleaf='GLOBAL']/mode!='mst'" { + error-message "Configuration not allowed in MST mode"; + error-app-tag stp-invalid; + } + + type uint16 { + range "5..600" { + error-message "Invalid Root-guard Timeout value."; + } + } + units seconds; + description + "Once superior BPDUs stop coming on the port, device + will wait for a period until root guard timeout before + moving the port to forwarding state"; + } + + uses vlanModeAttr; + } + } + + container STP_VLAN { + list STP_VLAN_LIST { + key "name"; + leaf name { + type string; + description + "Vlan identifier"; + } + + leaf vlanid { + type uint16 { + range "1..4095" { + error-message "Vlan ID out of range"; + error-app-tag vlanid-invalid; + } + } + description + "Vlan identifier number"; + } + + leaf enabled { + type boolean; + mandatory true; + description + "Spanning tree enabled/disabled on Vlan"; + } + + uses vlanModeAttr; + } + } + + container STP_VLAN_PORT { + list STP_VLAN_PORT_LIST { + key "vlan-name ifname"; + + leaf vlan-name { + type leafref { + path "../../../STP_VLAN/STP_VLAN_LIST/name"; + } + description + "Reference to Vlan"; + } + + leaf ifname { + type leafref { + path "../../../STP_PORT/STP_PORT_LIST/ifname"; + } + description + "Reference to Ethernet interface or PortChannel"; + } + + uses interfaceAttr; + } + } + + container STP_PORT { + list STP_PORT_LIST { + key "ifname"; + sonic-ext:dependent-on "STP_LIST"; + leaf ifname { + type string; + description + "Reference to Ethernet interface or PortChannel"; + } + + leaf enabled { + type boolean; + mandatory true; + description + "Spanning tree enabled/disabled on Interface"; + } + + leaf root_guard { + type boolean; + description + "Enable/Disable Root guard on port"; + } + + leaf bpdu_guard { + type boolean; + description + "Enable/Disable port BPDU guard"; + } + + leaf bpdu_guard_do_disable { + type boolean; + description + "Port to be disabled when it receives a BPDU"; + } + + leaf uplink_fast { + type boolean; + description + "Enable/Disable uplink-fast on port"; + } + + leaf portfast { + must "current()!='true' or ../../../STP/STP_LIST[keyleaf='GLOBAL']/mode='pvst'" { + error-message "Configuration not allowed in MST mode"; + error-app-tag stp-invalid; + } + type boolean; + description + "Enable/Disable portfast on port"; + } + + uses interfaceAttr; + + // For MST + leaf edge_port { + type boolean; + description + "Enable/Disable Edge-port on interface"; + } + + leaf link_type { + type enumeration { + enum auto; + enum shared; + enum point-to-point; + } + description + "Specifies the interface's link type. Permissible values + are 'shared', 'point-to-point' and 'auto'"; + } + } + } + + container STP_MST { + list STP_MST_LIST { + max-elements 1; + key "keyleaf"; + sonic-ext:dependent-on "STP_LIST"; + + leaf keyleaf { + type enumeration { + enum GLOBAL; + } + description + "Key node identifier. It's value is always GLOBAL"; + } + + leaf name { + must "../../../STP/STP_LIST[keyleaf='GLOBAL']/mode='mst'" { + error-message "Configuration allowed in MST mode"; + error-app-tag stp-invalid; + } + type string; + description + "MST Region name"; + } + + leaf revision { + must "../../../STP/STP_LIST[keyleaf='GLOBAL']/mode='mst'" { + error-message "Configuration allowed in MST mode"; + error-app-tag stp-invalid; + } + type uint32; + description + "MST Revision number"; + } + + leaf max_hops { + must "../../../STP/STP_LIST[keyleaf='GLOBAL']/mode='mst'" { + error-message "Configuration allowed in MST mode"; + error-app-tag stp-invalid; + } + type uint8; + description + "MST Max hops"; + } + + leaf hello_time { + must "../../../STP/STP_LIST[keyleaf='GLOBAL']/mode='mst'" { + error-message "Configuration allowed in MST mode"; + error-app-tag stp-invalid; + } + type uint8; + description + "MST hello time"; + } + + leaf max_age { + must "../../../STP/STP_LIST[keyleaf='GLOBAL']/mode='mst'" { + error-message "Configuration allowed in MST mode"; + error-app-tag stp-invalid; + } + type uint8; + description + "MST max age"; + } + + leaf forward_delay { + must "../../../STP/STP_LIST[keyleaf='GLOBAL']/mode='mst'" { + error-message "Configuration allowed in MST mode"; + error-app-tag stp-invalid; + } + type uint8; + description + "MST forward delay"; + } + + leaf hold_count { + must "../../../STP/STP_LIST[keyleaf='GLOBAL']/mode='mst'" { + error-message "Configuration allowed in MST mode"; + error-app-tag stp-invalid; + } + type uint8; + description + "MST hold count"; + } + } + } + + container STP_MST_INST { + list STP_MST_INST_LIST { + key "instance"; + + leaf instance { + type uint16; + description + "Instance identifier"; + } + + leaf-list vlan { + type string; + description + "Vlan list"; + } + + leaf bridge_priority { + type uint16 { + range "0..61440" { + error-message "Invalid Bridge Priority value."; + } + } + description + "The manageable component of the Bridge Identifier"; + } + } + } + + container STP_MST_PORT { + list STP_MST_PORT_LIST { + key "inst_id ifname"; + + leaf inst_id { + type leafref { + path "../../../STP_MST_INST/STP_MST_INST_LIST/instance"; + } + description + "Reference to MST Instance"; + } + + leaf ifname { + type leafref { + path "../../../STP_PORT/STP_PORT_LIST/ifname"; + } + + description + "Reference to Ethernet interface or PortChannel"; + } + uses interfaceAttr; + } + } + } +} \ No newline at end of file From e684942ff877f0791a59c4196feb792811720695 Mon Sep 17 00:00:00 2001 From: Wajahat Razi Date: Tue, 17 Dec 2024 14:12:25 +0500 Subject: [PATCH 2/5] Creating PR on SONiC buildimage Master --- src/sonic-yang-models/yang-models/sonic-stp.yang | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sonic-yang-models/yang-models/sonic-stp.yang b/src/sonic-yang-models/yang-models/sonic-stp.yang index aa272880dd1e..739b180a3c25 100644 --- a/src/sonic-yang-models/yang-models/sonic-stp.yang +++ b/src/sonic-yang-models/yang-models/sonic-stp.yang @@ -10,20 +10,20 @@ module sonic-stp { description "SONiC STP YANG model for PVST and MST configurations"; revision 2024-11-24 { - description "Version01 for combined PVST and MST configurations."; + description "Version01 for combined PVST configurations."; } grouping vlanModeAttr { leaf forward_delay { type uint8 { range "4..30" { - error-message "Invalid Forwarding Delay value."; + error-message "Invalid Forwarding Delay Value."; } } units seconds; default 15; description - "The delay used by STP bridges to transition root and + "The delay used by STP bridges to transition root, and designated ports to forwarding"; } @@ -49,7 +49,7 @@ module sonic-stp { units seconds; default 20; description - "The maximum age of the information transmitted by the + "The Maximum age of the information transmitted by the bridge when it is the root bridge"; } From 0de9d67563fbbec37112f20d5b3605ec863b41af Mon Sep 17 00:00:00 2001 From: Wajahat Razi Date: Tue, 17 Dec 2024 14:12:25 +0500 Subject: [PATCH 3/5] Creating PR on SONiC buildimage Master --- src/sonic-yang-models/yang-models/sonic-stp.yang | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sonic-yang-models/yang-models/sonic-stp.yang b/src/sonic-yang-models/yang-models/sonic-stp.yang index aa272880dd1e..d95ca3658aa1 100644 --- a/src/sonic-yang-models/yang-models/sonic-stp.yang +++ b/src/sonic-yang-models/yang-models/sonic-stp.yang @@ -10,20 +10,20 @@ module sonic-stp { description "SONiC STP YANG model for PVST and MST configurations"; revision 2024-11-24 { - description "Version01 for combined PVST and MST configurations."; + description "Version01 for combined PVST configurations."; } grouping vlanModeAttr { leaf forward_delay { type uint8 { range "4..30" { - error-message "Invalid Forwarding Delay value."; + error-message "Invalid Forwarding Delay Value."; } } units seconds; default 15; description - "The delay used by STP bridges to transition root and + "The delay used by STP bridges to transition root, and designated ports to forwarding"; } @@ -49,8 +49,8 @@ module sonic-stp { units seconds; default 20; description - "The maximum age of the information transmitted by the - bridge when it is the root bridge"; + "The Maximum age of the information transmitted by the + bridge when it is the root bridge."; } leaf priority { From 2929b0bd3ccc34f64327cf569adb31393935752b Mon Sep 17 00:00:00 2001 From: Wajahat Razi Date: Wed, 22 Jan 2025 02:02:09 +0500 Subject: [PATCH 4/5] Updated the YANG model --- .../yang-models/sonic-extension.yang | 1 + .../yang-models/sonic-stp.yang | 193 ++++++++++++------ 2 files changed, 127 insertions(+), 67 deletions(-) create mode 120000 src/sonic-yang-models/yang-models/sonic-extension.yang diff --git a/src/sonic-yang-models/yang-models/sonic-extension.yang b/src/sonic-yang-models/yang-models/sonic-extension.yang new file mode 120000 index 000000000000..dc60e0e88719 --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-extension.yang @@ -0,0 +1 @@ +/path/to/sonic-extension.yang \ No newline at end of file diff --git a/src/sonic-yang-models/yang-models/sonic-stp.yang b/src/sonic-yang-models/yang-models/sonic-stp.yang index fe5cac583fec..4d8333790204 100644 --- a/src/sonic-yang-models/yang-models/sonic-stp.yang +++ b/src/sonic-yang-models/yang-models/sonic-stp.yang @@ -1,27 +1,27 @@ module sonic-stp { + yang-version 1.1; + namespace "http://github.com/sonic-net/sonic-stp"; + prefix stp; import sonic-extension { prefix sonic-ext; } - - description - "SONiC STP YANG model for PVST and MST configurations"; - revision 2024-12-30 { - description - "Version01 for combined PVST configurations."; - } + description + "This module contains the collection of YANG definitions for the PVST & MSTP"; - extension dependent-on { - argument "dependency"; + revision 2024-12-30 { description - "Indicates module dependencies"; + "Version01 for combined PVST & MSTP configurations."; } grouping vlanModeAttr { + description + "Configuration parameters"; + leaf forward_delay { type uint8 { range "4..30" { @@ -74,6 +74,9 @@ module sonic-stp { } grouping interfaceAttr { + description + "Configuration parameters of interfaces."; + leaf path_cost { type uint64 { range "1..200000000" { @@ -99,15 +102,26 @@ module sonic-stp { } } - container sonic-spanning-tree { + container spanning-tree { + description + "Top level container for SONiC Spanning Tree configurations"; + + container stp-config { + description + "Global configurations"; - container STP { - list STP_LIST { + list stp-list { + description + "STP list containing global attributes"; max-elements 1; key "keyleaf"; + leaf keyleaf { type enumeration { - enum GLOBAL; + enum GLOBAL { + description + "Global configuration identifier"; + } } description "Key node identifier. It's value is always GLOBAL"; @@ -115,8 +129,14 @@ module sonic-stp { leaf mode { type enumeration { - enum pvst; - enum mst; + enum pvst { + description + "Per VLAN Spanning Tree Mode"; + } + enum mst { + description + "Multiple Spanning Tree Mode"; + } } mandatory true; description @@ -124,17 +144,17 @@ module sonic-stp { } leaf rootguard_timeout { - must "../../../STP/STP_LIST[keyleaf='GLOBAL']/mode!='mst'" { - error-message "Configuration not allowed in MST mode"; - error-app-tag stp-invalid; - } - type uint16 { range "5..600" { error-message "Invalid Root-guard Timeout value."; } } units seconds; + must "../../../stp-config/stp-list[keyleaf='GLOBAL']/mode!='mst'" { + error-message "Root guard timeout not allowed in MST mode"; + error-app-tag stp-invalid; + } + description "Once superior BPDUs stop coming on the port, device will wait for a period until root guard timeout before @@ -145,9 +165,15 @@ module sonic-stp { } } - container STP_VLAN { - list STP_VLAN_LIST { + container stp-vlan { + description + "VLAN Specific STP Configurations"; + + list stp-vlan-list { + description + "List of VLAN STP configurations"; key "name"; + leaf name { type string; description @@ -176,13 +202,18 @@ module sonic-stp { } } - container STP_VLAN_PORT { - list STP_VLAN_PORT_LIST { + container stp-vlan-port { + description + "Vlan port configurations"; + + list stp-vlan-port-list { + description + "List of VLAN port configurations"; key "vlan-name ifname"; leaf vlan-name { type leafref { - path "../../../STP_VLAN/STP_VLAN_LIST/name"; + path "../../../stp-vlan/stp-vlan-list/name"; } description "Reference to Vlan"; @@ -190,7 +221,7 @@ module sonic-stp { leaf ifname { type leafref { - path "../../../STP_PORT/STP_PORT_LIST/ifname"; + path "../../../stp-port/stp-port-list/ifname"; } description "Reference to Ethernet interface or PortChannel"; @@ -200,13 +231,17 @@ module sonic-stp { } } - container STP_PORT { - list STP_PORT_LIST { + container stp-port { + description + "Port Configurations."; + + list stp-port-list { + description + "List of STP port List attributes."; key "ifname"; - //sonic-ext:dependent-on "STP_LIST"; - must "/sonic-spanning-tree/STP/STP_LIST" { - error-message "STP global configuration must exist"; - } + + sonic-ext:dependent-on "stp-list"; + leaf ifname { type string; description @@ -245,13 +280,13 @@ module sonic-stp { } leaf portfast { - must "current()!='true' or ../../../STP/STP_LIST[keyleaf='GLOBAL']/mode='pvst'" { + type boolean; + must "current()!='true' or ../../../stp-config/stp-list[keyleaf='GLOBAL']/mode='pvst'" { error-message "Configuration not allowed in MST mode"; error-app-tag stp-invalid; } - type boolean; description - "Enable/Disable portfast on port"; + "Enable/Disable portfast on port in PVST only"; } uses interfaceAttr; @@ -265,9 +300,18 @@ module sonic-stp { leaf link_type { type enumeration { - enum auto; - enum shared; - enum point-to-point; + enum auto { + description + "Specifies the interface's link type. Permissible values 'auto'"; + } + enum shared { + description + "Specifies the interface's link type. Permissible values 'shared'"; + } + enum point-to-point { + description + "Specifies the interface's link type. Permissible values 'point-to-point'"; + } } description "Specifies the interface's link type. Permissible values @@ -276,97 +320,108 @@ module sonic-stp { } } - container STP_MST { - list STP_MST_LIST { + container stp-mst { + description + "MST specific configuration container"; + + list stp-mst-list { + description + "List of MST global configurations"; max-elements 1; key "keyleaf"; - //sonic-ext:dependent-on "STP_LIST"; - must "/sonic-spanning-tree/STP/STP_LIST" { - error-message "STP global configuration must exist"; - } + + sonic-ext:dependent-on "stp-list"; leaf keyleaf { type enumeration { - enum GLOBAL; + enum GLOBAL { + description + "Global MST"; + } } description "Key node identifier. It's value is always GLOBAL"; } leaf name { - must "../../../STP/STP_LIST[keyleaf='GLOBAL']/mode='mst'" { + type string; + must "../../../stp-config/stp-list[keyleaf='GLOBAL']/mode='mst'" { error-message "Configuration allowed in MST mode"; error-app-tag stp-invalid; } - type string; description "MST Region name"; } leaf revision { - must "../../../STP/STP_LIST[keyleaf='GLOBAL']/mode='mst'" { + type uint32; + must "../../../stp-config/stp-list[keyleaf='GLOBAL']/mode='mst'" { error-message "Configuration allowed in MST mode"; error-app-tag stp-invalid; } - type uint32; description "MST Revision number"; } leaf max_hops { - must "../../../STP/STP_LIST[keyleaf='GLOBAL']/mode='mst'" { + type uint8; + must "../../../stp-config/stp-list[keyleaf='GLOBAL']/mode='mst'" { error-message "Configuration allowed in MST mode"; error-app-tag stp-invalid; } - type uint8; description "MST Max hops"; } leaf hello_time { - must "../../../STP/STP_LIST[keyleaf='GLOBAL']/mode='mst'" { + type uint8; + must "../../../stp-config/stp-list[keyleaf='GLOBAL']/mode='mst'" { error-message "Configuration allowed in MST mode"; error-app-tag stp-invalid; } - type uint8; description "MST hello time"; } leaf max_age { - must "../../../STP/STP_LIST[keyleaf='GLOBAL']/mode='mst'" { + type uint8; + must "../../../stp-config/stp-list[keyleaf='GLOBAL']/mode='mst'" { error-message "Configuration allowed in MST mode"; error-app-tag stp-invalid; } - type uint8; description "MST max age"; } leaf forward_delay { - must "../../../STP/STP_LIST[keyleaf='GLOBAL']/mode='mst'" { + type uint8; + must "../../../stp-config/stp-list[keyleaf='GLOBAL']/mode='mst'" { error-message "Configuration allowed in MST mode"; error-app-tag stp-invalid; } - type uint8; description "MST forward delay"; } leaf hold_count { - must "../../../STP/STP_LIST[keyleaf='GLOBAL']/mode='mst'" { + type uint8; + must "../../../stp-config/stp-list[keyleaf='GLOBAL']/mode='mst'" { error-message "Configuration allowed in MST mode"; error-app-tag stp-invalid; } - type uint8; description "MST hold count"; } } } - container STP_MST_INST { - list STP_MST_INST_LIST { + container stp-mst-inst { + description + "STP MST Instance Configuration."; + + list stp-mst-inst-list { + description + "List of STP MST Instance attributes."; key "instance"; leaf instance { @@ -393,13 +448,18 @@ module sonic-stp { } } - container STP_MST_PORT { - list STP_MST_PORT_LIST { + container stp-mst-port { + description + "STP MST Port configurations."; + + list stp-mst-port-list { + description + "STP MST Port List attributes"; key "inst_id ifname"; leaf inst_id { type leafref { - path "../../../STP_MST_INST/STP_MST_INST_LIST/instance"; + path "../../../stp-mst-inst/stp-mst-inst-list/instance"; } description "Reference to MST Instance"; @@ -407,9 +467,8 @@ module sonic-stp { leaf ifname { type leafref { - path "../../../STP_PORT/STP_PORT_LIST/ifname"; + path "../../../stp-port/stp-port-list/ifname"; } - description "Reference to Ethernet interface or PortChannel"; } From 1d1fc45a7534d755ad47a808473c8bf6a3a16308 Mon Sep 17 00:00:00 2001 From: Wajahat Razi Date: Wed, 22 Jan 2025 02:02:09 +0500 Subject: [PATCH 5/5] Updated the YANG model --- .../tests/yang_model_tests/tests/stp.json | 4 +- .../yang_model_tests/tests_config/stp.json | 8 +- .../yang-models/sonic-extension.yang | 1 + .../yang-models/sonic-stp.yang | 193 ++++++++++++------ 4 files changed, 133 insertions(+), 73 deletions(-) create mode 120000 src/sonic-yang-models/yang-models/sonic-extension.yang diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/stp.json b/src/sonic-yang-models/tests/yang_model_tests/tests/stp.json index c89174731831..ab2d565ce0d5 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/stp.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/stp.json @@ -1,6 +1,6 @@ { - "STP_GLOBAL_VALID": { - "desc": "Configure valid global STP settings" + "PVST_GLOBAL_VALID": { + "desc": "Configure valid global PVST settings" } } \ No newline at end of file diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/stp.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/stp.json index c47e2836df6e..bf64a30c81bb 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/stp.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/stp.json @@ -1,8 +1,8 @@ { - "STP_GLOBAL_VALID": { - "sonic-stp:sonic-spanning-tree": { - "sonic-spanning-tree:STP": { - "STP_LIST": [ + "PVST_GLOBAL_VALID": { + "sonic-stp:spanning-tree": { + "spanning-tree:stp-config": { + "stp-list": [ { "keyleaf": "GLOBAL", "mode": "pvst", diff --git a/src/sonic-yang-models/yang-models/sonic-extension.yang b/src/sonic-yang-models/yang-models/sonic-extension.yang new file mode 120000 index 000000000000..dc60e0e88719 --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-extension.yang @@ -0,0 +1 @@ +/path/to/sonic-extension.yang \ No newline at end of file diff --git a/src/sonic-yang-models/yang-models/sonic-stp.yang b/src/sonic-yang-models/yang-models/sonic-stp.yang index fe5cac583fec..4d8333790204 100644 --- a/src/sonic-yang-models/yang-models/sonic-stp.yang +++ b/src/sonic-yang-models/yang-models/sonic-stp.yang @@ -1,27 +1,27 @@ module sonic-stp { + yang-version 1.1; + namespace "http://github.com/sonic-net/sonic-stp"; + prefix stp; import sonic-extension { prefix sonic-ext; } - - description - "SONiC STP YANG model for PVST and MST configurations"; - revision 2024-12-30 { - description - "Version01 for combined PVST configurations."; - } + description + "This module contains the collection of YANG definitions for the PVST & MSTP"; - extension dependent-on { - argument "dependency"; + revision 2024-12-30 { description - "Indicates module dependencies"; + "Version01 for combined PVST & MSTP configurations."; } grouping vlanModeAttr { + description + "Configuration parameters"; + leaf forward_delay { type uint8 { range "4..30" { @@ -74,6 +74,9 @@ module sonic-stp { } grouping interfaceAttr { + description + "Configuration parameters of interfaces."; + leaf path_cost { type uint64 { range "1..200000000" { @@ -99,15 +102,26 @@ module sonic-stp { } } - container sonic-spanning-tree { + container spanning-tree { + description + "Top level container for SONiC Spanning Tree configurations"; + + container stp-config { + description + "Global configurations"; - container STP { - list STP_LIST { + list stp-list { + description + "STP list containing global attributes"; max-elements 1; key "keyleaf"; + leaf keyleaf { type enumeration { - enum GLOBAL; + enum GLOBAL { + description + "Global configuration identifier"; + } } description "Key node identifier. It's value is always GLOBAL"; @@ -115,8 +129,14 @@ module sonic-stp { leaf mode { type enumeration { - enum pvst; - enum mst; + enum pvst { + description + "Per VLAN Spanning Tree Mode"; + } + enum mst { + description + "Multiple Spanning Tree Mode"; + } } mandatory true; description @@ -124,17 +144,17 @@ module sonic-stp { } leaf rootguard_timeout { - must "../../../STP/STP_LIST[keyleaf='GLOBAL']/mode!='mst'" { - error-message "Configuration not allowed in MST mode"; - error-app-tag stp-invalid; - } - type uint16 { range "5..600" { error-message "Invalid Root-guard Timeout value."; } } units seconds; + must "../../../stp-config/stp-list[keyleaf='GLOBAL']/mode!='mst'" { + error-message "Root guard timeout not allowed in MST mode"; + error-app-tag stp-invalid; + } + description "Once superior BPDUs stop coming on the port, device will wait for a period until root guard timeout before @@ -145,9 +165,15 @@ module sonic-stp { } } - container STP_VLAN { - list STP_VLAN_LIST { + container stp-vlan { + description + "VLAN Specific STP Configurations"; + + list stp-vlan-list { + description + "List of VLAN STP configurations"; key "name"; + leaf name { type string; description @@ -176,13 +202,18 @@ module sonic-stp { } } - container STP_VLAN_PORT { - list STP_VLAN_PORT_LIST { + container stp-vlan-port { + description + "Vlan port configurations"; + + list stp-vlan-port-list { + description + "List of VLAN port configurations"; key "vlan-name ifname"; leaf vlan-name { type leafref { - path "../../../STP_VLAN/STP_VLAN_LIST/name"; + path "../../../stp-vlan/stp-vlan-list/name"; } description "Reference to Vlan"; @@ -190,7 +221,7 @@ module sonic-stp { leaf ifname { type leafref { - path "../../../STP_PORT/STP_PORT_LIST/ifname"; + path "../../../stp-port/stp-port-list/ifname"; } description "Reference to Ethernet interface or PortChannel"; @@ -200,13 +231,17 @@ module sonic-stp { } } - container STP_PORT { - list STP_PORT_LIST { + container stp-port { + description + "Port Configurations."; + + list stp-port-list { + description + "List of STP port List attributes."; key "ifname"; - //sonic-ext:dependent-on "STP_LIST"; - must "/sonic-spanning-tree/STP/STP_LIST" { - error-message "STP global configuration must exist"; - } + + sonic-ext:dependent-on "stp-list"; + leaf ifname { type string; description @@ -245,13 +280,13 @@ module sonic-stp { } leaf portfast { - must "current()!='true' or ../../../STP/STP_LIST[keyleaf='GLOBAL']/mode='pvst'" { + type boolean; + must "current()!='true' or ../../../stp-config/stp-list[keyleaf='GLOBAL']/mode='pvst'" { error-message "Configuration not allowed in MST mode"; error-app-tag stp-invalid; } - type boolean; description - "Enable/Disable portfast on port"; + "Enable/Disable portfast on port in PVST only"; } uses interfaceAttr; @@ -265,9 +300,18 @@ module sonic-stp { leaf link_type { type enumeration { - enum auto; - enum shared; - enum point-to-point; + enum auto { + description + "Specifies the interface's link type. Permissible values 'auto'"; + } + enum shared { + description + "Specifies the interface's link type. Permissible values 'shared'"; + } + enum point-to-point { + description + "Specifies the interface's link type. Permissible values 'point-to-point'"; + } } description "Specifies the interface's link type. Permissible values @@ -276,97 +320,108 @@ module sonic-stp { } } - container STP_MST { - list STP_MST_LIST { + container stp-mst { + description + "MST specific configuration container"; + + list stp-mst-list { + description + "List of MST global configurations"; max-elements 1; key "keyleaf"; - //sonic-ext:dependent-on "STP_LIST"; - must "/sonic-spanning-tree/STP/STP_LIST" { - error-message "STP global configuration must exist"; - } + + sonic-ext:dependent-on "stp-list"; leaf keyleaf { type enumeration { - enum GLOBAL; + enum GLOBAL { + description + "Global MST"; + } } description "Key node identifier. It's value is always GLOBAL"; } leaf name { - must "../../../STP/STP_LIST[keyleaf='GLOBAL']/mode='mst'" { + type string; + must "../../../stp-config/stp-list[keyleaf='GLOBAL']/mode='mst'" { error-message "Configuration allowed in MST mode"; error-app-tag stp-invalid; } - type string; description "MST Region name"; } leaf revision { - must "../../../STP/STP_LIST[keyleaf='GLOBAL']/mode='mst'" { + type uint32; + must "../../../stp-config/stp-list[keyleaf='GLOBAL']/mode='mst'" { error-message "Configuration allowed in MST mode"; error-app-tag stp-invalid; } - type uint32; description "MST Revision number"; } leaf max_hops { - must "../../../STP/STP_LIST[keyleaf='GLOBAL']/mode='mst'" { + type uint8; + must "../../../stp-config/stp-list[keyleaf='GLOBAL']/mode='mst'" { error-message "Configuration allowed in MST mode"; error-app-tag stp-invalid; } - type uint8; description "MST Max hops"; } leaf hello_time { - must "../../../STP/STP_LIST[keyleaf='GLOBAL']/mode='mst'" { + type uint8; + must "../../../stp-config/stp-list[keyleaf='GLOBAL']/mode='mst'" { error-message "Configuration allowed in MST mode"; error-app-tag stp-invalid; } - type uint8; description "MST hello time"; } leaf max_age { - must "../../../STP/STP_LIST[keyleaf='GLOBAL']/mode='mst'" { + type uint8; + must "../../../stp-config/stp-list[keyleaf='GLOBAL']/mode='mst'" { error-message "Configuration allowed in MST mode"; error-app-tag stp-invalid; } - type uint8; description "MST max age"; } leaf forward_delay { - must "../../../STP/STP_LIST[keyleaf='GLOBAL']/mode='mst'" { + type uint8; + must "../../../stp-config/stp-list[keyleaf='GLOBAL']/mode='mst'" { error-message "Configuration allowed in MST mode"; error-app-tag stp-invalid; } - type uint8; description "MST forward delay"; } leaf hold_count { - must "../../../STP/STP_LIST[keyleaf='GLOBAL']/mode='mst'" { + type uint8; + must "../../../stp-config/stp-list[keyleaf='GLOBAL']/mode='mst'" { error-message "Configuration allowed in MST mode"; error-app-tag stp-invalid; } - type uint8; description "MST hold count"; } } } - container STP_MST_INST { - list STP_MST_INST_LIST { + container stp-mst-inst { + description + "STP MST Instance Configuration."; + + list stp-mst-inst-list { + description + "List of STP MST Instance attributes."; key "instance"; leaf instance { @@ -393,13 +448,18 @@ module sonic-stp { } } - container STP_MST_PORT { - list STP_MST_PORT_LIST { + container stp-mst-port { + description + "STP MST Port configurations."; + + list stp-mst-port-list { + description + "STP MST Port List attributes"; key "inst_id ifname"; leaf inst_id { type leafref { - path "../../../STP_MST_INST/STP_MST_INST_LIST/instance"; + path "../../../stp-mst-inst/stp-mst-inst-list/instance"; } description "Reference to MST Instance"; @@ -407,9 +467,8 @@ module sonic-stp { leaf ifname { type leafref { - path "../../../STP_PORT/STP_PORT_LIST/ifname"; + path "../../../stp-port/stp-port-list/ifname"; } - description "Reference to Ethernet interface or PortChannel"; }