From 6e1dcb7bc4fb961235bdcced61581f9edc47fd7c Mon Sep 17 00:00:00 2001 From: Brad House Date: Fri, 29 Nov 2024 08:17:38 -0500 Subject: [PATCH] YANG sonic-interface: add missing mac_addr leaf mac_addr support was added in the INTERFACES table by https://github.com/sonic-net/sonic-swss/pull/814 in 2020 but the YANG models were never updated to reflect that change. Signed-off-by: Brad House (@bradh352) --- .../yang_model_tests/tests/interface.json | 7 +++ .../tests_config/interface.json | 58 +++++++++++++++++++ .../yang-models/sonic-interface.yang | 9 +++ 3 files changed, 74 insertions(+) diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/interface.json b/src/sonic-yang-models/tests/yang_model_tests/tests/interface.json index b0532d90e129..a5af525aa9cf 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/interface.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/interface.json @@ -29,5 +29,12 @@ "INTERFACE_INVALID_ENABLE_IPV6_LINK_LOCAL": { "desc": "Enable the ipv6 link-local as true.", "eStr": "Invalid value \"true\" in \"ipv6_use_link_local_only\" element." + }, + "INTERFACE_MAC_ADDR": { + "desc": "Set administrator-provided interface mac address." + }, + "INTERFACE_INVALID_MAC_ADDR": { + "desc": "Set invalid interface mac address.", + "eStr": "Value \"badaddr\" does not satisfy the constraint \"[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}\" (range, length, or pattern)." } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/interface.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/interface.json index b0b9fdb68197..4a6e0252af59 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/interface.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/interface.json @@ -265,5 +265,63 @@ ] } } + }, + "INTERFACE_MAC_ADDR": { + "sonic-interface:sonic-interface": { + "sonic-interface:INTERFACE": { + "INTERFACE_LIST": [ + { + "name": "Ethernet8", + "mac_addr": "02:26:9b:73:c1:1a" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth8", + "description": "Ethernet8", + "fec": "rs", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet8", + "speed": 25000, + "mode":"trunk" + } + ] + } + } + }, + "INTERFACE_INVALID_MAC_ADDR": { + "sonic-interface:sonic-interface": { + "sonic-interface:INTERFACE": { + "INTERFACE_LIST": [ + { + "name": "Ethernet8", + "mac_addr": "badaddr" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth8", + "description": "Ethernet8", + "fec": "rs", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet8", + "speed": 25000, + "mode":"trunk" + } + ] + } + } } } diff --git a/src/sonic-yang-models/yang-models/sonic-interface.yang b/src/sonic-yang-models/yang-models/sonic-interface.yang index f8c676b7ca84..6c21b5995cba 100644 --- a/src/sonic-yang-models/yang-models/sonic-interface.yang +++ b/src/sonic-yang-models/yang-models/sonic-interface.yang @@ -5,6 +5,10 @@ module sonic-interface { namespace "http://github.com/sonic-net/sonic-interface"; prefix intf; + import ietf-yang-types { + prefix yang; + } + import sonic-types { prefix stypes; } @@ -81,6 +85,11 @@ module sonic-interface { default disable; } + leaf mac_addr { + description "Assign Administrator-provided MAC address to Interface"; + type yang:mac-address; + } + leaf loopback_action { description "Packet action when a packet ingress and gets routed on the same IP interface"; type stypes:loopback_action;