From e6fa396aaa14e7ac12e659725963e3514c97bbb6 Mon Sep 17 00:00:00 2001 From: Akhilesh Samineni <47657796+AkhileshSamineni@users.noreply.github.com> Date: Fri, 12 May 2023 11:24:19 +0530 Subject: [PATCH] SONiC Yang model support for IPv6 link local (#15021) This is backport of #14757 SONiC Yang model support for IPv6 link local What I did Created SONiC Yang model for IPv6 link local How I did it Defined Yang models for IPv6 link local based on https://github.com/sonic-net/SONiC/blob/master/doc/ipv6/ipv6_link_local.md How to verify it Added enable test case. Signed-off-by: Akhilesh Samineni akhilesh.samineni@broadcom.com --- src/sonic-yang-models/doc/Configuration.md | 24 ++++- .../tests/files/sample_config_db.json | 9 +- .../yang_model_tests/tests/interface.json | 7 ++ .../yang_model_tests/tests/portchannel.json | 7 ++ .../tests/yang_model_tests/tests/vlan.json | 7 ++ .../tests_config/interface.json | 56 ++++++++++++ .../tests_config/portchannel.json | 74 ++++++++++++++++ .../yang_model_tests/tests_config/vlan.json | 88 +++++++++++++++++++ .../yang-models/sonic-interface.yang | 6 ++ .../yang-models/sonic-portchannel.yang | 7 ++ .../yang-models/sonic-vlan.yang | 6 ++ 11 files changed, 287 insertions(+), 4 deletions(-) diff --git a/src/sonic-yang-models/doc/Configuration.md b/src/sonic-yang-models/doc/Configuration.md index b32a10c32a..f681aad44a 100644 --- a/src/sonic-yang-models/doc/Configuration.md +++ b/src/sonic-yang-models/doc/Configuration.md @@ -27,7 +27,8 @@ Table of Contents * [Device neighbor metada](#device-neighbor-metada) * [DHCP_RELAY](#dhcp_relay) * [DSCP_TO_TC_MAP](#dscp_to_tc_map) - * [FLEX_COUNTER_TABLE](#flex_counter_table) + * [FLEX_COUNTER_TABLE](#flex_counter_table) + * [IPv6 Link-local] (#ipv6-link-local) * [KDUMP](#kdump) * [Kubernetes Master](#kubernetes-master) * [L2 Neighbors](#l2-neighbors) @@ -950,6 +951,27 @@ instance is supported in SONiC. ``` +### IPv6 Link-local +``` +{ + "INTERFACE": { + "Ethernet8": { + "ipv6_use_link_local_only": "disable" + } + }, + "PORTCHANNEL_INTERFACE": { + "PortChannel01": { + "ipv6_use_link_local_only": "enable" + } + }, + "VLAN_INTERFACE": { + "Vlan1000": { + "ipv6_use_link_local_only": "enable" + } + } +} +``` + ### KDUMP ``` diff --git a/src/sonic-yang-models/tests/files/sample_config_db.json b/src/sonic-yang-models/tests/files/sample_config_db.json index 9f4d8516a8..4b534157bf 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -112,7 +112,8 @@ "PORTCHANNEL_INTERFACE": { "PortChannel0003": { "nat_zone": "1", - "loopback_action": "drop" + "loopback_action": "drop", + "ipv6_use_link_local_only": "enable" }, "PortChannel0004": {"vrf_name": "Vrf_blue"}, "PortChannel42|10.1.0.1/31": {}, @@ -128,7 +129,8 @@ "VLAN_INTERFACE": { "Vlan111": { "nat_zone": "0", - "loopback_action": "forward" + "loopback_action": "forward", + "ipv6_use_link_local_only": "disable" }, "Vlan777": {}, "Vlan111|2a04:5555:45:6709::1/64": { @@ -1005,7 +1007,8 @@ "Ethernet16": {}, "Ethernet18": { "nat_zone": "1", - "loopback_action": "forward" + "loopback_action": "forward", + "ipv6_use_link_local_only": "enable" }, "Ethernet112|2a04:5555:40:a709::2/126": { "scope": "global", 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 ed561f25bc..b0532d90e1 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 @@ -22,5 +22,12 @@ "desc": "INCORRECT LOOPBACK ACTION IN INTERFACE TABLE.", "eStrKey" : "Pattern", "eStr": ["drop|forward"] + }, + "INTERFACE_ENABLE_IPV6_LINK_LOCAL": { + "desc": "Enable the ipv6 link-local." + }, + "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." } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/portchannel.json b/src/sonic-yang-models/tests/yang_model_tests/tests/portchannel.json index ae7a7dffd9..c44ffef291 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/portchannel.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/portchannel.json @@ -73,5 +73,12 @@ "desc": "INCORRECT LOOPBACK ACTION IN PORTCHANNEL_INTERFACE TABLE.", "eStrKey" : "Pattern", "eStr": ["drop|forward"] + }, + "PORTCHANNEL_INTERFACE_ENABLE_IPV6_LINK_LOCAL": { + "desc": "Enable the ipv6 link-local." + }, + "PORTCHANNEL_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." } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/vlan.json b/src/sonic-yang-models/tests/yang_model_tests/tests/vlan.json index cf5fccf02b..7f1cb4eb35 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/vlan.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/vlan.json @@ -79,5 +79,12 @@ "desc": "INCORRECT LOOPBACK ACTION IN VLAN_INTERFACE TABLE.", "eStrKey" : "Pattern", "eStr": ["drop|forward"] + }, + "VLAN_INTERFACE_ENABLE_IPV6_LINK_LOCAL": { + "desc": "Enable the ipv6 link-local." + }, + "VLAN_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." } } 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 2f20f8475b..b0b9fdb681 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 @@ -209,5 +209,61 @@ ] } } + }, + "INTERFACE_ENABLE_IPV6_LINK_LOCAL": { + "sonic-interface:sonic-interface": { + "sonic-interface:INTERFACE": { + "INTERFACE_LIST": [ + { + "name": "Ethernet8", + "ipv6_use_link_local_only": "enable" + } + ] + } + }, + "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 + } + ] + } + } + }, + "INTERFACE_INVALID_ENABLE_IPV6_LINK_LOCAL": { + "sonic-interface:sonic-interface": { + "sonic-interface:INTERFACE": { + "INTERFACE_LIST": [ + { + "name": "Ethernet8", + "ipv6_use_link_local_only": "true" + } + ] + } + }, + "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 + } + ] + } + } } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/portchannel.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/portchannel.json index 36f2484fa3..7837d05443 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/portchannel.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/portchannel.json @@ -428,5 +428,79 @@ ] } } + }, + "PORTCHANNEL_INTERFACE_ENABLE_IPV6_LINK_LOCAL": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet0", + "speed": 25000 + } + ] + } + }, + "sonic-portchannel:sonic-portchannel": { + "sonic-portchannel:PORTCHANNEL": { + "PORTCHANNEL_LIST": [ + { + "admin_status": "up", + "min_links": "1", + "mtu": "9100", + "name": "PortChannel0001" + } + ] + }, + "sonic-portchannel:PORTCHANNEL_INTERFACE": { + "PORTCHANNEL_INTERFACE_LIST": [ + { + "name": "PortChannel0001", + "ipv6_use_link_local_only": "enable" + } + ] + } + } + }, + "PORTCHANNEL_INTERFACE_INVALID_ENABLE_IPV6_LINK_LOCAL": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet0", + "speed": 25000 + } + ] + } + }, + "sonic-portchannel:sonic-portchannel": { + "sonic-portchannel:PORTCHANNEL": { + "PORTCHANNEL_LIST": [ + { + "admin_status": "up", + "min_links": "1", + "mtu": "9100", + "name": "PortChannel0001" + } + ] + }, + "sonic-portchannel:PORTCHANNEL_INTERFACE": { + "PORTCHANNEL_INTERFACE_LIST": [ + { + "name": "PortChannel0001", + "ipv6_use_link_local_only": "true" + } + ] + } + } } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/vlan.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/vlan.json index c5934bc39c..c4db119b7f 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/vlan.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/vlan.json @@ -626,5 +626,93 @@ ] } } + }, + "VLAN_INTERFACE_ENABLE_IPV6_LINK_LOCAL": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "mtu": 9000, + "lanes": "1", + "name": "Ethernet0", + "speed": 25000 + } + ] + } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "description": "vlan_nat", + "name": "Vlan100" + } + ] + }, + "sonic-vlan:VLAN_MEMBER": { + "VLAN_MEMBER_LIST": [ + { + "port": "Ethernet0", + "tagging_mode": "tagged", + "name": "Vlan100" + } + ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan100", + "ipv6_use_link_local_only": "enable" + } + ] + } + } + }, + "VLAN_INTERFACE_INVALID_ENABLE_IPV6_LINK_LOCAL": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "mtu": 9000, + "lanes": "1", + "name": "Ethernet0", + "speed": 25000 + } + ] + } + }, + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "description": "vlan_nat", + "name": "Vlan100" + } + ] + }, + "sonic-vlan:VLAN_MEMBER": { + "VLAN_MEMBER_LIST": [ + { + "port": "Ethernet0", + "tagging_mode": "tagged", + "name": "Vlan100" + } + ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan100", + "ipv6_use_link_local_only": "true" + } + ] + } + } } } diff --git a/src/sonic-yang-models/yang-models/sonic-interface.yang b/src/sonic-yang-models/yang-models/sonic-interface.yang index afd46a6555..f8c676b7ca 100644 --- a/src/sonic-yang-models/yang-models/sonic-interface.yang +++ b/src/sonic-yang-models/yang-models/sonic-interface.yang @@ -75,6 +75,12 @@ module sonic-interface { } } + leaf ipv6_use_link_local_only { + description "Enable/Disable IPv6 link local address on interface"; + type stypes:mode-status; + default disable; + } + leaf loopback_action { description "Packet action when a packet ingress and gets routed on the same IP interface"; type stypes:loopback_action; diff --git a/src/sonic-yang-models/yang-models/sonic-portchannel.yang b/src/sonic-yang-models/yang-models/sonic-portchannel.yang index 717e3924c4..791094a7c0 100644 --- a/src/sonic-yang-models/yang-models/sonic-portchannel.yang +++ b/src/sonic-yang-models/yang-models/sonic-portchannel.yang @@ -181,6 +181,13 @@ module sonic-portchannel { enum disable; } } + + leaf ipv6_use_link_local_only { + description "Enable/Disable IPv6 link local address on portchannel interface"; + type stypes:mode-status; + default disable; + } + } /* end of list PORTCHANNEL_INTERFACE_LIST */ list PORTCHANNEL_INTERFACE_IPPREFIX_LIST { diff --git a/src/sonic-yang-models/yang-models/sonic-vlan.yang b/src/sonic-yang-models/yang-models/sonic-vlan.yang index b8f3e28c43..a2a2fbabb9 100644 --- a/src/sonic-yang-models/yang-models/sonic-vlan.yang +++ b/src/sonic-yang-models/yang-models/sonic-vlan.yang @@ -102,6 +102,12 @@ module sonic-vlan { } } + leaf ipv6_use_link_local_only { + description "Enable/Disable IPv6 link local address on vlan interface"; + type stypes:mode-status; + default disable; + } + leaf loopback_action { description "Packet action when a packet ingress and gets routed on the same IP interface"; type stypes:loopback_action;