From 26c11cbe08d34de8909b5a91aaf20a97384f01ea Mon Sep 17 00:00:00 2001 From: Nazarii Hnydyn Date: Mon, 26 Apr 2021 18:02:51 +0000 Subject: [PATCH 01/11] [pbh]: Add YANG model. Signed-off-by: Nazarii Hnydyn --- .../yang-models/sonic-pbh.yang | 218 ++++++++++++++++++ 1 file changed, 218 insertions(+) create mode 100644 src/sonic-yang-models/yang-models/sonic-pbh.yang diff --git a/src/sonic-yang-models/yang-models/sonic-pbh.yang b/src/sonic-yang-models/yang-models/sonic-pbh.yang new file mode 100644 index 000000000000..8e146f6fefc5 --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-pbh.yang @@ -0,0 +1,218 @@ +module sonic-pbh { + + yang-version 1.1; + + namespace "http://github.com/Azure/sonic-pbh"; + prefix pbh; + + import ietf-inet-types { + prefix inet; + } + + import sonic-port { + prefix port; + } + + import sonic-portchannel { + prefix lag; + } + + description "PBH YANG Module for SONiC OS"; + + revision 2021-04-23 { + description "First Revision"; + } + + container sonic-pbh { + + container PBH_HASH { + + description "PBH_HASH part of config_db.json"; + + list PBH_HASH_LIST { + + key "hash_name"; + + leaf hash_name { + description "The name of this hash"; + type string; + } + + leaf hash_field { + description "Configures native hash filed for this hash"; + mandatory true; + type string { + pattern "INNER_IP_PROTOCOL|INNER_L4_DST_PORT|INNER_L4_SRC_PORT|INNER_DST_IPV4|INNER_SRC_IPV4|INNER_DST_IPV6|INNER_SRC_IPV6"; + } + } + + leaf ipv4_mask { + description "Configures IPv4 address mask for this hash"; + mandatory true; + type inet:ipv4-address; + when "boolean(../hash_field[.='INNER_DST_IPV4' or .='INNER_SRC_IPV4'])"; + } + + leaf ipv6_mask { + description "Configures IPv6 address mask for this hash"; + mandatory true; + type inet:ipv6-address; + when "boolean(../hash_field[.='INNER_DST_IPV6' or .='INNER_SRC_IPV6'])"; + } + + leaf sequence_id { + description "Configures in which order the fields are hashed and defines which fields should be associative"; + mandatory true; + type uint32; + } + + } + /* end of PBH_HASH_LIST */ + } + /* end of container PBH_HASH */ + + container PBH_RULE { + + description "PBH_RULE part of config_db.json"; + + list PBH_RULE_LIST { + + key "table_name rule_name"; + + leaf table_name { + description "The name of table which holds this rule"; + type leafref { + path "/pbh:sonic-pbh/pbh:PBH_TABLE/pbh:PBH_TABLE_LIST/pbh:table_name"; + } + } + + leaf rule_name { + description "The name of this rule"; + type string; + } + + leaf priority { + description "Configures priority for this rule"; + mandatory true; + type uint32; + } + + leaf gre_key { + description "Configures packet match for this rule: GRE key"; + type string { + pattern "(0x){1}[a-fA-F0-9]+/(0x){1}[a-fA-F0-9]+"; + } + } + + leaf ip_protocol { + description "Configures packet match for this rule: IP protocol"; + type string { + pattern "(0x){1}[a-fA-F0-9]+/(0x){1}[a-fA-F0-9]+"; + } + } + + leaf ipv6_next_header { + description "Configures packet match for this rule: IPv6 Next header"; + type string { + pattern "(0x){1}[a-fA-F0-9]+/(0x){1}[a-fA-F0-9]+"; + } + } + + leaf l4_dst_port { + description "Configures packet match for this rule: L4 destination port"; + type string { + pattern "(0x){1}[a-fA-F0-9]+/(0x){1}[a-fA-F0-9]+"; + } + } + + leaf inner_ether_type { + description "Configures packet match for this rule: inner EtherType"; + type string { + pattern "(0x){1}[a-fA-F0-9]+/(0x){1}[a-fA-F0-9]+"; + } + } + + leaf-list hash_list { + description "The list of hash fields to apply with this rule"; + min-elements 1; + type leafref { + path "/pbh:sonic-pbh/pbh:PBH_HASH/pbh:PBH_HASH_LIST/pbh:hash_name"; + } + } + + leaf packet_action { + description "Configures packet action for this rule"; + type string { + pattern "SET_ECMP_HASH|SET_LAG_HASH"; + } + default "SET_ECMP_HASH"; + } + + leaf flow_counter { + description "Enables/Disables packet/byte counter for this rule"; + type string { + pattern "DISABLED|ENABLED"; + } + default "DISABLED"; + } + + } + /* end of PBH_RULE_LIST */ + } + /* end of container ACL_RULE */ + + container PBH_TABLE { + + description "PBH_TABLE part of config_db.json"; + + list PBH_TABLE_LIST { + + key "table_name"; + + leaf table_name { + description "The name of this table"; + type string; + } + + leaf-list port_list { + description "Ports to which this table is applied"; + type union { + type leafref { + path "/port:sonic-port/port:PORT/port:PORT_LIST/port:name"; + } + type string { + pattern ""; + } + } + default ""; + } + + leaf-list lag_list { + description "Portchannels to which this table is applied"; + type union { + type leafref { + path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name"; + } + type string { + pattern ""; + } + } + default ""; + } + + leaf description { + description "The description of this table"; + mandatory true; + type string { + length 0..255; + } + } + + } + /* end of PBH_TABLE_LIST */ + } + /* end of container PBH_TABLE */ + } + /* end of container sonic-pbh */ +} +/* end of module sonic-pbh */ From b01d801391cb334261ed55d15b6dd1d416bf2202 Mon Sep 17 00:00:00 2001 From: Nazarii Hnydyn Date: Wed, 28 Apr 2021 11:03:40 +0000 Subject: [PATCH 02/11] [pbh]: YANG model rev01. Signed-off-by: Nazarii Hnydyn --- src/sonic-yang-models/yang-models/sonic-pbh.yang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-yang-models/yang-models/sonic-pbh.yang b/src/sonic-yang-models/yang-models/sonic-pbh.yang index 8e146f6fefc5..cadda15210ac 100644 --- a/src/sonic-yang-models/yang-models/sonic-pbh.yang +++ b/src/sonic-yang-models/yang-models/sonic-pbh.yang @@ -159,7 +159,7 @@ module sonic-pbh { } /* end of PBH_RULE_LIST */ } - /* end of container ACL_RULE */ + /* end of container PBH_RULE */ container PBH_TABLE { From 40ad22d32561ecd9cf56ea877668169090da99d0 Mon Sep 17 00:00:00 2001 From: Nazarii Hnydyn Date: Tue, 25 May 2021 10:43:49 +0000 Subject: [PATCH 03/11] [pbh]: YANG model rev02. Signed-off-by: Nazarii Hnydyn --- src/sonic-yang-models/yang-models/sonic-pbh.yang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-yang-models/yang-models/sonic-pbh.yang b/src/sonic-yang-models/yang-models/sonic-pbh.yang index cadda15210ac..87f75678adc1 100644 --- a/src/sonic-yang-models/yang-models/sonic-pbh.yang +++ b/src/sonic-yang-models/yang-models/sonic-pbh.yang @@ -39,7 +39,7 @@ module sonic-pbh { } leaf hash_field { - description "Configures native hash filed for this hash"; + description "Configures native hash field for this hash"; mandatory true; type string { pattern "INNER_IP_PROTOCOL|INNER_L4_DST_PORT|INNER_L4_SRC_PORT|INNER_DST_IPV4|INNER_SRC_IPV4|INNER_DST_IPV6|INNER_SRC_IPV6"; From 148a77c7f93fc4be58789a0236c95192433962a0 Mon Sep 17 00:00:00 2001 From: Nazarii Hnydyn Date: Wed, 26 May 2021 16:55:22 +0000 Subject: [PATCH 04/11] [pbh]: YANG model rev03. Signed-off-by: Nazarii Hnydyn --- src/sonic-yang-models/yang-models/sonic-pbh.yang | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/sonic-yang-models/yang-models/sonic-pbh.yang b/src/sonic-yang-models/yang-models/sonic-pbh.yang index 87f75678adc1..1c0fa4510fc2 100644 --- a/src/sonic-yang-models/yang-models/sonic-pbh.yang +++ b/src/sonic-yang-models/yang-models/sonic-pbh.yang @@ -174,22 +174,12 @@ module sonic-pbh { type string; } - leaf-list port_list { - description "Ports to which this table is applied"; + leaf-list interface_list { + description "Interfaces to which this table is applied"; type union { type leafref { path "/port:sonic-port/port:PORT/port:PORT_LIST/port:name"; } - type string { - pattern ""; - } - } - default ""; - } - - leaf-list lag_list { - description "Portchannels to which this table is applied"; - type union { type leafref { path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name"; } @@ -204,7 +194,7 @@ module sonic-pbh { description "The description of this table"; mandatory true; type string { - length 0..255; + length 1..255; } } From c38a58b3e1ba910b2c5bc862b0be0ecee184c352 Mon Sep 17 00:00:00 2001 From: Nazarii Hnydyn Date: Wed, 26 May 2021 16:56:44 +0000 Subject: [PATCH 05/11] [pbh]: Add YANG UT. Signed-off-by: Nazarii Hnydyn --- .../tests/files/sample_config_db.json | 74 +++ .../tests/yang_model_tests/tests/pbh.json | 91 +++ .../yang_model_tests/tests_config/pbh.json | 610 ++++++++++++++++++ 3 files changed, 775 insertions(+) create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests/pbh.json create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests_config/pbh.json 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 95af4372618c..b5c3ba6ff979 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -630,6 +630,80 @@ ] } }, + "PBH_HASH": { + "inner_ip_proto": { + "hash_field": "INNER_IP_PROTOCOL", + "sequence_id": "1" + }, + "inner_l4_dst_port": { + "hash_field": "INNER_L4_DST_PORT", + "sequence_id": "2" + }, + "inner_l4_src_port": { + "hash_field": "INNER_L4_SRC_PORT", + "sequence_id": "2" + }, + "inner_dst_ipv4": { + "hash_field": "INNER_DST_IPV4", + "ipv4_mask": "255.0.0.0", + "sequence_id": "3" + }, + "inner_src_ipv4": { + "hash_field": "INNER_SRC_IPV4", + "ipv4_mask": "0.0.0.255", + "sequence_id": "3" + }, + "inner_dst_ipv6": { + "hash_field": "INNER_DST_IPV6", + "ipv6_mask": "ffff::", + "sequence_id": "4" + }, + "inner_src_ipv6": { + "hash_field": "INNER_SRC_IPV6", + "ipv6_mask": "::ffff", + "sequence_id": "4" + } + }, + "PBH_RULE": { + "pbh_table|nvgre": { + "priority": "1", + "gre_key": "0x2500/0xffffff00", + "inner_ether_type": "0x86dd/0xffff", + "hash_list": [ + "inner_ip_proto", + "inner_l4_dst_port", + "inner_l4_src_port", + "inner_dst_ipv6", + "inner_src_ipv6" + ], + "packet_action": "SET_ECMP_HASH" + }, + "pbh_table|vxlan": { + "priority": "2", + "ip_protocol": "0x11/0xff", + "l4_dst_port": "0x12b5/0xffff", + "inner_ether_type": "0x0800/0xffff", + "hash_list": [ + "inner_ip_proto", + "inner_l4_dst_port", + "inner_l4_src_port", + "inner_dst_ipv4", + "inner_src_ipv4" + ], + "packet_action": "SET_LAG_HASH" + } + }, + "PBH_TABLE": { + "pbh_table": { + "interface_list": [ + "Ethernet0", + "Ethernet4", + "PortChannel0003", + "PortChannel0004" + ], + "description": "NVGRE and VxLAN" + } + }, "INTERFACE": { "Ethernet112": {}, "Ethernet14": {}, diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/pbh.json b/src/sonic-yang-models/tests/yang_model_tests/tests/pbh.json new file mode 100644 index 000000000000..6fd6d17d4608 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/pbh.json @@ -0,0 +1,91 @@ +{ + "PBH_TABLE_RULE_HASH_VALID": { + "desc": "Configure PBH_TABLE, PBH_RULE and PBH_HASH." + }, + "PBH_TABLE_INVALID_INTERFACE": { + "desc": "Configure non-existing PORT/PORTCHANNEL in PBH_TABLE.", + "eStrKey" : "InvalidValue" + }, + "PBH_TABLE_INVALID_DESCRIPTION": { + "desc": "Configure invalid DESCRIPTION in PBH_TABLE.", + "eStrKey" : "Range" + }, + "PBH_RULE_INVALID_TABLE": { + "desc": "Configure non-existing PBH_TABLE in PBH_RULE.", + "eStrKey": "LeafRef" + }, + "PBH_RULE_INVALID_PRIORITY": { + "desc": "Configure invalid PRIORITY in PBH_RULE.", + "eStrKey": "InvalidValue" + }, + "PBH_RULE_INVALID_GRE_KEY": { + "desc": "Configure invalid GRE_KEY in PBH_RULE.", + "eStrKey" : "Pattern" + }, + "PBH_RULE_INVALID_IP_PROTOCOL": { + "desc": "Configure invalid IP_PROTOCOL in PBH_RULE.", + "eStrKey" : "Pattern" + }, + "PBH_RULE_INVALID_IPV6_NEXT_HEADER": { + "desc": "Configure invalid IPV6_NEXT_HEADER in PBH_RULE.", + "eStrKey" : "Pattern" + }, + "PBH_RULE_INVALID_L4_DST_PORT": { + "desc": "Configure invalid L4_DST_PORT in PBH_RULE.", + "eStrKey" : "Pattern" + }, + "PBH_RULE_INVALID_INNER_ETHER_TYPE": { + "desc": "Configure invalid INNER_ETHER_TYPE in PBH_RULE.", + "eStrKey" : "Pattern" + }, + "PBH_RULE_INVALID_HASH": { + "desc": "Configure non-existing PBH_HASH in PBH_RULE.", + "eStrKey" : "LeafRef" + }, + "PBH_RULE_INVALID_PACKET_ACTION": { + "desc": "Configure invalid PACKET_ACTION in PBH_RULE.", + "eStrKey" : "Pattern" + }, + "PBH_RULE_INVALID_FLOW_COUNTER": { + "desc": "Configure invalid FLOW_COUNTER in PBH_RULE.", + "eStrKey" : "Pattern" + }, + "PBH_RULE_DEFAULT_VALUE_PACKET_ACTION": { + "desc": "Verify default value for PACKET_ACTION field in PBH_RULE.", + "eStrKey" : "Verify", + "verify": { + "xpath": "/sonic-pbh:sonic-pbh/PBH_RULE/PBH_RULE_LIST[table_name='pbh_table'][rule_name='nvgre']/packet_action", + "key": "sonic-pbh:packet_action", + "value": "SET_ECMP_HASH" + } + }, + "PBH_RULE_DEFAULT_VALUE_FLOW_COUNTER": { + "desc": "Verify default value for FLOW_COUNTER field in PBH_RULE.", + "eStrKey" : "Verify", + "verify": { + "xpath": "/sonic-pbh:sonic-pbh/PBH_RULE/PBH_RULE_LIST[table_name='pbh_table'][rule_name='nvgre']/flow_counter", + "key": "sonic-pbh:flow_counter", + "value": "DISABLED" + } + }, + "PBH_HASH_INVALID_HASH_FIELD": { + "desc": "Configure invalid HASH_FIELD in PBH_HASH.", + "eStrKey" : "Pattern" + }, + "PBH_RULE_HASH_FIELD_IPV6_MASK_MISMATCH": { + "desc": "Configure HASH_FIELD (INNER_DST_IPV4) with IPV6_MASK in PBH_HASH.", + "eStrKey" : "When" + }, + "PBH_RULE_INVALID_IPV4_MASK": { + "desc": "Configure invalid IPV4_MASK in PBH_HASH.", + "eStrKey" : "Pattern" + }, + "PBH_RULE_INVALID_IPV6_MASK": { + "desc": "Configure invalid IPV6_MASK in PBH_HASH.", + "eStrKey" : "Pattern" + }, + "PBH_RULE_INVALID_SEQUENCE_ID": { + "desc": "Configure invalid SEQUENCE_ID in PBH_HASH.", + "eStrKey" : "InvalidValue" + } +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/pbh.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/pbh.json new file mode 100644 index 000000000000..bc6e6b2c5910 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/pbh.json @@ -0,0 +1,610 @@ +{ + "PBH_TABLE_RULE_HASH_VALID": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_HASH": { + "PBH_HASH_LIST": [ + { + "hash_name": "inner_ip_proto", + "hash_field": "INNER_IP_PROTOCOL", + "sequence_id": 1 + }, + { + "hash_name": "inner_l4_dst_port", + "hash_field": "INNER_L4_DST_PORT", + "sequence_id": 2 + }, + { + "hash_name": "inner_l4_src_port", + "hash_field": "INNER_L4_SRC_PORT", + "sequence_id": 2 + }, + { + "hash_name": "inner_dst_ipv4", + "hash_field": "INNER_DST_IPV4", + "ipv4_mask": "255.0.0.0", + "sequence_id": 3 + }, + { + "hash_name": "inner_src_ipv4", + "hash_field": "INNER_SRC_IPV4", + "ipv4_mask": "0.0.0.255", + "sequence_id": 3 + }, + { + "hash_name": "inner_dst_ipv6", + "hash_field": "INNER_DST_IPV6", + "ipv6_mask": "ffff::", + "sequence_id": 4 + }, + { + "hash_name": "inner_src_ipv6", + "hash_field": "INNER_SRC_IPV6", + "ipv6_mask": "::ffff", + "sequence_id": 4 + } + ] + }, + "sonic-pbh:PBH_RULE": { + "PBH_RULE_LIST": [ + { + "table_name": "pbh_table", + "rule_name": "nvgre", + "priority": 1, + "gre_key": "0x2500/0xffffff00", + "inner_ether_type": "0x86dd/0xffff", + "hash_list": [ + "inner_ip_proto", + "inner_l4_dst_port", + "inner_l4_src_port", + "inner_dst_ipv6", + "inner_src_ipv6" + ], + "packet_action": "SET_ECMP_HASH" + }, + { + "table_name": "pbh_table", + "rule_name": "vxlan", + "priority": 2, + "ip_protocol": "0x11/0xff", + "l4_dst_port": "0x12b5/0xffff", + "inner_ether_type": "0x0800/0xffff", + "hash_list": [ + "inner_ip_proto", + "inner_l4_dst_port", + "inner_l4_src_port", + "inner_dst_ipv4", + "inner_src_ipv4" + ], + "packet_action": "SET_LAG_HASH" + } + ] + }, + "sonic-pbh:PBH_TABLE": { + "PBH_TABLE_LIST": [ + { + "table_name": "pbh_table", + "interface_list": [ + "Ethernet0", + "Ethernet4", + "PortChannel0001", + "PortChannel0002" + ], + "description": "NVGRE and VxLAN" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet0", + "lanes": "0,1,2,3", + "speed": 100000 + }, + { + "name": "Ethernet4", + "lanes": "4,5,6,7", + "speed": 100000 + } + ] + } + }, + "sonic-portchannel:sonic-portchannel": { + "sonic-portchannel:PORTCHANNEL": { + "PORTCHANNEL_LIST": [ + { + "name": "PortChannel0001", + "admin_status": "up" + }, + { + "name": "PortChannel0002", + "admin_status": "up" + } + ] + } + } + }, + "PBH_TABLE_INVALID_INTERFACE": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_TABLE": { + "PBH_TABLE_LIST": [ + { + "table_name": "pbh_table", + "interface_list": [ + "EthernetX", + "PortChannel000X" + ], + "description": "NVGRE and VxLAN" + } + ] + } + } + }, + "PBH_TABLE_INVALID_DESCRIPTION": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_TABLE": { + "PBH_TABLE_LIST": [ + { + "table_name": "pbh_table", + "description": "" + } + ] + } + } + }, + "PBH_RULE_INVALID_TABLE": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_HASH": { + "PBH_HASH_LIST": [ + { + "hash_name": "inner_ip_proto", + "hash_field": "INNER_IP_PROTOCOL", + "sequence_id": 1 + } + ] + }, + "sonic-pbh:PBH_RULE": { + "PBH_RULE_LIST": [ + { + "table_name": "invalid_value", + "rule_name": "nvgre", + "priority": 1, + "hash_list": [ + "inner_ip_proto" + ] + } + ] + } + } + }, + "PBH_RULE_INVALID_PRIORITY": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_HASH": { + "PBH_HASH_LIST": [ + { + "hash_name": "inner_ip_proto", + "hash_field": "INNER_IP_PROTOCOL", + "sequence_id": 1 + } + ] + }, + "sonic-pbh:PBH_RULE": { + "PBH_RULE_LIST": [ + { + "table_name": "pbh_table", + "rule_name": "nvgre", + "priority": 4294967296, + "hash_list": [ + "inner_ip_proto" + ] + } + ] + }, + "sonic-pbh:PBH_TABLE": { + "PBH_TABLE_LIST": [ + { + "table_name": "pbh_table", + "description": "NVGRE" + } + ] + } + } + }, + "PBH_RULE_INVALID_GRE_KEY": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_HASH": { + "PBH_HASH_LIST": [ + { + "hash_name": "inner_ip_proto", + "hash_field": "INNER_IP_PROTOCOL", + "sequence_id": 1 + } + ] + }, + "sonic-pbh:PBH_RULE": { + "PBH_RULE_LIST": [ + { + "table_name": "pbh_table", + "rule_name": "nvgre", + "priority": 1, + "gre_key": "2500/0xffffff00", + "hash_list": [ + "inner_ip_proto" + ] + } + ] + }, + "sonic-pbh:PBH_TABLE": { + "PBH_TABLE_LIST": [ + { + "table_name": "pbh_table", + "description": "NVGRE" + } + ] + } + } + }, + "PBH_RULE_INVALID_IP_PROTOCOL": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_HASH": { + "PBH_HASH_LIST": [ + { + "hash_name": "inner_ip_proto", + "hash_field": "INNER_IP_PROTOCOL", + "sequence_id": 1 + } + ] + }, + "sonic-pbh:PBH_RULE": { + "PBH_RULE_LIST": [ + { + "table_name": "pbh_table", + "rule_name": "nvgre", + "priority": 1, + "ip_protocol": "0x11/ff", + "hash_list": [ + "inner_ip_proto" + ] + } + ] + }, + "sonic-pbh:PBH_TABLE": { + "PBH_TABLE_LIST": [ + { + "table_name": "pbh_table", + "description": "NVGRE" + } + ] + } + } + }, + "PBH_RULE_INVALID_IPV6_NEXT_HEADER": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_HASH": { + "PBH_HASH_LIST": [ + { + "hash_name": "inner_ip_proto", + "hash_field": "INNER_IP_PROTOCOL", + "sequence_id": 1 + } + ] + }, + "sonic-pbh:PBH_RULE": { + "PBH_RULE_LIST": [ + { + "table_name": "pbh_table", + "rule_name": "nvgre", + "priority": 1, + "ipv6_next_header": "0x11", + "hash_list": [ + "inner_ip_proto" + ] + } + ] + }, + "sonic-pbh:PBH_TABLE": { + "PBH_TABLE_LIST": [ + { + "table_name": "pbh_table", + "description": "NVGRE" + } + ] + } + } + }, + "PBH_RULE_INVALID_L4_DST_PORT": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_HASH": { + "PBH_HASH_LIST": [ + { + "hash_name": "inner_ip_proto", + "hash_field": "INNER_IP_PROTOCOL", + "sequence_id": 1 + } + ] + }, + "sonic-pbh:PBH_RULE": { + "PBH_RULE_LIST": [ + { + "table_name": "pbh_table", + "rule_name": "nvgre", + "priority": 1, + "l4_dst_port": "0xffff", + "hash_list": [ + "inner_ip_proto" + ] + } + ] + }, + "sonic-pbh:PBH_TABLE": { + "PBH_TABLE_LIST": [ + { + "table_name": "pbh_table", + "description": "NVGRE" + } + ] + } + } + }, + "PBH_RULE_INVALID_INNER_ETHER_TYPE": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_HASH": { + "PBH_HASH_LIST": [ + { + "hash_name": "inner_ip_proto", + "hash_field": "INNER_IP_PROTOCOL", + "sequence_id": 1 + } + ] + }, + "sonic-pbh:PBH_RULE": { + "PBH_RULE_LIST": [ + { + "table_name": "pbh_table", + "rule_name": "nvgre", + "priority": 1, + "inner_ether_type": "0x0800 / 0xffff", + "hash_list": [ + "inner_ip_proto" + ] + } + ] + }, + "sonic-pbh:PBH_TABLE": { + "PBH_TABLE_LIST": [ + { + "table_name": "pbh_table", + "description": "NVGRE" + } + ] + } + } + }, + "PBH_RULE_INVALID_HASH": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_RULE": { + "PBH_RULE_LIST": [ + { + "table_name": "pbh_table", + "rule_name": "nvgre", + "priority": 1, + "hash_list": [ + "invalid_value" + ] + } + ] + }, + "sonic-pbh:PBH_TABLE": { + "PBH_TABLE_LIST": [ + { + "table_name": "pbh_table", + "description": "NVGRE" + } + ] + } + } + }, + "PBH_RULE_INVALID_PACKET_ACTION": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_HASH": { + "PBH_HASH_LIST": [ + { + "hash_name": "inner_ip_proto", + "hash_field": "INNER_IP_PROTOCOL", + "sequence_id": 1 + } + ] + }, + "sonic-pbh:PBH_RULE": { + "PBH_RULE_LIST": [ + { + "table_name": "pbh_table", + "rule_name": "nvgre", + "priority": 1, + "hash_list": [ + "inner_ip_proto" + ], + "packet_action": "INVALID_VALUE" + } + ] + }, + "sonic-pbh:PBH_TABLE": { + "PBH_TABLE_LIST": [ + { + "table_name": "pbh_table", + "description": "NVGRE" + } + ] + } + } + }, + "PBH_RULE_INVALID_FLOW_COUNTER": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_HASH": { + "PBH_HASH_LIST": [ + { + "hash_name": "inner_ip_proto", + "hash_field": "INNER_IP_PROTOCOL", + "sequence_id": 1 + } + ] + }, + "sonic-pbh:PBH_RULE": { + "PBH_RULE_LIST": [ + { + "table_name": "pbh_table", + "rule_name": "nvgre", + "priority": 1, + "hash_list": [ + "inner_ip_proto" + ], + "flow_counter": "INVALID_VALUE" + } + ] + }, + "sonic-pbh:PBH_TABLE": { + "PBH_TABLE_LIST": [ + { + "table_name": "pbh_table", + "description": "NVGRE" + } + ] + } + } + }, + "PBH_RULE_DEFAULT_VALUE_PACKET_ACTION": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_HASH": { + "PBH_HASH_LIST": [ + { + "hash_name": "inner_ip_proto", + "hash_field": "INNER_IP_PROTOCOL", + "sequence_id": 1 + } + ] + }, + "sonic-pbh:PBH_RULE": { + "PBH_RULE_LIST": [ + { + "table_name": "pbh_table", + "rule_name": "nvgre", + "priority": 1, + "hash_list": [ + "inner_ip_proto" + ] + } + ] + }, + "sonic-pbh:PBH_TABLE": { + "PBH_TABLE_LIST": [ + { + "table_name": "pbh_table", + "description": "NVGRE" + } + ] + } + } + }, + "PBH_RULE_DEFAULT_VALUE_FLOW_COUNTER": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_HASH": { + "PBH_HASH_LIST": [ + { + "hash_name": "inner_ip_proto", + "hash_field": "INNER_IP_PROTOCOL", + "sequence_id": 1 + } + ] + }, + "sonic-pbh:PBH_RULE": { + "PBH_RULE_LIST": [ + { + "table_name": "pbh_table", + "rule_name": "nvgre", + "priority": 1, + "hash_list": [ + "inner_ip_proto" + ] + } + ] + }, + "sonic-pbh:PBH_TABLE": { + "PBH_TABLE_LIST": [ + { + "table_name": "pbh_table", + "description": "NVGRE" + } + ] + } + } + }, + "PBH_HASH_INVALID_HASH_FIELD": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_HASH": { + "PBH_HASH_LIST": [ + { + "hash_name": "inner_ip_proto", + "hash_field": "INVALID_VALUE", + "sequence_id": 1 + } + ] + } + } + }, + "PBH_RULE_HASH_FIELD_IPV6_MASK_MISMATCH": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_HASH": { + "PBH_HASH_LIST": [ + { + "hash_name": "inner_ip_proto", + "hash_field": "INNER_DST_IPV4", + "ipv6_mask": "ffff::", + "sequence_id": 1 + } + ] + } + } + }, + "PBH_RULE_INVALID_IPV4_MASK": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_HASH": { + "PBH_HASH_LIST": [ + { + "hash_name": "inner_ip_proto", + "hash_field": "INNER_DST_IPV4", + "ipv4_mask": "ffff::", + "sequence_id": 1 + } + ] + } + } + }, + "PBH_RULE_INVALID_IPV6_MASK": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_HASH": { + "PBH_HASH_LIST": [ + { + "hash_name": "inner_ip_proto", + "hash_field": "INNER_DST_IPV6", + "ipv6_mask": "255.0.0.0", + "sequence_id": 1 + } + ] + } + } + }, + "PBH_RULE_INVALID_SEQUENCE_ID": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_HASH": { + "PBH_HASH_LIST": [ + { + "hash_name": "inner_ip_proto", + "hash_field": "INNER_IP_PROTOCOL", + "sequence_id": 4294967296 + } + ] + } + } + } +} From b48f00f4c9cd668258a74395372750ea0070e58b Mon Sep 17 00:00:00 2001 From: Nazarii Hnydyn Date: Thu, 3 Jun 2021 10:29:21 +0000 Subject: [PATCH 06/11] [pbh]: YANG model rev04. Signed-off-by: Nazarii Hnydyn --- .../yang-models/sonic-pbh.yang | 120 ++++++++++++------ 1 file changed, 81 insertions(+), 39 deletions(-) diff --git a/src/sonic-yang-models/yang-models/sonic-pbh.yang b/src/sonic-yang-models/yang-models/sonic-pbh.yang index 1c0fa4510fc2..08881734eded 100644 --- a/src/sonic-yang-models/yang-models/sonic-pbh.yang +++ b/src/sonic-yang-models/yang-models/sonic-pbh.yang @@ -23,41 +23,64 @@ module sonic-pbh { description "First Revision"; } + typedef hash-field { + description "Represents native hash field"; + type enumeration { + enum INNER_IP_PROTOCOL; + enum INNER_L4_DST_PORT; + enum INNER_L4_SRC_PORT; + enum INNER_DST_IPV4; + enum INNER_SRC_IPV4; + enum INNER_DST_IPV6; + enum INNER_SRC_IPV6; + } + } + + typedef packet-action { + description "Represents packet action"; + type enumeration { + enum SET_ECMP_HASH; + enum SET_LAG_HASH; + } + } + + typedef flow-counter { + description "Represents flow counter state"; + type enumeration { + enum DISABLED; + enum ENABLED; + } + } + container sonic-pbh { - container PBH_HASH { + container PBH_HASH_FIELD { - description "PBH_HASH part of config_db.json"; + description "PBH_HASH_FIELD part of config_db.json"; - list PBH_HASH_LIST { + list PBH_HASH_FIELD_LIST { - key "hash_name"; + key "hash_field_name"; - leaf hash_name { - description "The name of this hash"; + leaf hash_field_name { + description "The name of this hash field"; type string; } leaf hash_field { - description "Configures native hash field for this hash"; - mandatory true; - type string { - pattern "INNER_IP_PROTOCOL|INNER_L4_DST_PORT|INNER_L4_SRC_PORT|INNER_DST_IPV4|INNER_SRC_IPV4|INNER_DST_IPV6|INNER_SRC_IPV6"; - } - } - - leaf ipv4_mask { - description "Configures IPv4 address mask for this hash"; + description "Configures native hash field for this hash field"; mandatory true; - type inet:ipv4-address; - when "boolean(../hash_field[.='INNER_DST_IPV4' or .='INNER_SRC_IPV4'])"; + type pbh:hash-field; } - leaf ipv6_mask { - description "Configures IPv6 address mask for this hash"; + leaf ip_mask { + description "Configures IPv4/IPv6 address mask for this hash field"; mandatory true; - type inet:ipv6-address; - when "boolean(../hash_field[.='INNER_DST_IPV6' or .='INNER_SRC_IPV6'])"; + type union { + type inet:ipv4-address; + type inet:ipv6-address; + } + when "boolean(../hash_field[.='INNER_DST_IPV4' or .='INNER_SRC_IPV4' or .='INNER_DST_IPV6' or .='INNER_SRC_IPV6'])"; } leaf sequence_id { @@ -66,6 +89,32 @@ module sonic-pbh { type uint32; } + } + /* end of PBH_HASH_FIELD_LIST */ + } + /* end of container PBH_HASH_FIELD */ + + container PBH_HASH { + + description "PBH_HASH part of config_db.json"; + + list PBH_HASH_LIST { + + key "hash_name"; + + leaf hash_name { + description "The name of this hash"; + type string; + } + + leaf-list hash_field_list { + description "The list of hash fields to apply with this hash"; + min-elements 1; + type leafref { + path "/pbh:sonic-pbh/pbh:PBH_HASH_FIELD/pbh:PBH_HASH_FIELD_LIST/pbh:hash_field_name"; + } + } + } /* end of PBH_HASH_LIST */ } @@ -98,43 +147,43 @@ module sonic-pbh { } leaf gre_key { - description "Configures packet match for this rule: GRE key"; + description "Configures packet match for this rule: GRE key (value/mask)"; type string { pattern "(0x){1}[a-fA-F0-9]+/(0x){1}[a-fA-F0-9]+"; } } leaf ip_protocol { - description "Configures packet match for this rule: IP protocol"; + description "Configures packet match for this rule: IP protocol (value/mask)"; type string { pattern "(0x){1}[a-fA-F0-9]+/(0x){1}[a-fA-F0-9]+"; } } leaf ipv6_next_header { - description "Configures packet match for this rule: IPv6 Next header"; + description "Configures packet match for this rule: IPv6 Next header (value/mask)"; type string { pattern "(0x){1}[a-fA-F0-9]+/(0x){1}[a-fA-F0-9]+"; } } leaf l4_dst_port { - description "Configures packet match for this rule: L4 destination port"; + description "Configures packet match for this rule: L4 destination port (value/mask)"; type string { pattern "(0x){1}[a-fA-F0-9]+/(0x){1}[a-fA-F0-9]+"; } } leaf inner_ether_type { - description "Configures packet match for this rule: inner EtherType"; + description "Configures packet match for this rule: inner EtherType (value/mask)"; type string { pattern "(0x){1}[a-fA-F0-9]+/(0x){1}[a-fA-F0-9]+"; } } - leaf-list hash_list { - description "The list of hash fields to apply with this rule"; - min-elements 1; + leaf hash { + description "The hash to apply with this rule"; + mandatory true; type leafref { path "/pbh:sonic-pbh/pbh:PBH_HASH/pbh:PBH_HASH_LIST/pbh:hash_name"; } @@ -142,17 +191,13 @@ module sonic-pbh { leaf packet_action { description "Configures packet action for this rule"; - type string { - pattern "SET_ECMP_HASH|SET_LAG_HASH"; - } + type pbh:packet-action; default "SET_ECMP_HASH"; } leaf flow_counter { description "Enables/Disables packet/byte counter for this rule"; - type string { - pattern "DISABLED|ENABLED"; - } + type pbh:flow-counter; default "DISABLED"; } @@ -176,6 +221,7 @@ module sonic-pbh { leaf-list interface_list { description "Interfaces to which this table is applied"; + min-elements 1; type union { type leafref { path "/port:sonic-port/port:PORT/port:PORT_LIST/port:name"; @@ -183,11 +229,7 @@ module sonic-pbh { type leafref { path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name"; } - type string { - pattern ""; - } } - default ""; } leaf description { From e0e9a0a309b63b5cddcebf27228423c024a1447a Mon Sep 17 00:00:00 2001 From: Nazarii Hnydyn Date: Thu, 3 Jun 2021 10:30:24 +0000 Subject: [PATCH 07/11] [pbh]: Add YANG UT rev01. Signed-off-by: Nazarii Hnydyn --- .../tests/files/sample_config_db.json | 52 +- .../tests/yang_model_tests/tests/pbh.json | 90 +-- .../yang_model_tests/tests_config/pbh.json | 556 ++---------------- 3 files changed, 77 insertions(+), 621 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 b5c3ba6ff979..4fc73909142a 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -630,7 +630,7 @@ ] } }, - "PBH_HASH": { + "PBH_HASH_FIELD": { "inner_ip_proto": { "hash_field": "INNER_IP_PROTOCOL", "sequence_id": "1" @@ -645,52 +645,62 @@ }, "inner_dst_ipv4": { "hash_field": "INNER_DST_IPV4", - "ipv4_mask": "255.0.0.0", + "ip_mask": "255.0.0.0", "sequence_id": "3" }, "inner_src_ipv4": { "hash_field": "INNER_SRC_IPV4", - "ipv4_mask": "0.0.0.255", + "ip_mask": "0.0.0.255", "sequence_id": "3" }, "inner_dst_ipv6": { "hash_field": "INNER_DST_IPV6", - "ipv6_mask": "ffff::", + "ip_mask": "ffff::", "sequence_id": "4" }, "inner_src_ipv6": { "hash_field": "INNER_SRC_IPV6", - "ipv6_mask": "::ffff", + "ip_mask": "::ffff", "sequence_id": "4" } }, - "PBH_RULE": { - "pbh_table|nvgre": { - "priority": "1", - "gre_key": "0x2500/0xffffff00", - "inner_ether_type": "0x86dd/0xffff", - "hash_list": [ + "PBH_HASH": { + "inner_v4_hash": { + "hash_field_list": [ + "inner_ip_proto", + "inner_l4_dst_port", + "inner_l4_src_port", + "inner_dst_ipv4", + "inner_src_ipv4" + ] + }, + "inner_v6_hash": { + "hash_field_list": [ "inner_ip_proto", "inner_l4_dst_port", "inner_l4_src_port", "inner_dst_ipv6", "inner_src_ipv6" - ], - "packet_action": "SET_ECMP_HASH" + ] + } + }, + "PBH_RULE": { + "pbh_table|nvgre": { + "priority": "1", + "gre_key": "0x2500/0xffffff00", + "inner_ether_type": "0x86dd/0xffff", + "hash": "inner_v6_hash", + "packet_action": "SET_ECMP_HASH", + "flow_counter": "DISABLED" }, "pbh_table|vxlan": { "priority": "2", "ip_protocol": "0x11/0xff", "l4_dst_port": "0x12b5/0xffff", "inner_ether_type": "0x0800/0xffff", - "hash_list": [ - "inner_ip_proto", - "inner_l4_dst_port", - "inner_l4_src_port", - "inner_dst_ipv4", - "inner_src_ipv4" - ], - "packet_action": "SET_LAG_HASH" + "hash": "inner_v4_hash", + "packet_action": "SET_LAG_HASH", + "flow_counter": "ENABLED" } }, "PBH_TABLE": { diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/pbh.json b/src/sonic-yang-models/tests/yang_model_tests/tests/pbh.json index 6fd6d17d4608..a2fac41f592f 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/pbh.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/pbh.json @@ -1,91 +1,5 @@ { - "PBH_TABLE_RULE_HASH_VALID": { - "desc": "Configure PBH_TABLE, PBH_RULE and PBH_HASH." - }, - "PBH_TABLE_INVALID_INTERFACE": { - "desc": "Configure non-existing PORT/PORTCHANNEL in PBH_TABLE.", - "eStrKey" : "InvalidValue" - }, - "PBH_TABLE_INVALID_DESCRIPTION": { - "desc": "Configure invalid DESCRIPTION in PBH_TABLE.", - "eStrKey" : "Range" - }, - "PBH_RULE_INVALID_TABLE": { - "desc": "Configure non-existing PBH_TABLE in PBH_RULE.", - "eStrKey": "LeafRef" - }, - "PBH_RULE_INVALID_PRIORITY": { - "desc": "Configure invalid PRIORITY in PBH_RULE.", - "eStrKey": "InvalidValue" - }, - "PBH_RULE_INVALID_GRE_KEY": { - "desc": "Configure invalid GRE_KEY in PBH_RULE.", - "eStrKey" : "Pattern" - }, - "PBH_RULE_INVALID_IP_PROTOCOL": { - "desc": "Configure invalid IP_PROTOCOL in PBH_RULE.", - "eStrKey" : "Pattern" - }, - "PBH_RULE_INVALID_IPV6_NEXT_HEADER": { - "desc": "Configure invalid IPV6_NEXT_HEADER in PBH_RULE.", - "eStrKey" : "Pattern" - }, - "PBH_RULE_INVALID_L4_DST_PORT": { - "desc": "Configure invalid L4_DST_PORT in PBH_RULE.", - "eStrKey" : "Pattern" - }, - "PBH_RULE_INVALID_INNER_ETHER_TYPE": { - "desc": "Configure invalid INNER_ETHER_TYPE in PBH_RULE.", - "eStrKey" : "Pattern" - }, - "PBH_RULE_INVALID_HASH": { - "desc": "Configure non-existing PBH_HASH in PBH_RULE.", - "eStrKey" : "LeafRef" - }, - "PBH_RULE_INVALID_PACKET_ACTION": { - "desc": "Configure invalid PACKET_ACTION in PBH_RULE.", - "eStrKey" : "Pattern" - }, - "PBH_RULE_INVALID_FLOW_COUNTER": { - "desc": "Configure invalid FLOW_COUNTER in PBH_RULE.", - "eStrKey" : "Pattern" - }, - "PBH_RULE_DEFAULT_VALUE_PACKET_ACTION": { - "desc": "Verify default value for PACKET_ACTION field in PBH_RULE.", - "eStrKey" : "Verify", - "verify": { - "xpath": "/sonic-pbh:sonic-pbh/PBH_RULE/PBH_RULE_LIST[table_name='pbh_table'][rule_name='nvgre']/packet_action", - "key": "sonic-pbh:packet_action", - "value": "SET_ECMP_HASH" - } - }, - "PBH_RULE_DEFAULT_VALUE_FLOW_COUNTER": { - "desc": "Verify default value for FLOW_COUNTER field in PBH_RULE.", - "eStrKey" : "Verify", - "verify": { - "xpath": "/sonic-pbh:sonic-pbh/PBH_RULE/PBH_RULE_LIST[table_name='pbh_table'][rule_name='nvgre']/flow_counter", - "key": "sonic-pbh:flow_counter", - "value": "DISABLED" - } - }, - "PBH_HASH_INVALID_HASH_FIELD": { - "desc": "Configure invalid HASH_FIELD in PBH_HASH.", - "eStrKey" : "Pattern" - }, - "PBH_RULE_HASH_FIELD_IPV6_MASK_MISMATCH": { - "desc": "Configure HASH_FIELD (INNER_DST_IPV4) with IPV6_MASK in PBH_HASH.", - "eStrKey" : "When" - }, - "PBH_RULE_INVALID_IPV4_MASK": { - "desc": "Configure invalid IPV4_MASK in PBH_HASH.", - "eStrKey" : "Pattern" - }, - "PBH_RULE_INVALID_IPV6_MASK": { - "desc": "Configure invalid IPV6_MASK in PBH_HASH.", - "eStrKey" : "Pattern" - }, - "PBH_RULE_INVALID_SEQUENCE_ID": { - "desc": "Configure invalid SEQUENCE_ID in PBH_HASH.", - "eStrKey" : "InvalidValue" + "PBH_TABLE_RULE_HASH_HASH_FIELD_VALID": { + "desc": "Configure PBH_TABLE, PBH_RULE, PBH_HASH and PBH_HASH_FIELD" } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/pbh.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/pbh.json index bc6e6b2c5910..1d0c0d6f4128 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/pbh.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/pbh.json @@ -1,49 +1,73 @@ { - "PBH_TABLE_RULE_HASH_VALID": { + "PBH_TABLE_RULE_HASH_HASH_FIELD_VALID": { "sonic-pbh:sonic-pbh": { - "sonic-pbh:PBH_HASH": { - "PBH_HASH_LIST": [ + "sonic-pbh:PBH_HASH_FIELD": { + "PBH_HASH_FIELD_LIST": [ { - "hash_name": "inner_ip_proto", + "hash_field_name": "inner_ip_proto", "hash_field": "INNER_IP_PROTOCOL", "sequence_id": 1 }, { - "hash_name": "inner_l4_dst_port", + "hash_field_name": "inner_l4_dst_port", "hash_field": "INNER_L4_DST_PORT", "sequence_id": 2 }, { - "hash_name": "inner_l4_src_port", + "hash_field_name": "inner_l4_src_port", "hash_field": "INNER_L4_SRC_PORT", "sequence_id": 2 }, { - "hash_name": "inner_dst_ipv4", + "hash_field_name": "inner_dst_ipv4", "hash_field": "INNER_DST_IPV4", - "ipv4_mask": "255.0.0.0", + "ip_mask": "255.0.0.0", "sequence_id": 3 }, { - "hash_name": "inner_src_ipv4", + "hash_field_name": "inner_src_ipv4", "hash_field": "INNER_SRC_IPV4", - "ipv4_mask": "0.0.0.255", + "ip_mask": "0.0.0.255", "sequence_id": 3 }, { - "hash_name": "inner_dst_ipv6", + "hash_field_name": "inner_dst_ipv6", "hash_field": "INNER_DST_IPV6", - "ipv6_mask": "ffff::", + "ip_mask": "ffff::", "sequence_id": 4 }, { - "hash_name": "inner_src_ipv6", + "hash_field_name": "inner_src_ipv6", "hash_field": "INNER_SRC_IPV6", - "ipv6_mask": "::ffff", + "ip_mask": "::ffff", "sequence_id": 4 } ] }, + "sonic-pbh:PBH_HASH": { + "PBH_HASH_LIST": [ + { + "hash_name": "inner_v4_hash", + "hash_field_list": [ + "inner_ip_proto", + "inner_l4_dst_port", + "inner_l4_src_port", + "inner_dst_ipv4", + "inner_src_ipv4" + ] + }, + { + "hash_name": "inner_v6_hash", + "hash_field_list": [ + "inner_ip_proto", + "inner_l4_dst_port", + "inner_l4_src_port", + "inner_dst_ipv6", + "inner_src_ipv6" + ] + } + ] + }, "sonic-pbh:PBH_RULE": { "PBH_RULE_LIST": [ { @@ -52,14 +76,9 @@ "priority": 1, "gre_key": "0x2500/0xffffff00", "inner_ether_type": "0x86dd/0xffff", - "hash_list": [ - "inner_ip_proto", - "inner_l4_dst_port", - "inner_l4_src_port", - "inner_dst_ipv6", - "inner_src_ipv6" - ], - "packet_action": "SET_ECMP_HASH" + "hash": "inner_v6_hash", + "packet_action": "SET_ECMP_HASH", + "flow_counter": "DISABLED" }, { "table_name": "pbh_table", @@ -68,14 +87,9 @@ "ip_protocol": "0x11/0xff", "l4_dst_port": "0x12b5/0xffff", "inner_ether_type": "0x0800/0xffff", - "hash_list": [ - "inner_ip_proto", - "inner_l4_dst_port", - "inner_l4_src_port", - "inner_dst_ipv4", - "inner_src_ipv4" - ], - "packet_action": "SET_LAG_HASH" + "hash": "inner_v4_hash", + "packet_action": "SET_LAG_HASH", + "flow_counter": "ENABLED" } ] }, @@ -124,487 +138,5 @@ ] } } - }, - "PBH_TABLE_INVALID_INTERFACE": { - "sonic-pbh:sonic-pbh": { - "sonic-pbh:PBH_TABLE": { - "PBH_TABLE_LIST": [ - { - "table_name": "pbh_table", - "interface_list": [ - "EthernetX", - "PortChannel000X" - ], - "description": "NVGRE and VxLAN" - } - ] - } - } - }, - "PBH_TABLE_INVALID_DESCRIPTION": { - "sonic-pbh:sonic-pbh": { - "sonic-pbh:PBH_TABLE": { - "PBH_TABLE_LIST": [ - { - "table_name": "pbh_table", - "description": "" - } - ] - } - } - }, - "PBH_RULE_INVALID_TABLE": { - "sonic-pbh:sonic-pbh": { - "sonic-pbh:PBH_HASH": { - "PBH_HASH_LIST": [ - { - "hash_name": "inner_ip_proto", - "hash_field": "INNER_IP_PROTOCOL", - "sequence_id": 1 - } - ] - }, - "sonic-pbh:PBH_RULE": { - "PBH_RULE_LIST": [ - { - "table_name": "invalid_value", - "rule_name": "nvgre", - "priority": 1, - "hash_list": [ - "inner_ip_proto" - ] - } - ] - } - } - }, - "PBH_RULE_INVALID_PRIORITY": { - "sonic-pbh:sonic-pbh": { - "sonic-pbh:PBH_HASH": { - "PBH_HASH_LIST": [ - { - "hash_name": "inner_ip_proto", - "hash_field": "INNER_IP_PROTOCOL", - "sequence_id": 1 - } - ] - }, - "sonic-pbh:PBH_RULE": { - "PBH_RULE_LIST": [ - { - "table_name": "pbh_table", - "rule_name": "nvgre", - "priority": 4294967296, - "hash_list": [ - "inner_ip_proto" - ] - } - ] - }, - "sonic-pbh:PBH_TABLE": { - "PBH_TABLE_LIST": [ - { - "table_name": "pbh_table", - "description": "NVGRE" - } - ] - } - } - }, - "PBH_RULE_INVALID_GRE_KEY": { - "sonic-pbh:sonic-pbh": { - "sonic-pbh:PBH_HASH": { - "PBH_HASH_LIST": [ - { - "hash_name": "inner_ip_proto", - "hash_field": "INNER_IP_PROTOCOL", - "sequence_id": 1 - } - ] - }, - "sonic-pbh:PBH_RULE": { - "PBH_RULE_LIST": [ - { - "table_name": "pbh_table", - "rule_name": "nvgre", - "priority": 1, - "gre_key": "2500/0xffffff00", - "hash_list": [ - "inner_ip_proto" - ] - } - ] - }, - "sonic-pbh:PBH_TABLE": { - "PBH_TABLE_LIST": [ - { - "table_name": "pbh_table", - "description": "NVGRE" - } - ] - } - } - }, - "PBH_RULE_INVALID_IP_PROTOCOL": { - "sonic-pbh:sonic-pbh": { - "sonic-pbh:PBH_HASH": { - "PBH_HASH_LIST": [ - { - "hash_name": "inner_ip_proto", - "hash_field": "INNER_IP_PROTOCOL", - "sequence_id": 1 - } - ] - }, - "sonic-pbh:PBH_RULE": { - "PBH_RULE_LIST": [ - { - "table_name": "pbh_table", - "rule_name": "nvgre", - "priority": 1, - "ip_protocol": "0x11/ff", - "hash_list": [ - "inner_ip_proto" - ] - } - ] - }, - "sonic-pbh:PBH_TABLE": { - "PBH_TABLE_LIST": [ - { - "table_name": "pbh_table", - "description": "NVGRE" - } - ] - } - } - }, - "PBH_RULE_INVALID_IPV6_NEXT_HEADER": { - "sonic-pbh:sonic-pbh": { - "sonic-pbh:PBH_HASH": { - "PBH_HASH_LIST": [ - { - "hash_name": "inner_ip_proto", - "hash_field": "INNER_IP_PROTOCOL", - "sequence_id": 1 - } - ] - }, - "sonic-pbh:PBH_RULE": { - "PBH_RULE_LIST": [ - { - "table_name": "pbh_table", - "rule_name": "nvgre", - "priority": 1, - "ipv6_next_header": "0x11", - "hash_list": [ - "inner_ip_proto" - ] - } - ] - }, - "sonic-pbh:PBH_TABLE": { - "PBH_TABLE_LIST": [ - { - "table_name": "pbh_table", - "description": "NVGRE" - } - ] - } - } - }, - "PBH_RULE_INVALID_L4_DST_PORT": { - "sonic-pbh:sonic-pbh": { - "sonic-pbh:PBH_HASH": { - "PBH_HASH_LIST": [ - { - "hash_name": "inner_ip_proto", - "hash_field": "INNER_IP_PROTOCOL", - "sequence_id": 1 - } - ] - }, - "sonic-pbh:PBH_RULE": { - "PBH_RULE_LIST": [ - { - "table_name": "pbh_table", - "rule_name": "nvgre", - "priority": 1, - "l4_dst_port": "0xffff", - "hash_list": [ - "inner_ip_proto" - ] - } - ] - }, - "sonic-pbh:PBH_TABLE": { - "PBH_TABLE_LIST": [ - { - "table_name": "pbh_table", - "description": "NVGRE" - } - ] - } - } - }, - "PBH_RULE_INVALID_INNER_ETHER_TYPE": { - "sonic-pbh:sonic-pbh": { - "sonic-pbh:PBH_HASH": { - "PBH_HASH_LIST": [ - { - "hash_name": "inner_ip_proto", - "hash_field": "INNER_IP_PROTOCOL", - "sequence_id": 1 - } - ] - }, - "sonic-pbh:PBH_RULE": { - "PBH_RULE_LIST": [ - { - "table_name": "pbh_table", - "rule_name": "nvgre", - "priority": 1, - "inner_ether_type": "0x0800 / 0xffff", - "hash_list": [ - "inner_ip_proto" - ] - } - ] - }, - "sonic-pbh:PBH_TABLE": { - "PBH_TABLE_LIST": [ - { - "table_name": "pbh_table", - "description": "NVGRE" - } - ] - } - } - }, - "PBH_RULE_INVALID_HASH": { - "sonic-pbh:sonic-pbh": { - "sonic-pbh:PBH_RULE": { - "PBH_RULE_LIST": [ - { - "table_name": "pbh_table", - "rule_name": "nvgre", - "priority": 1, - "hash_list": [ - "invalid_value" - ] - } - ] - }, - "sonic-pbh:PBH_TABLE": { - "PBH_TABLE_LIST": [ - { - "table_name": "pbh_table", - "description": "NVGRE" - } - ] - } - } - }, - "PBH_RULE_INVALID_PACKET_ACTION": { - "sonic-pbh:sonic-pbh": { - "sonic-pbh:PBH_HASH": { - "PBH_HASH_LIST": [ - { - "hash_name": "inner_ip_proto", - "hash_field": "INNER_IP_PROTOCOL", - "sequence_id": 1 - } - ] - }, - "sonic-pbh:PBH_RULE": { - "PBH_RULE_LIST": [ - { - "table_name": "pbh_table", - "rule_name": "nvgre", - "priority": 1, - "hash_list": [ - "inner_ip_proto" - ], - "packet_action": "INVALID_VALUE" - } - ] - }, - "sonic-pbh:PBH_TABLE": { - "PBH_TABLE_LIST": [ - { - "table_name": "pbh_table", - "description": "NVGRE" - } - ] - } - } - }, - "PBH_RULE_INVALID_FLOW_COUNTER": { - "sonic-pbh:sonic-pbh": { - "sonic-pbh:PBH_HASH": { - "PBH_HASH_LIST": [ - { - "hash_name": "inner_ip_proto", - "hash_field": "INNER_IP_PROTOCOL", - "sequence_id": 1 - } - ] - }, - "sonic-pbh:PBH_RULE": { - "PBH_RULE_LIST": [ - { - "table_name": "pbh_table", - "rule_name": "nvgre", - "priority": 1, - "hash_list": [ - "inner_ip_proto" - ], - "flow_counter": "INVALID_VALUE" - } - ] - }, - "sonic-pbh:PBH_TABLE": { - "PBH_TABLE_LIST": [ - { - "table_name": "pbh_table", - "description": "NVGRE" - } - ] - } - } - }, - "PBH_RULE_DEFAULT_VALUE_PACKET_ACTION": { - "sonic-pbh:sonic-pbh": { - "sonic-pbh:PBH_HASH": { - "PBH_HASH_LIST": [ - { - "hash_name": "inner_ip_proto", - "hash_field": "INNER_IP_PROTOCOL", - "sequence_id": 1 - } - ] - }, - "sonic-pbh:PBH_RULE": { - "PBH_RULE_LIST": [ - { - "table_name": "pbh_table", - "rule_name": "nvgre", - "priority": 1, - "hash_list": [ - "inner_ip_proto" - ] - } - ] - }, - "sonic-pbh:PBH_TABLE": { - "PBH_TABLE_LIST": [ - { - "table_name": "pbh_table", - "description": "NVGRE" - } - ] - } - } - }, - "PBH_RULE_DEFAULT_VALUE_FLOW_COUNTER": { - "sonic-pbh:sonic-pbh": { - "sonic-pbh:PBH_HASH": { - "PBH_HASH_LIST": [ - { - "hash_name": "inner_ip_proto", - "hash_field": "INNER_IP_PROTOCOL", - "sequence_id": 1 - } - ] - }, - "sonic-pbh:PBH_RULE": { - "PBH_RULE_LIST": [ - { - "table_name": "pbh_table", - "rule_name": "nvgre", - "priority": 1, - "hash_list": [ - "inner_ip_proto" - ] - } - ] - }, - "sonic-pbh:PBH_TABLE": { - "PBH_TABLE_LIST": [ - { - "table_name": "pbh_table", - "description": "NVGRE" - } - ] - } - } - }, - "PBH_HASH_INVALID_HASH_FIELD": { - "sonic-pbh:sonic-pbh": { - "sonic-pbh:PBH_HASH": { - "PBH_HASH_LIST": [ - { - "hash_name": "inner_ip_proto", - "hash_field": "INVALID_VALUE", - "sequence_id": 1 - } - ] - } - } - }, - "PBH_RULE_HASH_FIELD_IPV6_MASK_MISMATCH": { - "sonic-pbh:sonic-pbh": { - "sonic-pbh:PBH_HASH": { - "PBH_HASH_LIST": [ - { - "hash_name": "inner_ip_proto", - "hash_field": "INNER_DST_IPV4", - "ipv6_mask": "ffff::", - "sequence_id": 1 - } - ] - } - } - }, - "PBH_RULE_INVALID_IPV4_MASK": { - "sonic-pbh:sonic-pbh": { - "sonic-pbh:PBH_HASH": { - "PBH_HASH_LIST": [ - { - "hash_name": "inner_ip_proto", - "hash_field": "INNER_DST_IPV4", - "ipv4_mask": "ffff::", - "sequence_id": 1 - } - ] - } - } - }, - "PBH_RULE_INVALID_IPV6_MASK": { - "sonic-pbh:sonic-pbh": { - "sonic-pbh:PBH_HASH": { - "PBH_HASH_LIST": [ - { - "hash_name": "inner_ip_proto", - "hash_field": "INNER_DST_IPV6", - "ipv6_mask": "255.0.0.0", - "sequence_id": 1 - } - ] - } - } - }, - "PBH_RULE_INVALID_SEQUENCE_ID": { - "sonic-pbh:sonic-pbh": { - "sonic-pbh:PBH_HASH": { - "PBH_HASH_LIST": [ - { - "hash_name": "inner_ip_proto", - "hash_field": "INNER_IP_PROTOCOL", - "sequence_id": 4294967296 - } - ] - } - } } } From 38876d268de85ebacfdb5d2fc8616d7b59024396 Mon Sep 17 00:00:00 2001 From: Nazarii Hnydyn Date: Tue, 15 Jun 2021 16:39:01 +0000 Subject: [PATCH 08/11] [pbh]: YANG model rev05. Signed-off-by: Nazarii Hnydyn --- .../yang-models/sonic-pbh.yang | 43 +++++++++++-------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/src/sonic-yang-models/yang-models/sonic-pbh.yang b/src/sonic-yang-models/yang-models/sonic-pbh.yang index 08881734eded..5840b1ef432d 100644 --- a/src/sonic-yang-models/yang-models/sonic-pbh.yang +++ b/src/sonic-yang-models/yang-models/sonic-pbh.yang @@ -17,7 +17,7 @@ module sonic-pbh { prefix lag; } - description "PBH YANG Module for SONiC OS"; + description "PBH YANG Module for SONiC OS: hashing for NVGRE & VxLAN with IPv4/IPv6 inner 5-tuple"; revision 2021-04-23 { description "First Revision"; @@ -64,7 +64,9 @@ module sonic-pbh { leaf hash_field_name { description "The name of this hash field"; - type string; + type string { + length 1..255; + } } leaf hash_field { @@ -76,10 +78,9 @@ module sonic-pbh { leaf ip_mask { description "Configures IPv4/IPv6 address mask for this hash field"; mandatory true; - type union { - type inet:ipv4-address; - type inet:ipv6-address; - } + type inet:ip-address-no-zone; + must "(boolean(../hash_field[.='INNER_DST_IPV4' or .='INNER_SRC_IPV4']) and contains(current(), '.')) + or (boolean(../hash_field[.='INNER_DST_IPV6' or .='INNER_SRC_IPV6']) and contains(current(), ':'))"; when "boolean(../hash_field[.='INNER_DST_IPV4' or .='INNER_SRC_IPV4' or .='INNER_DST_IPV6' or .='INNER_SRC_IPV6'])"; } @@ -104,7 +105,9 @@ module sonic-pbh { leaf hash_name { description "The name of this hash"; - type string; + type string { + length 1..255; + } } leaf-list hash_field_list { @@ -137,7 +140,9 @@ module sonic-pbh { leaf rule_name { description "The name of this rule"; - type string; + type string { + length 1..255; + } } leaf priority { @@ -149,35 +154,35 @@ module sonic-pbh { leaf gre_key { description "Configures packet match for this rule: GRE key (value/mask)"; type string { - pattern "(0x){1}[a-fA-F0-9]+/(0x){1}[a-fA-F0-9]+"; + pattern "(0x){1}[a-fA-F0-9]{1,8}/(0x){1}[a-fA-F0-9]{1,8}"; } } leaf ip_protocol { - description "Configures packet match for this rule: IP protocol (value/mask)"; + description "Configures packet match for this rule: IP protocol (IANA Protocol Numbers)"; type string { - pattern "(0x){1}[a-fA-F0-9]+/(0x){1}[a-fA-F0-9]+"; + pattern "(0x){1}[a-fA-F0-9]{1,2}"; } } leaf ipv6_next_header { - description "Configures packet match for this rule: IPv6 Next header (value/mask)"; + description "Configures packet match for this rule: IPv6 Next header (IANA Protocol Numbers)"; type string { - pattern "(0x){1}[a-fA-F0-9]+/(0x){1}[a-fA-F0-9]+"; + pattern "(0x){1}[a-fA-F0-9]{1,2}"; } } leaf l4_dst_port { - description "Configures packet match for this rule: L4 destination port (value/mask)"; + description "Configures packet match for this rule: L4 destination port"; type string { - pattern "(0x){1}[a-fA-F0-9]+/(0x){1}[a-fA-F0-9]+"; + pattern "(0x){1}[a-fA-F0-9]{1,4}"; } } leaf inner_ether_type { - description "Configures packet match for this rule: inner EtherType (value/mask)"; + description "Configures packet match for this rule: inner EtherType (IANA Ethertypes)"; type string { - pattern "(0x){1}[a-fA-F0-9]+/(0x){1}[a-fA-F0-9]+"; + pattern "(0x){1}[a-fA-F0-9]{1,4}"; } } @@ -216,7 +221,9 @@ module sonic-pbh { leaf table_name { description "The name of this table"; - type string; + type string { + length 1..255; + } } leaf-list interface_list { From 0a4a977ed11b4817e401034526060015be9f1402 Mon Sep 17 00:00:00 2001 From: Nazarii Hnydyn Date: Tue, 15 Jun 2021 16:41:40 +0000 Subject: [PATCH 09/11] [pbh]: Add YANG UT rev02. Signed-off-by: Nazarii Hnydyn --- .../tests/files/sample_config_db.json | 8 +- .../tests/yang_model_tests/test_yang_model.py | 2 + .../tests/yang_model_tests/tests/pbh.json | 100 ++- .../yang_model_tests/tests_config/pbh.json | 781 +++++++++++++++++- 4 files changed, 882 insertions(+), 9 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 4fc73909142a..2e9140359e2a 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -688,16 +688,16 @@ "pbh_table|nvgre": { "priority": "1", "gre_key": "0x2500/0xffffff00", - "inner_ether_type": "0x86dd/0xffff", + "inner_ether_type": "0x86dd", "hash": "inner_v6_hash", "packet_action": "SET_ECMP_HASH", "flow_counter": "DISABLED" }, "pbh_table|vxlan": { "priority": "2", - "ip_protocol": "0x11/0xff", - "l4_dst_port": "0x12b5/0xffff", - "inner_ether_type": "0x0800/0xffff", + "ip_protocol": "0x11", + "l4_dst_port": "0x12b5", + "inner_ether_type": "0x0800", "hash": "inner_v4_hash", "packet_action": "SET_LAG_HASH", "flow_counter": "ENABLED" diff --git a/src/sonic-yang-models/tests/yang_model_tests/test_yang_model.py b/src/sonic-yang-models/tests/yang_model_tests/test_yang_model.py index 5ed4ea3f6daf..355c9086a6fb 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/test_yang_model.py +++ b/src/sonic-yang-models/tests/yang_model_tests/test_yang_model.py @@ -46,6 +46,8 @@ def initTest(self): 'Mandatory': ['required element', 'Missing'], 'Verify': ['verified'], 'Range': ['does not satisfy', 'range'], + 'MinElements': ['Too few'], + 'MaxElements': ['Too many'], 'None': [] } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/pbh.json b/src/sonic-yang-models/tests/yang_model_tests/tests/pbh.json index a2fac41f592f..f84d513e8bfe 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/pbh.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/pbh.json @@ -1,5 +1,103 @@ { "PBH_TABLE_RULE_HASH_HASH_FIELD_VALID": { - "desc": "Configure PBH_TABLE, PBH_RULE, PBH_HASH and PBH_HASH_FIELD" + "desc": "Configure PBH_TABLE, PBH_RULE, PBH_HASH and PBH_HASH_FIELD." + }, + "PBH_TABLE_INVALID_INTERFACE": { + "desc": "Configure non-existing PORT/PORTCHANNEL in PBH_TABLE.", + "eStrKey": "InvalidValue" + }, + "PBH_TABLE_EMPTY_INTERFACE_LIST": { + "desc": "Configure empty INTERFACE_LIST in PBH_TABLE.", + "eStrKey": "MinElements" + }, + "PBH_TABLE_INVALID_DESCRIPTION": { + "desc": "Configure invalid DESCRIPTION in PBH_TABLE.", + "eStrKey": "Range" + }, + "PBH_RULE_INVALID_TABLE": { + "desc": "Configure non-existing PBH_TABLE in PBH_RULE.", + "eStrKey": "LeafRef" + }, + "PBH_RULE_INVALID_PRIORITY": { + "desc": "Configure invalid PRIORITY in PBH_RULE.", + "eStrKey": "InvalidValue" + }, + "PBH_RULE_INVALID_GRE_KEY": { + "desc": "Configure invalid GRE_KEY in PBH_RULE.", + "eStrKey": "Pattern" + }, + "PBH_RULE_INVALID_IP_PROTOCOL": { + "desc": "Configure invalid IP_PROTOCOL in PBH_RULE.", + "eStrKey": "Pattern" + }, + "PBH_RULE_INVALID_IPV6_NEXT_HEADER": { + "desc": "Configure invalid IPV6_NEXT_HEADER in PBH_RULE.", + "eStrKey": "Pattern" + }, + "PBH_RULE_INVALID_L4_DST_PORT": { + "desc": "Configure invalid L4_DST_PORT in PBH_RULE.", + "eStrKey": "Pattern" + }, + "PBH_RULE_INVALID_INNER_ETHER_TYPE": { + "desc": "Configure invalid INNER_ETHER_TYPE in PBH_RULE.", + "eStrKey": "Pattern" + }, + "PBH_RULE_INVALID_HASH": { + "desc": "Configure non-existing PBH_HASH in PBH_RULE.", + "eStrKey": "LeafRef" + }, + "PBH_RULE_INVALID_PACKET_ACTION": { + "desc": "Configure invalid PACKET_ACTION in PBH_RULE.", + "eStrKey": "InvalidValue" + }, + "PBH_RULE_INVALID_FLOW_COUNTER": { + "desc": "Configure invalid FLOW_COUNTER in PBH_RULE.", + "eStrKey": "InvalidValue" + }, + "PBH_RULE_DEFAULT_VALUE_PACKET_ACTION": { + "desc": "Verify default value for PACKET_ACTION field in PBH_RULE.", + "eStrKey": "Verify", + "verify": { + "xpath": "/sonic-pbh:sonic-pbh/PBH_RULE/PBH_RULE_LIST[table_name='pbh_table'][rule_name='nvgre']/packet_action", + "key": "sonic-pbh:packet_action", + "value": "SET_ECMP_HASH" + } + }, + "PBH_RULE_DEFAULT_VALUE_FLOW_COUNTER": { + "desc": "Verify default value for FLOW_COUNTER field in PBH_RULE.", + "eStrKey": "Verify", + "verify": { + "xpath": "/sonic-pbh:sonic-pbh/PBH_RULE/PBH_RULE_LIST[table_name='pbh_table'][rule_name='nvgre']/flow_counter", + "key": "sonic-pbh:flow_counter", + "value": "DISABLED" + } + }, + "PBH_HASH_INVALID_HASH_FIELD": { + "desc": "Configure invalid HASH_FIELD in PBH_HASH.", + "eStrKey": "LeafRef" + }, + "PBH_HASH_EMPTY_HASH_FIELD_LIST": { + "desc": "Configure empty HASH_FIELD_LIST in PBH_HASH.", + "eStrKey": "MinElements" + }, + "PBH_HASH_FIELD_INVALID_HASH_FIELD": { + "desc": "Configure invalid HASH_FIELD in PBH_HASH_FIELD.", + "eStrKey": "InvalidValue" + }, + "PBH_HASH_FIELD_INVALID_IP_MASK": { + "desc": "Configure invalid IP_MASK in PBH_HASH_FIELD.", + "eStrKey": "InvalidValue" + }, + "PBH_HASH_FIELD_IPV4_MASK_HASH_FIELD_MISMATCH": { + "desc": "Configure HASH_FIELD (INNER_DST_IPV6) with IPV4_MASK in PBH_HASH_FIELD.", + "eStrKey": "Must" + }, + "PBH_HASH_FIELD_IPV6_MASK_HASH_FIELD_MISMATCH": { + "desc": "Configure HASH_FIELD (INNER_DST_IPV4) with IPV6_MASK in PBH_HASH_FIELD.", + "eStrKey": "Must" + }, + "PBH_HASH_FIELD_INVALID_SEQUENCE_ID": { + "desc": "Configure invalid SEQUENCE_ID in PBH_HASH_FIELD.", + "eStrKey": "InvalidValue" } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/pbh.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/pbh.json index 1d0c0d6f4128..2d75244a228d 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/pbh.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/pbh.json @@ -75,7 +75,7 @@ "rule_name": "nvgre", "priority": 1, "gre_key": "0x2500/0xffffff00", - "inner_ether_type": "0x86dd/0xffff", + "inner_ether_type": "0x86dd", "hash": "inner_v6_hash", "packet_action": "SET_ECMP_HASH", "flow_counter": "DISABLED" @@ -84,9 +84,9 @@ "table_name": "pbh_table", "rule_name": "vxlan", "priority": 2, - "ip_protocol": "0x11/0xff", - "l4_dst_port": "0x12b5/0xffff", - "inner_ether_type": "0x0800/0xffff", + "ip_protocol": "0x11", + "l4_dst_port": "0x12b5", + "inner_ether_type": "0x0800", "hash": "inner_v4_hash", "packet_action": "SET_LAG_HASH", "flow_counter": "ENABLED" @@ -138,5 +138,778 @@ ] } } + }, + "PBH_TABLE_INVALID_INTERFACE": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_TABLE": { + "PBH_TABLE_LIST": [ + { + "table_name": "pbh_table", + "interface_list": [ + "EthernetX", + "PortChannel000X" + ], + "description": "NVGRE and VxLAN" + } + ] + } + } + }, + "PBH_TABLE_EMPTY_INTERFACE_LIST": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_TABLE": { + "PBH_TABLE_LIST": [ + { + "table_name": "pbh_table", + "description": "NVGRE and VxLAN" + } + ] + } + } + }, + "PBH_TABLE_INVALID_DESCRIPTION": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_TABLE": { + "PBH_TABLE_LIST": [ + { + "table_name": "pbh_table", + "interface_list": [ + "Ethernet0" + ], + "description": "" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet0", + "lanes": "0,1,2,3", + "speed": 100000 + } + ] + } + } + }, + "PBH_RULE_INVALID_TABLE": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_HASH_FIELD": { + "PBH_HASH_FIELD_LIST": [ + { + "hash_field_name": "inner_ip_proto", + "hash_field": "INNER_IP_PROTOCOL", + "sequence_id": 1 + } + ] + }, + "sonic-pbh:PBH_HASH": { + "PBH_HASH_LIST": [ + { + "hash_name": "inner_v6_hash", + "hash_field_list": [ + "inner_ip_proto" + ] + } + ] + }, + "sonic-pbh:PBH_RULE": { + "PBH_RULE_LIST": [ + { + "table_name": "invalid_value", + "rule_name": "nvgre", + "priority": 1, + "hash": "inner_v6_hash" + } + ] + } + } + }, + "PBH_RULE_INVALID_PRIORITY": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_HASH_FIELD": { + "PBH_HASH_FIELD_LIST": [ + { + "hash_field_name": "inner_ip_proto", + "hash_field": "INNER_IP_PROTOCOL", + "sequence_id": 1 + } + ] + }, + "sonic-pbh:PBH_HASH": { + "PBH_HASH_LIST": [ + { + "hash_name": "inner_v6_hash", + "hash_field_list": [ + "inner_ip_proto" + ] + } + ] + }, + "sonic-pbh:PBH_RULE": { + "PBH_RULE_LIST": [ + { + "table_name": "pbh_table", + "rule_name": "nvgre", + "priority": 4294967296, + "hash": "inner_v6_hash" + } + ] + }, + "sonic-pbh:PBH_TABLE": { + "PBH_TABLE_LIST": [ + { + "table_name": "pbh_table", + "interface_list": [ + "Ethernet0" + ], + "description": "NVGRE" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet0", + "lanes": "0,1,2,3", + "speed": 100000 + } + ] + } + } + }, + "PBH_RULE_INVALID_GRE_KEY": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_HASH_FIELD": { + "PBH_HASH_FIELD_LIST": [ + { + "hash_field_name": "inner_ip_proto", + "hash_field": "INNER_IP_PROTOCOL", + "sequence_id": 1 + } + ] + }, + "sonic-pbh:PBH_HASH": { + "PBH_HASH_LIST": [ + { + "hash_name": "inner_v6_hash", + "hash_field_list": [ + "inner_ip_proto" + ] + } + ] + }, + "sonic-pbh:PBH_RULE": { + "PBH_RULE_LIST": [ + { + "table_name": "pbh_table", + "rule_name": "nvgre", + "priority": 1, + "gre_key": "2500/0xffffff00", + "hash": "inner_v6_hash" + } + ] + }, + "sonic-pbh:PBH_TABLE": { + "PBH_TABLE_LIST": [ + { + "table_name": "pbh_table", + "interface_list": [ + "Ethernet0" + ], + "description": "NVGRE" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet0", + "lanes": "0,1,2,3", + "speed": 100000 + } + ] + } + } + }, + "PBH_RULE_INVALID_IP_PROTOCOL": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_HASH_FIELD": { + "PBH_HASH_FIELD_LIST": [ + { + "hash_field_name": "inner_ip_proto", + "hash_field": "INNER_IP_PROTOCOL", + "sequence_id": 1 + } + ] + }, + "sonic-pbh:PBH_HASH": { + "PBH_HASH_LIST": [ + { + "hash_name": "inner_v6_hash", + "hash_field_list": [ + "inner_ip_proto" + ] + } + ] + }, + "sonic-pbh:PBH_RULE": { + "PBH_RULE_LIST": [ + { + "table_name": "pbh_table", + "rule_name": "nvgre", + "priority": 1, + "ip_protocol": "11", + "hash": "inner_v6_hash" + } + ] + }, + "sonic-pbh:PBH_TABLE": { + "PBH_TABLE_LIST": [ + { + "table_name": "pbh_table", + "interface_list": [ + "Ethernet0" + ], + "description": "NVGRE" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet0", + "lanes": "0,1,2,3", + "speed": 100000 + } + ] + } + } + }, + "PBH_RULE_INVALID_IPV6_NEXT_HEADER": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_HASH_FIELD": { + "PBH_HASH_FIELD_LIST": [ + { + "hash_field_name": "inner_ip_proto", + "hash_field": "INNER_IP_PROTOCOL", + "sequence_id": 1 + } + ] + }, + "sonic-pbh:PBH_HASH": { + "PBH_HASH_LIST": [ + { + "hash_name": "inner_v6_hash", + "hash_field_list": [ + "inner_ip_proto" + ] + } + ] + }, + "sonic-pbh:PBH_RULE": { + "PBH_RULE_LIST": [ + { + "table_name": "pbh_table", + "rule_name": "nvgre", + "priority": 1, + "ipv6_next_header": "11", + "hash": "inner_v6_hash" + } + ] + }, + "sonic-pbh:PBH_TABLE": { + "PBH_TABLE_LIST": [ + { + "table_name": "pbh_table", + "interface_list": [ + "Ethernet0" + ], + "description": "NVGRE" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet0", + "lanes": "0,1,2,3", + "speed": 100000 + } + ] + } + } + }, + "PBH_RULE_INVALID_L4_DST_PORT": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_HASH_FIELD": { + "PBH_HASH_FIELD_LIST": [ + { + "hash_field_name": "inner_ip_proto", + "hash_field": "INNER_IP_PROTOCOL", + "sequence_id": 1 + } + ] + }, + "sonic-pbh:PBH_HASH": { + "PBH_HASH_LIST": [ + { + "hash_name": "inner_v6_hash", + "hash_field_list": [ + "inner_ip_proto" + ] + } + ] + }, + "sonic-pbh:PBH_RULE": { + "PBH_RULE_LIST": [ + { + "table_name": "pbh_table", + "rule_name": "nvgre", + "priority": 1, + "l4_dst_port": "12b5", + "hash": "inner_v6_hash" + } + ] + }, + "sonic-pbh:PBH_TABLE": { + "PBH_TABLE_LIST": [ + { + "table_name": "pbh_table", + "interface_list": [ + "Ethernet0" + ], + "description": "NVGRE" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet0", + "lanes": "0,1,2,3", + "speed": 100000 + } + ] + } + } + }, + "PBH_RULE_INVALID_INNER_ETHER_TYPE": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_HASH_FIELD": { + "PBH_HASH_FIELD_LIST": [ + { + "hash_field_name": "inner_ip_proto", + "hash_field": "INNER_IP_PROTOCOL", + "sequence_id": 1 + } + ] + }, + "sonic-pbh:PBH_HASH": { + "PBH_HASH_LIST": [ + { + "hash_name": "inner_v6_hash", + "hash_field_list": [ + "inner_ip_proto" + ] + } + ] + }, + "sonic-pbh:PBH_RULE": { + "PBH_RULE_LIST": [ + { + "table_name": "pbh_table", + "rule_name": "nvgre", + "priority": 1, + "inner_ether_type": "86dd", + "hash": "inner_v6_hash" + } + ] + }, + "sonic-pbh:PBH_TABLE": { + "PBH_TABLE_LIST": [ + { + "table_name": "pbh_table", + "interface_list": [ + "Ethernet0" + ], + "description": "NVGRE" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet0", + "lanes": "0,1,2,3", + "speed": 100000 + } + ] + } + } + }, + "PBH_RULE_INVALID_HASH": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_RULE": { + "PBH_RULE_LIST": [ + { + "table_name": "pbh_table", + "rule_name": "nvgre", + "priority": 1, + "hash": "invalid_value" + } + ] + }, + "sonic-pbh:PBH_TABLE": { + "PBH_TABLE_LIST": [ + { + "table_name": "pbh_table", + "interface_list": [ + "Ethernet0" + ], + "description": "NVGRE" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet0", + "lanes": "0,1,2,3", + "speed": 100000 + } + ] + } + } + }, + "PBH_RULE_INVALID_PACKET_ACTION": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_HASH_FIELD": { + "PBH_HASH_FIELD_LIST": [ + { + "hash_field_name": "inner_ip_proto", + "hash_field": "INNER_IP_PROTOCOL", + "sequence_id": 1 + } + ] + }, + "sonic-pbh:PBH_HASH": { + "PBH_HASH_LIST": [ + { + "hash_name": "inner_v6_hash", + "hash_field_list": [ + "inner_ip_proto" + ] + } + ] + }, + "sonic-pbh:PBH_RULE": { + "PBH_RULE_LIST": [ + { + "table_name": "pbh_table", + "rule_name": "nvgre", + "priority": 1, + "hash": "inner_v6_hash", + "packet_action": "INVALID_VALUE" + } + ] + }, + "sonic-pbh:PBH_TABLE": { + "PBH_TABLE_LIST": [ + { + "table_name": "pbh_table", + "interface_list": [ + "Ethernet0" + ], + "description": "NVGRE" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet0", + "lanes": "0,1,2,3", + "speed": 100000 + } + ] + } + } + }, + "PBH_RULE_INVALID_FLOW_COUNTER": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_HASH_FIELD": { + "PBH_HASH_FIELD_LIST": [ + { + "hash_field_name": "inner_ip_proto", + "hash_field": "INNER_IP_PROTOCOL", + "sequence_id": 1 + } + ] + }, + "sonic-pbh:PBH_HASH": { + "PBH_HASH_LIST": [ + { + "hash_name": "inner_v6_hash", + "hash_field_list": [ + "inner_ip_proto" + ] + } + ] + }, + "sonic-pbh:PBH_RULE": { + "PBH_RULE_LIST": [ + { + "table_name": "pbh_table", + "rule_name": "nvgre", + "priority": 1, + "hash": "inner_v6_hash", + "flow_counter": "INVALID_VALUE" + } + ] + }, + "sonic-pbh:PBH_TABLE": { + "PBH_TABLE_LIST": [ + { + "table_name": "pbh_table", + "interface_list": [ + "Ethernet0" + ], + "description": "NVGRE" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet0", + "lanes": "0,1,2,3", + "speed": 100000 + } + ] + } + } + }, + "PBH_RULE_DEFAULT_VALUE_PACKET_ACTION": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_HASH_FIELD": { + "PBH_HASH_FIELD_LIST": [ + { + "hash_field_name": "inner_ip_proto", + "hash_field": "INNER_IP_PROTOCOL", + "sequence_id": 1 + } + ] + }, + "sonic-pbh:PBH_HASH": { + "PBH_HASH_LIST": [ + { + "hash_name": "inner_v6_hash", + "hash_field_list": [ + "inner_ip_proto" + ] + } + ] + }, + "sonic-pbh:PBH_RULE": { + "PBH_RULE_LIST": [ + { + "table_name": "pbh_table", + "rule_name": "nvgre", + "priority": 1, + "hash": "inner_v6_hash" + } + ] + }, + "sonic-pbh:PBH_TABLE": { + "PBH_TABLE_LIST": [ + { + "table_name": "pbh_table", + "interface_list": [ + "Ethernet0" + ], + "description": "NVGRE" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet0", + "lanes": "0,1,2,3", + "speed": 100000 + } + ] + } + } + }, + "PBH_RULE_DEFAULT_VALUE_FLOW_COUNTER": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_HASH_FIELD": { + "PBH_HASH_FIELD_LIST": [ + { + "hash_field_name": "inner_ip_proto", + "hash_field": "INNER_IP_PROTOCOL", + "sequence_id": 1 + } + ] + }, + "sonic-pbh:PBH_HASH": { + "PBH_HASH_LIST": [ + { + "hash_name": "inner_v6_hash", + "hash_field_list": [ + "inner_ip_proto" + ] + } + ] + }, + "sonic-pbh:PBH_RULE": { + "PBH_RULE_LIST": [ + { + "table_name": "pbh_table", + "rule_name": "nvgre", + "priority": 1, + "hash": "inner_v6_hash" + } + ] + }, + "sonic-pbh:PBH_TABLE": { + "PBH_TABLE_LIST": [ + { + "table_name": "pbh_table", + "interface_list": [ + "Ethernet0" + ], + "description": "NVGRE" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet0", + "lanes": "0,1,2,3", + "speed": 100000 + } + ] + } + } + }, + "PBH_HASH_INVALID_HASH_FIELD": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_HASH": { + "PBH_HASH_LIST": [ + { + "hash_name": "inner_v6_hash", + "hash_field_list": [ + "invalid_value" + ] + } + ] + } + } + }, + "PBH_HASH_EMPTY_HASH_FIELD_LIST": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_HASH": { + "PBH_HASH_LIST": [ + { + "hash_name": "inner_v6_hash" + } + ] + } + } + }, + "PBH_HASH_FIELD_INVALID_HASH_FIELD": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_HASH_FIELD": { + "PBH_HASH_FIELD_LIST": [ + { + "hash_field_name": "inner_ip_proto", + "hash_field": "INVALID_VALUE", + "sequence_id": 1 + } + ] + } + } + }, + "PBH_HASH_FIELD_INVALID_IP_MASK": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_HASH_FIELD": { + "PBH_HASH_FIELD_LIST": [ + { + "hash_field_name": "inner_dst_ipv4", + "hash_field": "INNER_DST_IPV4", + "ip_mask": "INVALID_VALUE", + "sequence_id": 1 + } + ] + } + } + }, + "PBH_HASH_FIELD_IPV4_MASK_HASH_FIELD_MISMATCH": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_HASH_FIELD": { + "PBH_HASH_FIELD_LIST": [ + { + "hash_field_name": "inner_dst_ipv6", + "hash_field": "INNER_DST_IPV6", + "ip_mask": "255.0.0.0", + "sequence_id": 1 + } + ] + } + } + }, + "PBH_HASH_FIELD_IPV6_MASK_HASH_FIELD_MISMATCH": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_HASH_FIELD": { + "PBH_HASH_FIELD_LIST": [ + { + "hash_field_name": "inner_dst_ipv4", + "hash_field": "INNER_DST_IPV4", + "ip_mask": "ffff::", + "sequence_id": 1 + } + ] + } + } + }, + "PBH_HASH_FIELD_INVALID_SEQUENCE_ID": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_HASH_FIELD": { + "PBH_HASH_FIELD_LIST": [ + { + "hash_field_name": "inner_ip_proto", + "hash_field": "INNER_IP_PROTOCOL", + "sequence_id": 4294967296 + } + ] + } + } } } From ab84cfc18129a589d39b099846c9cd648bf2e993 Mon Sep 17 00:00:00 2001 From: Nazarii Hnydyn Date: Tue, 13 Jul 2021 17:52:07 +0000 Subject: [PATCH 10/11] [pbh]: YANG model rev06. Signed-off-by: Nazarii Hnydyn --- src/sonic-yang-models/yang-models/sonic-pbh.yang | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/sonic-yang-models/yang-models/sonic-pbh.yang b/src/sonic-yang-models/yang-models/sonic-pbh.yang index 5840b1ef432d..21a4b5fecc69 100644 --- a/src/sonic-yang-models/yang-models/sonic-pbh.yang +++ b/src/sonic-yang-models/yang-models/sonic-pbh.yang @@ -158,6 +158,13 @@ module sonic-pbh { } } + leaf ether_type { + description "Configures packet match for this rule: EtherType (IANA Ethertypes)"; + type string { + pattern "(0x){1}[a-fA-F0-9]{1,4}"; + } + } + leaf ip_protocol { description "Configures packet match for this rule: IP protocol (IANA Protocol Numbers)"; type string { From bc53bb68cc9a4ad5dc103e9e17a5511ae2c039f2 Mon Sep 17 00:00:00 2001 From: Nazarii Hnydyn Date: Tue, 13 Jul 2021 17:52:51 +0000 Subject: [PATCH 11/11] [pbh]: Add YANG UT rev03. Signed-off-by: Nazarii Hnydyn --- .../tests/files/sample_config_db.json | 3 + .../tests/yang_model_tests/tests/pbh.json | 4 ++ .../yang_model_tests/tests_config/pbh.json | 59 +++++++++++++++++++ 3 files changed, 66 insertions(+) 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 2e9140359e2a..dea0f754efb3 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -687,6 +687,8 @@ "PBH_RULE": { "pbh_table|nvgre": { "priority": "1", + "ether_type": "0x0800", + "ip_protocol": "0x2f", "gre_key": "0x2500/0xffffff00", "inner_ether_type": "0x86dd", "hash": "inner_v6_hash", @@ -695,6 +697,7 @@ }, "pbh_table|vxlan": { "priority": "2", + "ether_type": "0x0800", "ip_protocol": "0x11", "l4_dst_port": "0x12b5", "inner_ether_type": "0x0800", diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/pbh.json b/src/sonic-yang-models/tests/yang_model_tests/tests/pbh.json index f84d513e8bfe..cb3a0a99fae4 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/pbh.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/pbh.json @@ -26,6 +26,10 @@ "desc": "Configure invalid GRE_KEY in PBH_RULE.", "eStrKey": "Pattern" }, + "PBH_RULE_INVALID_ETHER_TYPE": { + "desc": "Configure invalid ETHER_TYPE in PBH_RULE.", + "eStrKey": "Pattern" + }, "PBH_RULE_INVALID_IP_PROTOCOL": { "desc": "Configure invalid IP_PROTOCOL in PBH_RULE.", "eStrKey": "Pattern" diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/pbh.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/pbh.json index 2d75244a228d..36be9aa0132d 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/pbh.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/pbh.json @@ -74,6 +74,8 @@ "table_name": "pbh_table", "rule_name": "nvgre", "priority": 1, + "ether_type": "0x0800", + "ip_protocol": "0x2f", "gre_key": "0x2500/0xffffff00", "inner_ether_type": "0x86dd", "hash": "inner_v6_hash", @@ -84,6 +86,7 @@ "table_name": "pbh_table", "rule_name": "vxlan", "priority": 2, + "ether_type": "0x0800", "ip_protocol": "0x11", "l4_dst_port": "0x12b5", "inner_ether_type": "0x0800", @@ -337,6 +340,62 @@ } } }, + "PBH_RULE_INVALID_ETHER_TYPE": { + "sonic-pbh:sonic-pbh": { + "sonic-pbh:PBH_HASH_FIELD": { + "PBH_HASH_FIELD_LIST": [ + { + "hash_field_name": "inner_ip_proto", + "hash_field": "INNER_IP_PROTOCOL", + "sequence_id": 1 + } + ] + }, + "sonic-pbh:PBH_HASH": { + "PBH_HASH_LIST": [ + { + "hash_name": "inner_v6_hash", + "hash_field_list": [ + "inner_ip_proto" + ] + } + ] + }, + "sonic-pbh:PBH_RULE": { + "PBH_RULE_LIST": [ + { + "table_name": "pbh_table", + "rule_name": "nvgre", + "priority": 1, + "ether_type": "0800", + "hash": "inner_v6_hash" + } + ] + }, + "sonic-pbh:PBH_TABLE": { + "PBH_TABLE_LIST": [ + { + "table_name": "pbh_table", + "interface_list": [ + "Ethernet0" + ], + "description": "NVGRE" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet0", + "lanes": "0,1,2,3", + "speed": 100000 + } + ] + } + } + }, "PBH_RULE_INVALID_IP_PROTOCOL": { "sonic-pbh:sonic-pbh": { "sonic-pbh:PBH_HASH_FIELD": {