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 455eed24b01d..90e67a975aa0 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -957,6 +957,21 @@ }, "DEBUG_COUNTER": { "FLEX_COUNTER_STATUS": "enable" + }, + "FLOW_CNT_ROUTE": { + "FLEX_COUNTER_STATUS": "enable", + "POLL_INTERVAL": "10000" + } + }, + "FLOW_COUNTER_ROUTE_PATTERN": { + "1.1.1.0/24": { + "max_match_count": "30" + }, + "2000::/64": { + "max_match_count": "30" + }, + "Vnet1|2.2.2.0/24": { + "max_match_count": "30" } }, "CRM": { diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/flex_counter.json b/src/sonic-yang-models/tests/yang_model_tests/tests/flex_counter.json index 7a328ca693c1..92d96b54f3a1 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/flex_counter.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/flex_counter.json @@ -6,5 +6,16 @@ "desc": "Out of range poll interval.", "eStrKey": "Range", "eStr": "100..4294967295" + }, + "FLOW_COUNTER_ROUTE_PATTERN_TABLE_WITH_VRF": { + "desc": "FLOW_COUNTER_ROUTE_PATTERN_TABLE_WITH_VRF no failure." + }, + "FLOW_COUNTER_ROUTE_PATTERN_TABLE_WITH_DEFAULT_VRF": { + "desc": "FLOW_COUNTER_ROUTE_PATTERN_TABLE_WITH_DEFAULT_VRF no failure." + }, + "FLOW_COUNTER_ROUTE_PATTERN_TABLE_WITH_INVALID_MAX_MATCH_COUNT": { + "desc": "Out of range max_match_count.", + "eStrKey": "Range", + "eStr": "1..50" } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/flex_counter.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/flex_counter.json index 9043132791fd..169a38ff6d7c 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/flex_counter.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/flex_counter.json @@ -46,6 +46,10 @@ "FLOW_CNT_TRAP": { "FLEX_COUNTER_STATUS": "enable", "POLL_INTERVAL": 10000 + }, + "FLOW_CNT_ROUTE": { + "FLEX_COUNTER_STATUS": "enable", + "POLL_INTERVAL": 10000 } } } @@ -97,8 +101,77 @@ "FLOW_CNT_TRAP": { "FLEX_COUNTER_STATUS": "enable", "POLL_INTERVAL": 99 + }, + "FLOW_CNT_ROUTE": { + "FLEX_COUNTER_STATUS": "enable", + "POLL_INTERVAL": 99 } } } + }, + "FLOW_COUNTER_ROUTE_PATTERN_TABLE_WITH_VRF": { + "sonic-vrf:sonic-vrf":{ + "sonic-vrf:VRF": { + "VRF_LIST": [ + { + "name":"Vrf1" + } + ] + } + }, + "sonic-flex_counter:sonic-flex_counter": { + "sonic-flex_counter:FLOW_COUNTER_ROUTE_PATTERN": { + "FLOW_COUNTER_ROUTE_PATTERN_VRF_LIST": [ + { + "vrf_name": "Vrf1", + "ip_prefix": "1.1.1.0/24", + "max_match_count": 30 + }, + { + "vrf_name": "Vrf1", + "ip_prefix": "2000::/64", + "max_match_count": 30 + } + ] + } + } + }, + "FLOW_COUNTER_ROUTE_PATTERN_TABLE_WITH_DEFAULT_VRF": { + "sonic-flex_counter:sonic-flex_counter": { + "sonic-flex_counter:FLOW_COUNTER_ROUTE_PATTERN": { + "FLOW_COUNTER_ROUTE_PATTERN_LIST": [ + { + "ip_prefix": "1.1.1.0/24", + "max_match_count": 30 + }, + { + "ip_prefix": "2000::/64", + "max_match_count": 30 + } + ] + } + } + }, + "FLOW_COUNTER_ROUTE_PATTERN_TABLE_WITH_INVALID_MAX_MATCH_COUNT": { + "sonic-vrf:sonic-vrf":{ + "sonic-vrf:VRF": { + "VRF_LIST": [ + { + "name":"Vrf1" + } + ] + } + }, + "sonic-flex_counter:sonic-flex_counter": { + "sonic-flex_counter:FLOW_COUNTER_ROUTE_PATTERN": { + "FLOW_COUNTER_ROUTE_PATTERN_VRF_LIST": [ + { + "vrf_name": "Vrf1", + "ip_prefix": "1.1.1.0/24", + "max_match_count": 0 + } + ] + } + } } } diff --git a/src/sonic-yang-models/yang-models/sonic-flex_counter.yang b/src/sonic-yang-models/yang-models/sonic-flex_counter.yang index 8e958af2f427..9ced223e94bc 100644 --- a/src/sonic-yang-models/yang-models/sonic-flex_counter.yang +++ b/src/sonic-yang-models/yang-models/sonic-flex_counter.yang @@ -5,6 +5,10 @@ module sonic-flex_counter { namespace "http://github.com/Azure/sonic-flex_counter"; prefix flex_counter; + import ietf-inet-types { + prefix inet; + } + import sonic-types { prefix stypes; } @@ -211,8 +215,69 @@ module sonic-flex_counter { } } + container FLOW_CNT_ROUTE { + /* ROUTE_FLEX_COUNTER_GROUP */ + leaf FLEX_COUNTER_STATUS { + type flex_status; + } + leaf FLEX_COUNTER_DELAY_STATUS { + type flex_delay_status; + } + leaf POLL_INTERVAL { + type poll_interval; + } + } + } /* end of container FLEX_COUNTER_TABLE */ + + container FLOW_COUNTER_ROUTE_PATTERN { + description "Flow counter route pattern of config_db.json"; + + list FLOW_COUNTER_ROUTE_PATTERN_LIST { + + key "ip_prefix"; + + leaf ip_prefix { + type inet:ip-prefix; + } + + leaf max_match_count { + type uint32 { + range 1..50; + } + } + + } + + list FLOW_COUNTER_ROUTE_PATTERN_VRF_LIST { + + key "vrf_name ip_prefix"; + + leaf vrf_name { + /* + We don't use vrf_name reference here because: + 1. User is allowed to configure a VRF that does not exist yet here, orchagent is designed to resolve the VRF name once the VRF is created. + 2. The field vrf_name accept both VRF name and VNET name. + */ + type string { + length 0..16; + } + } + + leaf ip_prefix { + type inet:ip-prefix; + } + + leaf max_match_count { + type uint32 { + range 1..50; + } + } + + } + } + /* end of container FLOW_COUNTER_ROUTE_PATTERN */ } /* end of top level container */ }