From 8a54b877f8e2a6423f3cb290ffb47b7adc56c5cc Mon Sep 17 00:00:00 2001 From: Zhenggen Xu Date: Fri, 27 Sep 2019 23:27:57 -0700 Subject: [PATCH 1/2] Fix the stack-overflow issue in AclOrch::getTableById() In case the table_id and m_mirrorTableId/m_mirrorTableId are empty The function would be called recursively without ending. Signed-off-by: Zhenggen Xu --- orchagent/aclorch.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/orchagent/aclorch.cpp b/orchagent/aclorch.cpp index 21496c05fd..0ebc9d41d9 100644 --- a/orchagent/aclorch.cpp +++ b/orchagent/aclorch.cpp @@ -2913,6 +2913,11 @@ sai_object_id_t AclOrch::getTableById(string table_id) { SWSS_LOG_ENTER(); + if (table_id.empty()) + { + return SAI_NULL_OBJECT_ID; + } + for (auto it : m_AclTables) { if (it.second.id == table_id) From 3bd1ceee4d1e963c967b440b9570c43bcffa5b52 Mon Sep 17 00:00:00 2001 From: Zhenggen Xu Date: Sat, 28 Sep 2019 21:30:18 -0700 Subject: [PATCH 2/2] Skip the acl rules with empty tables and added log messages Signed-off-by: Zhenggen Xu --- orchagent/aclorch.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/orchagent/aclorch.cpp b/orchagent/aclorch.cpp index 0ebc9d41d9..4887937d53 100644 --- a/orchagent/aclorch.cpp +++ b/orchagent/aclorch.cpp @@ -2724,6 +2724,13 @@ void AclOrch::doAclRuleTask(Consumer &consumer) string op = kfvOp(t); SWSS_LOG_INFO("OP: %s, TABLE_ID: %s, RULE_ID: %s", op.c_str(), table_id.c_str(), rule_id.c_str()); + + if (table_id.empty()) + { + SWSS_LOG_WARN("ACL rule with RULE_ID: %s is not valid as TABLE_ID is empty", rule_id.c_str()); + it = consumer.m_toSync.erase(it); + continue; + } if (op == SET_COMMAND) { @@ -2915,6 +2922,7 @@ sai_object_id_t AclOrch::getTableById(string table_id) if (table_id.empty()) { + SWSS_LOG_WARN("table_id is empty"); return SAI_NULL_OBJECT_ID; }