From dad68b54f10c39d3a135de5b5c80dc83d1b578bf Mon Sep 17 00:00:00 2001 From: Vivek Reddy Date: Mon, 29 Mar 2021 07:26:54 -0400 Subject: [PATCH] [SFlowMgr] Sflow Crash on 200G ports handled (#1683) - What I did Added 200G entry into the speed-rate map. Also handled the case which programs empty string into APP-DB and thus leading to a failure of Orchagent. Default Sampling rate for 200G is set to 20000 - Why I did it Fix for Issue: Azure/sonic-buildimage#6793 - How I verified it run sflow community test under sonic-mgmt Co-authored-by: Vivek Reddy Karri --- cfgmgr/sflowmgr.cpp | 3 ++- cfgmgr/sflowmgr.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cfgmgr/sflowmgr.cpp b/cfgmgr/sflowmgr.cpp index aefcffe8e8..b7aeb8bbc1 100644 --- a/cfgmgr/sflowmgr.cpp +++ b/cfgmgr/sflowmgr.cpp @@ -13,6 +13,7 @@ using namespace swss; map sflowSpeedRateInitMap = { {SFLOW_SAMPLE_RATE_KEY_400G, SFLOW_SAMPLE_RATE_VALUE_400G}, + {SFLOW_SAMPLE_RATE_KEY_200G, SFLOW_SAMPLE_RATE_VALUE_200G}, {SFLOW_SAMPLE_RATE_KEY_100G, SFLOW_SAMPLE_RATE_VALUE_100G}, {SFLOW_SAMPLE_RATE_KEY_50G, SFLOW_SAMPLE_RATE_VALUE_50G}, {SFLOW_SAMPLE_RATE_KEY_40G, SFLOW_SAMPLE_RATE_VALUE_40G}, @@ -229,7 +230,7 @@ void SflowMgr::sflowCheckAndFillValues(string alias, vector &va { string speed = m_sflowPortConfMap[alias].speed; - if (speed != SFLOW_ERROR_SPEED_STR) + if (speed != SFLOW_ERROR_SPEED_STR && sflowSpeedRateInitMap.find(speed) != sflowSpeedRateInitMap.end()) { rate = sflowSpeedRateInitMap[speed]; } diff --git a/cfgmgr/sflowmgr.h b/cfgmgr/sflowmgr.h index 9f1d87cb8a..8e454efa7a 100644 --- a/cfgmgr/sflowmgr.h +++ b/cfgmgr/sflowmgr.h @@ -11,6 +11,7 @@ namespace swss { #define SFLOW_SAMPLE_RATE_KEY_400G "400000" +#define SFLOW_SAMPLE_RATE_KEY_200G "200000" #define SFLOW_SAMPLE_RATE_KEY_100G "100000" #define SFLOW_SAMPLE_RATE_KEY_50G "50000" #define SFLOW_SAMPLE_RATE_KEY_40G "40000" @@ -19,6 +20,7 @@ namespace swss { #define SFLOW_SAMPLE_RATE_KEY_1G "1000" #define SFLOW_SAMPLE_RATE_VALUE_400G "40000" +#define SFLOW_SAMPLE_RATE_VALUE_200G "20000" #define SFLOW_SAMPLE_RATE_VALUE_100G "10000" #define SFLOW_SAMPLE_RATE_VALUE_50G "5000" #define SFLOW_SAMPLE_RATE_VALUE_40G "4000"