Skip to content

Commit

Permalink
[YANG] Add route flow counter support (#9814)
Browse files Browse the repository at this point in the history
* [YANG] Add route flow counter support
  • Loading branch information
Junchao-Mellanox authored Mar 24, 2022
1 parent e2502ed commit 9282618
Show file tree
Hide file tree
Showing 4 changed files with 164 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/sonic-yang-models/tests/files/sample_config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,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": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
"FLOW_CNT_TRAP": {
"FLEX_COUNTER_STATUS": "enable",
"POLL_INTERVAL": 10000
},
"FLOW_CNT_ROUTE": {
"FLEX_COUNTER_STATUS": "enable",
"POLL_INTERVAL": 10000
}
}
}
Expand Down Expand Up @@ -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
}
]
}
}
}
}
65 changes: 65 additions & 0 deletions src/sonic-yang-models/yang-models/sonic-flex_counter.yang
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 */
}
Expand Down

0 comments on commit 9282618

Please sign in to comment.