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 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..ddcfeed3e3fa 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;