From a2b40097501044c59673d63fff50701016626aa7 Mon Sep 17 00:00:00 2001 From: Akhilesh Samineni Date: Mon, 11 Oct 2021 09:15:03 -0700 Subject: [PATCH 1/8] SONiC Yang model for DHCP-Relay parameters Added DHCPv4 Source interface, Link select, Max hop count, Server VRF, Policy action and VRF Select options. Added DHCPv6 Servers, Source interface, Max hop count, Server VRF and VRF Select options. Tables: VLAN. --- .../yang-models/sonic-types.yang | 15 ++++++ .../yang-models/sonic-vlan.yang | 47 +++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/src/sonic-yang-models/yang-models/sonic-types.yang b/src/sonic-yang-models/yang-models/sonic-types.yang index ac3ceb805ff2..0fccca1d1aea 100644 --- a/src/sonic-yang-models/yang-models/sonic-types.yang +++ b/src/sonic-yang-models/yang-models/sonic-types.yang @@ -184,4 +184,19 @@ module sonic-types { enum transit; } } + + typedef relay_policy_action { + type enumeration { + enum discard; + enum append; + enum replace; + } + } + + typedef mode_enable { + type enumeration { + enum enable; + enum disable; + } + } } diff --git a/src/sonic-yang-models/yang-models/sonic-vlan.yang b/src/sonic-yang-models/yang-models/sonic-vlan.yang index c63bc6b46ac4..a1e8f9e51466 100644 --- a/src/sonic-yang-models/yang-models/sonic-vlan.yang +++ b/src/sonic-yang-models/yang-models/sonic-vlan.yang @@ -167,6 +167,53 @@ module sonic-vlan { type inet:ip-address; } + leaf-list dhcpv6_servers{ + type inet:ipv6-address; + } + + leaf dhcp_relay_link_select { + type stypes:mode_enable; + } + + leaf dhcp_relay_src_intf { + type string; + } + + leaf dhcp_relay_max_hop_count { + type uint32; + } + + leaf dhcp_server_vrf { + type string; + } + + leaf dhcp_relay_vrf_select { + type stypes:mode_enable; + default disable; + } + + leaf dhcp_relay_policy_action { + type stypes:relay_policy_action; + default discard; + } + + leaf dhcpv6_relay_src_intf { + type string; + } + + leaf dhcpv6_relay_max_hop_count { + type uint32; + } + + leaf dhcpv6_server_vrf { + type string; + } + + leaf dhcpv6_relay_vrf_select { + type stypes:mode_enable; + default disable; + } + leaf mtu { type uint16 { range 1..9216; From 557cc738e9f985be47c48746529c54d5664d0231 Mon Sep 17 00:00:00 2001 From: Akhilesh Samineni Date: Thu, 21 Oct 2021 03:27:41 -0700 Subject: [PATCH 2/8] Added test cases for dhcp-yang parameters. --- .../tests/files/sample_config_db.json | 22 +++ .../tests/yang_model_tests/tests/vlan.json | 10 ++ .../yang_model_tests/tests_config/vlan.json | 139 ++++++++++++++++++ .../yang-models/sonic-vlan.yang | 40 ++++- 4 files changed, 203 insertions(+), 8 deletions(-) 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 bd7aff24b554..4302d51d982b 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -220,6 +220,17 @@ "dhcp_servers": [ "10.222.72.116" ], + "dhcp_relay_src_intf": "Loopback0", + "dhcp_relay_link_select": "enable", + "dhcp_relay_vrf_select": "enable", + "dhcp_relay_policy_action": "append", + "dhcp_relay_max_hop_count": "5", + "dhcpv6_servers": [ + "2a04:5555:41::11" + ], + "dhcpv6_relay_max_hop_count": "6", + "dhcpv6_relay_src_intf": "Loopback0", + "dhcpv6_relay_vrf_select": "enable", "vlanid": "111", "mtu": "9216", "admin_status": "up" @@ -229,6 +240,17 @@ "dhcp_servers": [ "10.222.72.116" ], + "dhcp_relay_src_intf": "Loopback0", + "dhcp_relay_link_select": "enable", + "dhcp_relay_vrf_select": "enable", + "dhcp_relay_policy_action": "append", + "dhcp_relay_max_hop_count": "7", + "dhcpv6_servers": [ + "2a04:5555:41::11" + ], + "dhcpv6_relay_max_hop_count": "8", + "dhcpv6_relay_src_intf": "Loopback0", + "dhcpv6_relay_vrf_select": "enable", "vlanid": "777", "mtu": "9216", "admin_status": "up" 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 2d38ef453c32..a28575fe77c0 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 @@ -17,6 +17,10 @@ "eStrKey" : "InvalidValue", "eStr": ["dhcp_servers"] }, + "DHCPV6_SERVER_INCORRECT_FORMAT": { + "desc": "Add dhcpv6_server which is not in correct ipv6-address format.", + "eStrKey" : "Pattern" + }, "VLAN_WITH_NON_EXIST_PORT": { "desc": "Configure a member port in VLAN_MEMBER table which does not exist.", "eStrKey" : "InvalidValue" @@ -43,5 +47,11 @@ }, "VLAN_INTERFACE_VALID_NAT_ZONE_RANGE": { "desc": "Configure valid value for nat zone." + }, + "DHCP_SERVER_VALID_PARAMETERS_FORMAT": { + "desc": "Add dhcp_server and it's parameters in correct format." + }, + "DHCPV6_SERVER_VALID_PARAMETERS_FORMAT": { + "desc": "Add dhcpv6_server and it's parameters in correct format." } } 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 0faa3926b21e..6157a269711d 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 @@ -33,6 +33,23 @@ } } }, + "DHCPV6_SERVER_INCORRECT_FORMAT": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "admin_status": "up", + "description": "v6server_vlan", + "dhcpv6_servers": [ + "2001:1:2" + ], + "mtu": "9216", + "name": "Vlan500" + } + ] + } + } + }, "TAGGING_MODE_WRONG_VALUE": { "sonic-port:sonic-port": { "sonic-port:PORT": { @@ -367,5 +384,127 @@ ] } } + }, + "DHCP_SERVER_VALID_PARAMETERS_FORMAT": { + "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": [ + { + "admin_status": "up", + "description": "server_vlan", + "dhcp_servers": [ + "10.186.72.10" + ], + "dhcp_relay_src_intf": "Loopback1", + "dhcp_relay_link_select": "enable", + "dhcp_relay_max_hop_count": "10", + "dhcp_server_vrf": "VrfRed", + "dhcp_relay_vrf_select": "enable", + "dhcp_relay_policy_action": "append", + "mtu": "9216", + "name": "Vlan300" + } + ] + }, + "sonic-vlan:VLAN_MEMBER": { + "VLAN_MEMBER_LIST": [ + { + "port": "Ethernet0", + "tagging_mode": "tagged", + "name": "Vlan300" + } + ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_IPPREFIX_LIST": [ + { + "family": "IPv4", + "ip-prefix": "20.0.0.1/24", + "scope": "global", + "name": "Vlan300" + } + ], + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan300" + } + ] + } + } + }, + "DHCPV6_SERVER_VALID_PARAMETERS_FORMAT": { + "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": [ + { + "admin_status": "up", + "description": "v6server_vlan", + "dhcpv6_servers": [ + "2001:1::2" + ], + "dhcpv6_relay_src_intf": "Loopback1", + "dhcpv6_relay_max_hop_count": "10", + "dhcpv6_server_vrf": "VrfRed", + "dhcpv6_relay_vrf_select": "enable", + "mtu": "9216", + "name": "Vlan400" + } + ] + }, + "sonic-vlan:VLAN_MEMBER": { + "VLAN_MEMBER_LIST": [ + { + "port": "Ethernet0", + "tagging_mode": "tagged", + "name": "Vlan400" + } + ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_IPPREFIX_LIST": [ + { + "family": "IPv6", + "ip-prefix": "2002::1/64", + "scope": "global", + "name": "Vlan400" + } + ], + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan400" + } + ] + } + } } } diff --git a/src/sonic-yang-models/yang-models/sonic-vlan.yang b/src/sonic-yang-models/yang-models/sonic-vlan.yang index a1e8f9e51466..c600bec0a4b5 100644 --- a/src/sonic-yang-models/yang-models/sonic-vlan.yang +++ b/src/sonic-yang-models/yang-models/sonic-vlan.yang @@ -164,52 +164,76 @@ module sonic-vlan { } leaf-list dhcp_servers { + description "Configure the dhcp v4 servers"; type inet:ip-address; } - leaf-list dhcpv6_servers{ - type inet:ipv6-address; + leaf dhcp_relay_src_intf { + description "Set source interface for the relay"; + type string; } leaf dhcp_relay_link_select { + description "Enable/Disable link-select option for the relay"; type stypes:mode_enable; } - leaf dhcp_relay_src_intf { - type string; - } - leaf dhcp_relay_max_hop_count { - type uint32; + description "Max hop count for the relay"; + type uint8 { + range "1..15" { + error-message "Invalid max hop count for the relay"; + error-app-tag max-hop-count-invalid; + } + } + default "10"; } leaf dhcp_server_vrf { + description "Vrf configured on the server"; type string; } leaf dhcp_relay_vrf_select { + description "Enable/Disable vrf-select sub-option for the relay"; type stypes:mode_enable; default disable; } leaf dhcp_relay_policy_action { + description "Configure policy action for the relay"; type stypes:relay_policy_action; default discard; } + leaf-list dhcpv6_servers { + description "Configure the dhcp v6 servers"; + type inet:ipv6-address; + } + leaf dhcpv6_relay_src_intf { + description "Set source interface for the relay"; type string; } leaf dhcpv6_relay_max_hop_count { - type uint32; + description "Max hop count for the relay"; + type uint8 { + range "1..15" { + error-message "Invalid max hop count for the relay"; + error-app-tag max-hop-count-invalid; + } + } + default "10"; } leaf dhcpv6_server_vrf { + description "Vrf configured on the server"; type string; } leaf dhcpv6_relay_vrf_select { + description "Enable/Disable vrf-select sub-option for the relay"; type stypes:mode_enable; default disable; } From d466e174c572d0ea09a1908050fbe1d81cf59f59 Mon Sep 17 00:00:00 2001 From: Akhilesh Samineni Date: Fri, 22 Oct 2021 06:22:47 -0700 Subject: [PATCH 3/8] Removed the fields which doesn't have backend support. Signed-off-by: Akhilesh Samineni --- .../tests/files/sample_config_db.json | 16 ----- .../tests/yang_model_tests/tests/vlan.json | 8 +-- .../yang_model_tests/tests_config/vlan.json | 10 --- .../yang-models/sonic-vlan.yang | 65 ------------------- 4 files changed, 4 insertions(+), 95 deletions(-) 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 4302d51d982b..e99416bede48 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -220,17 +220,9 @@ "dhcp_servers": [ "10.222.72.116" ], - "dhcp_relay_src_intf": "Loopback0", - "dhcp_relay_link_select": "enable", - "dhcp_relay_vrf_select": "enable", - "dhcp_relay_policy_action": "append", - "dhcp_relay_max_hop_count": "5", "dhcpv6_servers": [ "2a04:5555:41::11" ], - "dhcpv6_relay_max_hop_count": "6", - "dhcpv6_relay_src_intf": "Loopback0", - "dhcpv6_relay_vrf_select": "enable", "vlanid": "111", "mtu": "9216", "admin_status": "up" @@ -240,17 +232,9 @@ "dhcp_servers": [ "10.222.72.116" ], - "dhcp_relay_src_intf": "Loopback0", - "dhcp_relay_link_select": "enable", - "dhcp_relay_vrf_select": "enable", - "dhcp_relay_policy_action": "append", - "dhcp_relay_max_hop_count": "7", "dhcpv6_servers": [ "2a04:5555:41::11" ], - "dhcpv6_relay_max_hop_count": "8", - "dhcpv6_relay_src_intf": "Loopback0", - "dhcpv6_relay_vrf_select": "enable", "vlanid": "777", "mtu": "9216", "admin_status": "up" 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 a28575fe77c0..74adac2f9c3d 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 @@ -48,10 +48,10 @@ "VLAN_INTERFACE_VALID_NAT_ZONE_RANGE": { "desc": "Configure valid value for nat zone." }, - "DHCP_SERVER_VALID_PARAMETERS_FORMAT": { - "desc": "Add dhcp_server and it's parameters in correct format." + "DHCP_SERVER_VALID_FORMAT": { + "desc": "Add dhcp_server in correct format." }, - "DHCPV6_SERVER_VALID_PARAMETERS_FORMAT": { - "desc": "Add dhcpv6_server and it's parameters in correct format." + "DHCPV6_SERVER_VALID_FORMAT": { + "desc": "Add dhcpv6_server in correct format." } } 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 6157a269711d..38a13425e5dd 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 @@ -410,12 +410,6 @@ "dhcp_servers": [ "10.186.72.10" ], - "dhcp_relay_src_intf": "Loopback1", - "dhcp_relay_link_select": "enable", - "dhcp_relay_max_hop_count": "10", - "dhcp_server_vrf": "VrfRed", - "dhcp_relay_vrf_select": "enable", - "dhcp_relay_policy_action": "append", "mtu": "9216", "name": "Vlan300" } @@ -472,10 +466,6 @@ "dhcpv6_servers": [ "2001:1::2" ], - "dhcpv6_relay_src_intf": "Loopback1", - "dhcpv6_relay_max_hop_count": "10", - "dhcpv6_server_vrf": "VrfRed", - "dhcpv6_relay_vrf_select": "enable", "mtu": "9216", "name": "Vlan400" } diff --git a/src/sonic-yang-models/yang-models/sonic-vlan.yang b/src/sonic-yang-models/yang-models/sonic-vlan.yang index c600bec0a4b5..f420b8f7b17c 100644 --- a/src/sonic-yang-models/yang-models/sonic-vlan.yang +++ b/src/sonic-yang-models/yang-models/sonic-vlan.yang @@ -168,76 +168,11 @@ module sonic-vlan { type inet:ip-address; } - leaf dhcp_relay_src_intf { - description "Set source interface for the relay"; - type string; - } - - leaf dhcp_relay_link_select { - description "Enable/Disable link-select option for the relay"; - type stypes:mode_enable; - } - - leaf dhcp_relay_max_hop_count { - description "Max hop count for the relay"; - type uint8 { - range "1..15" { - error-message "Invalid max hop count for the relay"; - error-app-tag max-hop-count-invalid; - } - } - default "10"; - } - - leaf dhcp_server_vrf { - description "Vrf configured on the server"; - type string; - } - - leaf dhcp_relay_vrf_select { - description "Enable/Disable vrf-select sub-option for the relay"; - type stypes:mode_enable; - default disable; - } - - leaf dhcp_relay_policy_action { - description "Configure policy action for the relay"; - type stypes:relay_policy_action; - default discard; - } - leaf-list dhcpv6_servers { description "Configure the dhcp v6 servers"; type inet:ipv6-address; } - leaf dhcpv6_relay_src_intf { - description "Set source interface for the relay"; - type string; - } - - leaf dhcpv6_relay_max_hop_count { - description "Max hop count for the relay"; - type uint8 { - range "1..15" { - error-message "Invalid max hop count for the relay"; - error-app-tag max-hop-count-invalid; - } - } - default "10"; - } - - leaf dhcpv6_server_vrf { - description "Vrf configured on the server"; - type string; - } - - leaf dhcpv6_relay_vrf_select { - description "Enable/Disable vrf-select sub-option for the relay"; - type stypes:mode_enable; - default disable; - } - leaf mtu { type uint16 { range 1..9216; From b2c4f688aa61b1c5c50bec09edee082f03841148 Mon Sep 17 00:00:00 2001 From: Akhilesh Samineni Date: Fri, 22 Oct 2021 06:26:52 -0700 Subject: [PATCH 4/8] Removed unwanted sonic-types. --- .../yang-models/sonic-types.yang | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/sonic-yang-models/yang-models/sonic-types.yang b/src/sonic-yang-models/yang-models/sonic-types.yang index 0fccca1d1aea..ac3ceb805ff2 100644 --- a/src/sonic-yang-models/yang-models/sonic-types.yang +++ b/src/sonic-yang-models/yang-models/sonic-types.yang @@ -184,19 +184,4 @@ module sonic-types { enum transit; } } - - typedef relay_policy_action { - type enumeration { - enum discard; - enum append; - enum replace; - } - } - - typedef mode_enable { - type enumeration { - enum enable; - enum disable; - } - } } From 1c73acc2c80e71a31669683935de130c1f79076b Mon Sep 17 00:00:00 2001 From: Akhilesh Samineni Date: Fri, 22 Oct 2021 06:49:06 -0700 Subject: [PATCH 5/8] Corrected the test case. --- .../tests/yang_model_tests/tests_config/vlan.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 38a13425e5dd..c0ff21e6ae55 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 @@ -385,7 +385,7 @@ } } }, - "DHCP_SERVER_VALID_PARAMETERS_FORMAT": { + "DHCP_SERVER_VALID_FORMAT": { "sonic-port:sonic-port": { "sonic-port:PORT": { "PORT_LIST": [ @@ -441,7 +441,7 @@ } } }, - "DHCPV6_SERVER_VALID_PARAMETERS_FORMAT": { + "DHCPV6_SERVER_VALID_FORMAT": { "sonic-port:sonic-port": { "sonic-port:PORT": { "PORT_LIST": [ From 3b00557d3a8ee67a7dfc5eb480dbe65f96dea920 Mon Sep 17 00:00:00 2001 From: Akhilesh Samineni Date: Tue, 2 Nov 2021 03:54:26 -0700 Subject: [PATCH 6/8] Added new dhcpv6-relay.yang for dhcpv6 servers --- src/sonic-yang-models/setup.py | 1 + .../tests/files/sample_config_db.json | 12 +++ .../yang_model_tests/tests/dhcpv6_relay.json | 9 ++ .../tests_config/dhcpv6_relay.json | 84 +++++++++++++++++++ .../yang-models/sonic-dhcpv6-relay.yang | 54 ++++++++++++ 5 files changed, 160 insertions(+) create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests/dhcpv6_relay.json create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests_config/dhcpv6_relay.json create mode 100644 src/sonic-yang-models/yang-models/sonic-dhcpv6-relay.yang diff --git a/src/sonic-yang-models/setup.py b/src/sonic-yang-models/setup.py index 51c190e495d4..2d7ada90d0f7 100644 --- a/src/sonic-yang-models/setup.py +++ b/src/sonic-yang-models/setup.py @@ -51,6 +51,7 @@ './yang-models/sonic-crm.yang', './yang-models/sonic-device_metadata.yang', './yang-models/sonic-device_neighbor.yang', + './yang-models/sonic-dhcpv6-relay.yang', './yang-models/sonic-extension.yang', './yang-models/sonic-flex_counter.yang', './yang-models/sonic-feature.yang', 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 e99416bede48..0c01e7495452 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -1144,6 +1144,18 @@ "high_mem_alert": "disabled", "state": "enabled" } + }, + "DHCP_RELAY": { + "Vlan111": { + "dhcpv6_servers": [ + "2a04:5555:41::11" + ] + }, + "Vlan777": { + "dhcpv6_servers": [ + "2a04:5555:41::11" + ] + } } }, diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/dhcpv6_relay.json b/src/sonic-yang-models/tests/yang_model_tests/tests/dhcpv6_relay.json new file mode 100644 index 000000000000..318a5eb7682b --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/dhcpv6_relay.json @@ -0,0 +1,9 @@ +{ + "DHCPV6_SERVER_INCORRECT_FORMAT": { + "desc": "Add dhcpv6_server which is not in correct ipv6-address format.", + "eStrKey" : "Pattern" + }, + "DHCPV6_SERVER_VALID_FORMAT": { + "desc": "Add dhcpv6_server in correct format." + } +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/dhcpv6_relay.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/dhcpv6_relay.json new file mode 100644 index 000000000000..85dc058cfbaa --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/dhcpv6_relay.json @@ -0,0 +1,84 @@ +{ + "DHCPV6_SERVER_INCORRECT_FORMAT": { + "sonic-dhcpv6-relay:sonic-dhcpv6-relay": { + "sonic-dhcpv6-relay:DHCP_RELAY": { + "DHCP_RELAY_LIST": [ + { + "dhcpv6_servers": [ + "2001:1:2" + ], + "name": "Vlan500" + } + ] + } + } + }, + "DHCPV6_SERVER_VALID_FORMAT": { + "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": [ + { + "admin_status": "up", + "description": "v6server_vlan", + "dhcpv6_servers": [ + "2001:1::2" + ], + "mtu": "9216", + "name": "Vlan400" + } + ] + }, + "sonic-vlan:VLAN_MEMBER": { + "VLAN_MEMBER_LIST": [ + { + "port": "Ethernet0", + "tagging_mode": "tagged", + "name": "Vlan400" + } + ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_IPPREFIX_LIST": [ + { + "family": "IPv6", + "ip-prefix": "2002::1/64", + "scope": "global", + "name": "Vlan400" + } + ], + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan400" + } + ] + } + }, + "sonic-dhcpv6-relay:sonic-dhcpv6-relay": { + "sonic-dhcpv6-relay:DHCP_RELAY": { + "DHCP_RELAY_LIST": [ + { + "dhcpv6_servers": [ + "2001:1::2" + ], + "name": "Vlan400" + } + ] + } + } + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-dhcpv6-relay.yang b/src/sonic-yang-models/yang-models/sonic-dhcpv6-relay.yang new file mode 100644 index 000000000000..f6e8a90412c1 --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-dhcpv6-relay.yang @@ -0,0 +1,54 @@ +module sonic-dhcpv6-relay { + + namespace "http://github.com/Azure/sonic-dhcpv6-relay"; + + prefix sdhcpv6relay; + + yang-version 1.1; + + import ietf-inet-types { + prefix inet; + } + + import sonic-vlan { + prefix vlan; + } + + organization "SONiC"; + + contact "SONiC"; + + description "DHCPv6 Relay yang Module for SONiC OS"; + + revision 2021-10-30 { + description "First Revision"; + } + + container sonic-dhcpv6-relay { + + container DHCP_RELAY { + + description "DHCP_RELAY part of config_db.json"; + + list DHCP_RELAY_LIST { + + key "name"; + + leaf name { + type leafref { + path /vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name; + } + } + + leaf-list dhcpv6_servers { + description "Configure the dhcp v6 servers"; + type inet:ipv6-address; + } + } + /* end of VLAN_LIST */ + } + /* end of container DHCP_RELAY */ + } + /* end of container sonic-dhcpv6-relay */ +} +/* end of module sonic-dhcpv6-relay */ From b025f5fbace4de273f718764720e5cd2361e8b33 Mon Sep 17 00:00:00 2001 From: Akhilesh Samineni Date: Tue, 2 Nov 2021 07:49:11 -0700 Subject: [PATCH 7/8] Removed leaf reference for VLAN --- src/sonic-yang-models/yang-models/sonic-dhcpv6-relay.yang | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/sonic-yang-models/yang-models/sonic-dhcpv6-relay.yang b/src/sonic-yang-models/yang-models/sonic-dhcpv6-relay.yang index f6e8a90412c1..df612d6cacc1 100644 --- a/src/sonic-yang-models/yang-models/sonic-dhcpv6-relay.yang +++ b/src/sonic-yang-models/yang-models/sonic-dhcpv6-relay.yang @@ -10,10 +10,6 @@ module sonic-dhcpv6-relay { prefix inet; } - import sonic-vlan { - prefix vlan; - } - organization "SONiC"; contact "SONiC"; @@ -35,9 +31,7 @@ module sonic-dhcpv6-relay { key "name"; leaf name { - type leafref { - path /vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name; - } + type string; } leaf-list dhcpv6_servers { From 97b4896fbe8126027164907ac7a77b1cfef64ca9 Mon Sep 17 00:00:00 2001 From: Akhilesh Samineni Date: Tue, 2 Nov 2021 23:12:05 -0700 Subject: [PATCH 8/8] Addded leaf 'rfc6939_support' to the dhcpv6-relay yang --- src/sonic-yang-models/tests/files/sample_config_db.json | 6 ++++-- .../tests/yang_model_tests/tests_config/dhcpv6_relay.json | 2 ++ src/sonic-yang-models/yang-models/sonic-dhcpv6-relay.yang | 5 +++++ 3 files changed, 11 insertions(+), 2 deletions(-) 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 244ba87eee00..5b407df7538b 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -1149,12 +1149,14 @@ "Vlan111": { "dhcpv6_servers": [ "2a04:5555:41::11" - ] + ], + "rfc6939_support": "true" }, "Vlan777": { "dhcpv6_servers": [ "2a04:5555:41::11" - ] + ], + "rfc6939_support": "true" } }, "SCHEDULER": { diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/dhcpv6_relay.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/dhcpv6_relay.json index 85dc058cfbaa..68c077e51e91 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/dhcpv6_relay.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/dhcpv6_relay.json @@ -75,6 +75,8 @@ "dhcpv6_servers": [ "2001:1::2" ], + "rfc6939_support": "true", + "name": "Vlan400" } ] diff --git a/src/sonic-yang-models/yang-models/sonic-dhcpv6-relay.yang b/src/sonic-yang-models/yang-models/sonic-dhcpv6-relay.yang index df612d6cacc1..f1e73397dff4 100644 --- a/src/sonic-yang-models/yang-models/sonic-dhcpv6-relay.yang +++ b/src/sonic-yang-models/yang-models/sonic-dhcpv6-relay.yang @@ -38,6 +38,11 @@ module sonic-dhcpv6-relay { description "Configure the dhcp v6 servers"; type inet:ipv6-address; } + + leaf rfc6939_support { + description "Set rfc6939 for the relay"; + type boolean; + } } /* end of VLAN_LIST */ }