diff --git a/src/sonic-yang-models/setup.py b/src/sonic-yang-models/setup.py index 7ef362c008ba..f610aa355b11 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 35cb22074106..5b407df7538b 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,9 @@ "dhcp_servers": [ "10.222.72.116" ], + "dhcpv6_servers": [ + "2a04:5555:41::11" + ], "vlanid": "111", "mtu": "9216", "admin_status": "up" @@ -229,6 +232,9 @@ "dhcp_servers": [ "10.222.72.116" ], + "dhcpv6_servers": [ + "2a04:5555:41::11" + ], "vlanid": "777", "mtu": "9216", "admin_status": "up" @@ -1139,7 +1145,20 @@ "state": "enabled" } }, - + "DHCP_RELAY": { + "Vlan111": { + "dhcpv6_servers": [ + "2a04:5555:41::11" + ], + "rfc6939_support": "true" + }, + "Vlan777": { + "dhcpv6_servers": [ + "2a04:5555:41::11" + ], + "rfc6939_support": "true" + } + }, "SCHEDULER": { "TEST@0": { "cbs": "256", 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/vlan.json b/src/sonic-yang-models/tests/yang_model_tests/tests/vlan.json index 2d38ef453c32..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 @@ -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_FORMAT": { + "desc": "Add dhcp_server 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/dhcpv6_relay.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/dhcpv6_relay.json new file mode 100644 index 000000000000..68c077e51e91 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/dhcpv6_relay.json @@ -0,0 +1,86 @@ +{ + "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" + ], + "rfc6939_support": "true", + + "name": "Vlan400" + } + ] + } + } + } +} 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..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 @@ -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,117 @@ ] } } + }, + "DHCP_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": "server_vlan", + "dhcp_servers": [ + "10.186.72.10" + ], + "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_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" + } + ] + } + } } } 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..f1e73397dff4 --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-dhcpv6-relay.yang @@ -0,0 +1,53 @@ +module sonic-dhcpv6-relay { + + namespace "http://github.com/Azure/sonic-dhcpv6-relay"; + + prefix sdhcpv6relay; + + yang-version 1.1; + + import ietf-inet-types { + prefix inet; + } + + 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 string; + } + + leaf-list dhcpv6_servers { + 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 */ + } + /* end of container DHCP_RELAY */ + } + /* end of container sonic-dhcpv6-relay */ +} +/* end of module sonic-dhcpv6-relay */ diff --git a/src/sonic-yang-models/yang-models/sonic-vlan.yang b/src/sonic-yang-models/yang-models/sonic-vlan.yang index c63bc6b46ac4..f420b8f7b17c 100644 --- a/src/sonic-yang-models/yang-models/sonic-vlan.yang +++ b/src/sonic-yang-models/yang-models/sonic-vlan.yang @@ -164,9 +164,15 @@ module sonic-vlan { } leaf-list dhcp_servers { + description "Configure the dhcp v4 servers"; type inet:ip-address; } + leaf-list dhcpv6_servers { + description "Configure the dhcp v6 servers"; + type inet:ipv6-address; + } + leaf mtu { type uint16 { range 1..9216;