Skip to content
22 changes: 22 additions & 0 deletions src/sonic-yang-models/tests/files/sample_config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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": [
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We currently store dhcpv6_servers in a separate table called DHCP_RELAY, and SONiC dhcp6relay fetches dhcpv6 server addresses from this table instead of VLAN. This is the draft sonic-dhcpv6-relay.yang

module DHCP_RELAY  
    container DHCP_RELAY {  	
        list VLAN_LIST {
    		key name;
   		    leaf name {
    			type string;
  		    }
   		    leaf dhcpv6_servers {
     		    	type inet6:ip-address;
  		    }
		    leaf dhcpv6_option|rfc6939_support {
			    type bool;
		    }
        }
    }
}

And config_db schema looks like this:

DHCP_RELAY|intf-i|dhcpv6_servers: ["dhcp-server-0", "dhcp-server-1", ...., "dhcp-server-n-1"]
DHCP_RELAY|intf-i|dhcpv6_option|rfc6939_support: "true"

202106 version currently still uses ISC-DHCP which reads from VLAN table, so we need to have dhcpv6_servers in both VLAN and DHCP_RELAY

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a new 'dhcpv6-relay' yang file changes for DHCP_RELAY table.

@kellyyeh Seeing parsing issues with leaf "dhcpv6_option|rfc6939_support", as it has '|' character.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add it as just "rfc6939_support" please?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, added leaf as 'rfc6939_support'.

"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"
Expand Down
10 changes: 10 additions & 0 deletions src/sonic-yang-models/tests/yang_model_tests/tests/vlan.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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."
}
}
139 changes: 139 additions & 0 deletions src/sonic-yang-models/tests/yang_model_tests/tests_config/vlan.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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"
}
]
}
}
}
}
15 changes: 15 additions & 0 deletions src/sonic-yang-models/yang-models/sonic-types.yang
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
71 changes: 71 additions & 0 deletions src/sonic-yang-models/yang-models/sonic-vlan.yang
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,80 @@ module sonic-vlan {
}

leaf-list dhcp_servers {
description "Configure the dhcp v4 servers";
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;
Expand Down