From 7fc547147828f06084830cd33adb07b8e52ba5d8 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..eb9663bb6c71 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": "Invalid value \"badaddr\" in \"mac_addr\" element." } } 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 03f96de28f67..943a639fec51 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 @@ -274,5 +274,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;