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..dea0f754efb3 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,93 @@ ] } }, + "PBH_HASH_FIELD": { + "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", + "ip_mask": "255.0.0.0", + "sequence_id": "3" + }, + "inner_src_ipv4": { + "hash_field": "INNER_SRC_IPV4", + "ip_mask": "0.0.0.255", + "sequence_id": "3" + }, + "inner_dst_ipv6": { + "hash_field": "INNER_DST_IPV6", + "ip_mask": "ffff::", + "sequence_id": "4" + }, + "inner_src_ipv6": { + "hash_field": "INNER_SRC_IPV6", + "ip_mask": "::ffff", + "sequence_id": "4" + } + }, + "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" + ] + } + }, + "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", + "packet_action": "SET_ECMP_HASH", + "flow_counter": "DISABLED" + }, + "pbh_table|vxlan": { + "priority": "2", + "ether_type": "0x0800", + "ip_protocol": "0x11", + "l4_dst_port": "0x12b5", + "inner_ether_type": "0x0800", + "hash": "inner_v4_hash", + "packet_action": "SET_LAG_HASH", + "flow_counter": "ENABLED" + } + }, + "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/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 new file mode 100644 index 000000000000..cb3a0a99fae4 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/pbh.json @@ -0,0 +1,107 @@ +{ + "PBH_TABLE_RULE_HASH_HASH_FIELD_VALID": { + "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_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" + }, + "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 new file mode 100644 index 000000000000..36be9aa0132d --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/pbh.json @@ -0,0 +1,974 @@ +{ + "PBH_TABLE_RULE_HASH_HASH_FIELD_VALID": { + "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 + }, + { + "hash_field_name": "inner_l4_dst_port", + "hash_field": "INNER_L4_DST_PORT", + "sequence_id": 2 + }, + { + "hash_field_name": "inner_l4_src_port", + "hash_field": "INNER_L4_SRC_PORT", + "sequence_id": 2 + }, + { + "hash_field_name": "inner_dst_ipv4", + "hash_field": "INNER_DST_IPV4", + "ip_mask": "255.0.0.0", + "sequence_id": 3 + }, + { + "hash_field_name": "inner_src_ipv4", + "hash_field": "INNER_SRC_IPV4", + "ip_mask": "0.0.0.255", + "sequence_id": 3 + }, + { + "hash_field_name": "inner_dst_ipv6", + "hash_field": "INNER_DST_IPV6", + "ip_mask": "ffff::", + "sequence_id": 4 + }, + { + "hash_field_name": "inner_src_ipv6", + "hash_field": "INNER_SRC_IPV6", + "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": [ + { + "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", + "packet_action": "SET_ECMP_HASH", + "flow_counter": "DISABLED" + }, + { + "table_name": "pbh_table", + "rule_name": "vxlan", + "priority": 2, + "ether_type": "0x0800", + "ip_protocol": "0x11", + "l4_dst_port": "0x12b5", + "inner_ether_type": "0x0800", + "hash": "inner_v4_hash", + "packet_action": "SET_LAG_HASH", + "flow_counter": "ENABLED" + } + ] + }, + "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_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_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": { + "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 + } + ] + } + } + } +} 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..21a4b5fecc69 --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-pbh.yang @@ -0,0 +1,264 @@ +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: hashing for NVGRE & VxLAN with IPv4/IPv6 inner 5-tuple"; + + revision 2021-04-23 { + 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_FIELD { + + description "PBH_HASH_FIELD part of config_db.json"; + + list PBH_HASH_FIELD_LIST { + + key "hash_field_name"; + + leaf hash_field_name { + description "The name of this hash field"; + type string { + length 1..255; + } + } + + leaf hash_field { + description "Configures native hash field for this hash field"; + mandatory true; + type pbh:hash-field; + } + + leaf ip_mask { + description "Configures IPv4/IPv6 address mask for this hash field"; + mandatory true; + 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'])"; + } + + 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_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 { + length 1..255; + } + } + + 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 */ + } + /* 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 { + length 1..255; + } + } + + leaf priority { + description "Configures priority for this rule"; + mandatory true; + type uint32; + } + + leaf gre_key { + description "Configures packet match for this rule: GRE key (value/mask)"; + type string { + pattern "(0x){1}[a-fA-F0-9]{1,8}/(0x){1}[a-fA-F0-9]{1,8}"; + } + } + + 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 { + pattern "(0x){1}[a-fA-F0-9]{1,2}"; + } + } + + leaf ipv6_next_header { + description "Configures packet match for this rule: IPv6 Next header (IANA Protocol Numbers)"; + type string { + pattern "(0x){1}[a-fA-F0-9]{1,2}"; + } + } + + leaf l4_dst_port { + description "Configures packet match for this rule: L4 destination port"; + type string { + pattern "(0x){1}[a-fA-F0-9]{1,4}"; + } + } + + leaf inner_ether_type { + description "Configures packet match for this rule: inner EtherType (IANA Ethertypes)"; + type string { + pattern "(0x){1}[a-fA-F0-9]{1,4}"; + } + } + + 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"; + } + } + + leaf packet_action { + description "Configures packet action for this rule"; + type pbh:packet-action; + default "SET_ECMP_HASH"; + } + + leaf flow_counter { + description "Enables/Disables packet/byte counter for this rule"; + type pbh:flow-counter; + default "DISABLED"; + } + + } + /* end of PBH_RULE_LIST */ + } + /* end of container PBH_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 { + length 1..255; + } + } + + 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"; + } + type leafref { + path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name"; + } + } + } + + leaf description { + description "The description of this table"; + mandatory true; + type string { + length 1..255; + } + } + + } + /* end of PBH_TABLE_LIST */ + } + /* end of container PBH_TABLE */ + } + /* end of container sonic-pbh */ +} +/* end of module sonic-pbh */