From 9f836a6a093a03997624f5d637be7e18938c9699 Mon Sep 17 00:00:00 2001 From: Wenda Ni Date: Fri, 18 Oct 2019 03:44:16 +0000 Subject: [PATCH 1/5] Allow buffer profile application after init (i.e., at run time) Signed-off-by: Wenda Ni --- orchagent/bufferorch.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/orchagent/bufferorch.cpp b/orchagent/bufferorch.cpp index c560551bca..48953cbebf 100644 --- a/orchagent/bufferorch.cpp +++ b/orchagent/bufferorch.cpp @@ -579,7 +579,7 @@ task_process_status BufferOrch::processQueue(Consumer &consumer) } else { - SWSS_LOG_ERROR("Queue profile '%s' was inserted after BufferOrch init", key.c_str()); + SWSS_LOG_NOTICE("Queue profile '%s' was inserted after BufferOrch init", key.c_str()); } return task_process_status::task_success; @@ -666,7 +666,7 @@ task_process_status BufferOrch::processPriorityGroup(Consumer &consumer) } else { - SWSS_LOG_ERROR("PG profile '%s' was inserted after BufferOrch init", key.c_str()); + SWSS_LOG_NOTICE("PG profile '%s' was inserted after BufferOrch init", key.c_str()); } return task_process_status::task_success; From a627330c17d703e15859a65161a645e713b7c947 Mon Sep 17 00:00:00 2001 From: Wenda Ni Date: Tue, 29 Oct 2019 00:44:01 +0000 Subject: [PATCH 2/5] Address comment: Alert when a buffer profile is applied after the physical port is brought up Signed-off-by: Wenda Ni --- orchagent/bufferorch.cpp | 28 ++++++++++++++++++++++++++-- orchagent/portsorch.cpp | 11 +++++++++++ orchagent/portsorch.h | 1 + 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/orchagent/bufferorch.cpp b/orchagent/bufferorch.cpp index 48953cbebf..11210d93c8 100644 --- a/orchagent/bufferorch.cpp +++ b/orchagent/bufferorch.cpp @@ -579,7 +579,19 @@ task_process_status BufferOrch::processQueue(Consumer &consumer) } else { - SWSS_LOG_NOTICE("Queue profile '%s' was inserted after BufferOrch init", key.c_str()); + // If a buffer queue profile is not in the initial CONFIG_DB BUFFER_QUEUE table + // at BufferOrch object instantiation, it is considered being applied + // at run time, and, in this case, is not tracked in the m_ready_list. It is up to + // the application to guarantee the set order that the buffer queue profile + // should be applied to a physical port before the physical port is brought up to + // carry traffic. Here, we alert to application through syslog when such a wrong + // set order is detected. + for (const auto &port_name : port_names) + { + if (!gPortsOrch->isPortAdminUp(port_name)) { + SWSS_LOG_ERROR("Queue profile '%s' applied after port %s is up", key.c_str(), port_name.c_str()); + } + } } return task_process_status::task_success; @@ -666,7 +678,19 @@ task_process_status BufferOrch::processPriorityGroup(Consumer &consumer) } else { - SWSS_LOG_NOTICE("PG profile '%s' was inserted after BufferOrch init", key.c_str()); + // If a buffer pg profile is not in the initial CONFIG_DB BUFFER_PG table + // at BufferOrch object instantiation, it is considered being applied + // at run time, and, in this case, is not tracked in the m_ready_list. It is up to + // the application to guarantee the set order that the buffer pg profile + // should be applied to a physical port before the physical port is brought up to + // carry traffic. Here, we alert to application through syslog when such a wrong + // set order is detected. + for (const auto &port_name : port_names) + { + if (!gPortsOrch->isPortAdminUp(port_name)) { + SWSS_LOG_ERROR("PG profile '%s' applied after port %s is up", key.c_str(), port_name.c_str()); + } + } } return task_process_status::task_success; diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 6901593754..b6aef20439 100644 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -400,6 +400,17 @@ bool PortsOrch::isInitDone() return m_initDone; } +bool PortsOrch::isPortAdminUp(const string &alias) +{ + auto it = m_portList.find(alias); + if (it == m_portList.end()) + { + SWSS_LOG_ERROR("Failed to get Port object by port alias: %s", alias.c_str()); + return false; + } + + return p->second.m_admin_state_up; +} map& PortsOrch::getAllPorts() { diff --git a/orchagent/portsorch.h b/orchagent/portsorch.h index d2819e62ea..6b12dd24fb 100644 --- a/orchagent/portsorch.h +++ b/orchagent/portsorch.h @@ -57,6 +57,7 @@ class PortsOrch : public Orch, public Subject bool allPortsReady(); bool isInitDone(); + bool isPortAdminUp(const string &alias); map& getAllPorts(); bool bake() override; From a34766ef72d97f3590763c77031446f69e7f3751 Mon Sep 17 00:00:00 2001 From: Wenda Ni Date: Tue, 29 Oct 2019 00:45:44 +0000 Subject: [PATCH 3/5] Remove unnecessary space Signed-off-by: Wenda Ni --- portsyncd/portsyncd.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/portsyncd/portsyncd.cpp b/portsyncd/portsyncd.cpp index 2b72d29ac7..dd5cf68b7b 100644 --- a/portsyncd/portsyncd.cpp +++ b/portsyncd/portsyncd.cpp @@ -172,7 +172,6 @@ int main(int argc, char **argv) return EXIT_FAILURE; } - return 1; } From b97b86a767979bb545ba8213e058daa15fc843ef Mon Sep 17 00:00:00 2001 From: Wenda Ni Date: Tue, 29 Oct 2019 00:47:52 +0000 Subject: [PATCH 4/5] Correct logic Signed-off-by: Wenda Ni --- orchagent/bufferorch.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/orchagent/bufferorch.cpp b/orchagent/bufferorch.cpp index 11210d93c8..2257e927bd 100644 --- a/orchagent/bufferorch.cpp +++ b/orchagent/bufferorch.cpp @@ -588,7 +588,7 @@ task_process_status BufferOrch::processQueue(Consumer &consumer) // set order is detected. for (const auto &port_name : port_names) { - if (!gPortsOrch->isPortAdminUp(port_name)) { + if (gPortsOrch->isPortAdminUp(port_name)) { SWSS_LOG_ERROR("Queue profile '%s' applied after port %s is up", key.c_str(), port_name.c_str()); } } @@ -687,7 +687,7 @@ task_process_status BufferOrch::processPriorityGroup(Consumer &consumer) // set order is detected. for (const auto &port_name : port_names) { - if (!gPortsOrch->isPortAdminUp(port_name)) { + if (gPortsOrch->isPortAdminUp(port_name)) { SWSS_LOG_ERROR("PG profile '%s' applied after port %s is up", key.c_str(), port_name.c_str()); } } From 5197c8fffc6701294b022818db2d3c459fb08177 Mon Sep 17 00:00:00 2001 From: Wenda Ni Date: Tue, 29 Oct 2019 00:58:34 +0000 Subject: [PATCH 5/5] Correct compile error Signed-off-by: Wenda Ni --- orchagent/portsorch.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index b6aef20439..ae876467fb 100644 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -409,7 +409,7 @@ bool PortsOrch::isPortAdminUp(const string &alias) return false; } - return p->second.m_admin_state_up; + return it->second.m_admin_state_up; } map& PortsOrch::getAllPorts()