From 6189eaadbd21ac20b3762c9860dd735645c3752b Mon Sep 17 00:00:00 2001 From: Prince Sunny Date: Wed, 13 Jun 2018 10:23:45 -0700 Subject: [PATCH] Allocate buffer for 256 entries for ACL resource query (#523) * Allocate buffer for 256 entries for ACL resource query * Changed to MACRO --- orchagent/crmorch.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/orchagent/crmorch.cpp b/orchagent/crmorch.cpp index ab6c0b72d774..0ec87ec9f8fc 100644 --- a/orchagent/crmorch.cpp +++ b/orchagent/crmorch.cpp @@ -12,6 +12,7 @@ #define CRM_THRESHOLD_LOW_DEFAULT 70 #define CRM_THRESHOLD_HIGH_DEFAULT 85 #define CRM_EXCEEDED_MSG_MAX 10 +#define CRM_ACL_RESOURCE_COUNT 256 extern sai_object_id_t gSwitchId; extern sai_switch_api_t *sai_switch_api; @@ -436,20 +437,18 @@ void CrmOrch::getResAvailableCounters() case SAI_SWITCH_ATTR_AVAILABLE_ACL_TABLE: case SAI_SWITCH_ATTR_AVAILABLE_ACL_TABLE_GROUP: { - attr.value.aclresource.count = 0; - attr.value.aclresource.list = NULL; + vector resources(CRM_ACL_RESOURCE_COUNT); + attr.value.aclresource.count = CRM_ACL_RESOURCE_COUNT; + attr.value.aclresource.list = resources.data(); sai_status_t status = sai_switch_api->get_switch_attribute(gSwitchId, 1, &attr); - if ((status != SAI_STATUS_SUCCESS) && (status != SAI_STATUS_BUFFER_OVERFLOW)) + if (status == SAI_STATUS_BUFFER_OVERFLOW) { - SWSS_LOG_ERROR("Failed to get switch attribute %u , rv:%d", attr.id, status); - break; + resources.resize(attr.value.aclresource.count); + attr.value.aclresource.list = resources.data(); + status = sai_switch_api->get_switch_attribute(gSwitchId, 1, &attr); } - vector resources(attr.value.aclresource.count); - attr.value.aclresource.list = resources.data(); - - status = sai_switch_api->get_switch_attribute(gSwitchId, 1, &attr); if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to get switch attribute %u , rv:%d", attr.id, status);