From f54b7d0b634b466c06867858d843744216f09efa Mon Sep 17 00:00:00 2001 From: Stephen Sun <5379172+stephenxs@users.noreply.github.com> Date: Thu, 29 Jul 2021 16:32:06 +0800 Subject: [PATCH] [Dynamic Buffer Calc][202012]Bug fix: Don't create lossless buffer profile for active ports without speed configured (#1820) **What I did** Bugfix: Don't create lossless buffer profiles for active ports without speed configured This is to backport PR #1822 to 202012. Root cause: - In `handlePortTableUpdate`, `refreshPgsFromPort` is called if admin status is updated even if the speed is not configured. This is reasonable because the port can be configured as headroom override and the profile should be applied in that case. - However, as a side-effect, the port's state is set to `PORT_READY` in `refreshPgsForPort` regardless of whether the speed is configured, which is not correct. This is should be avoided and `PORT_READY` should be set by the caller if necessary Fix: - Don't set the port's state to `PORT_READY` in `refreshPgsForPort` and check the port's state before calling it. Note: - The change is covered by the existing vs tests. - The scenario where the bug was originally found can not be covered by vs test because: - The speed is always configured in vs image by default - Removing speed is not handled in buffer manager since it's not a valid flow. - A regression test will be opened to cover this case. --- cfgmgr/buffermgrdyn.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cfgmgr/buffermgrdyn.cpp b/cfgmgr/buffermgrdyn.cpp index 2f7c2c846a..7407e5ede5 100644 --- a/cfgmgr/buffermgrdyn.cpp +++ b/cfgmgr/buffermgrdyn.cpp @@ -920,8 +920,6 @@ task_process_status BufferMgrDynamic::refreshPgsForPort(const string &port, cons SWSS_LOG_DEBUG("Nothing to do for port %s since no PG configured on it", port.c_str()); } - portInfo.state = PORT_READY; - // Remove the old profile which is probably not referenced anymore. if (!profilesToBeReleased.empty()) { @@ -1150,6 +1148,9 @@ task_process_status BufferMgrDynamic::doUpdateBufferProfileForDynamicTh(buffer_p SWSS_LOG_DEBUG("Checking PG %s for dynamic profile %s", key.c_str(), profileName.c_str()); portsChecked.insert(portName); + if (port.state != PORT_READY) + continue; + rc = refreshPgsForPort(portName, port.speed, port.cable_length, port.mtu); if (task_process_status::task_success != rc) {