Skip to content

Commit 59440f2

Browse files
authored
Allow buffer profile apply after init (sonic-net#1099)
* Allow buffer profile application after init (i.e., at run time) Signed-off-by: Wenda Ni <[email protected]> * Address comment: Alert when a buffer profile is applied after the physical port is brought up Signed-off-by: Wenda Ni <[email protected]> * Remove unnecessary space Signed-off-by: Wenda Ni <[email protected]> * Correct logic Signed-off-by: Wenda Ni <[email protected]> * Correct compile error Signed-off-by: Wenda Ni <[email protected]>
1 parent 20747fa commit 59440f2

File tree

4 files changed

+38
-3
lines changed

4 files changed

+38
-3
lines changed

orchagent/bufferorch.cpp

+26-2
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,19 @@ task_process_status BufferOrch::processQueue(Consumer &consumer)
579579
}
580580
else
581581
{
582-
SWSS_LOG_ERROR("Queue profile '%s' was inserted after BufferOrch init", key.c_str());
582+
// If a buffer queue profile is not in the initial CONFIG_DB BUFFER_QUEUE table
583+
// at BufferOrch object instantiation, it is considered being applied
584+
// at run time, and, in this case, is not tracked in the m_ready_list. It is up to
585+
// the application to guarantee the set order that the buffer queue profile
586+
// should be applied to a physical port before the physical port is brought up to
587+
// carry traffic. Here, we alert to application through syslog when such a wrong
588+
// set order is detected.
589+
for (const auto &port_name : port_names)
590+
{
591+
if (gPortsOrch->isPortAdminUp(port_name)) {
592+
SWSS_LOG_ERROR("Queue profile '%s' applied after port %s is up", key.c_str(), port_name.c_str());
593+
}
594+
}
583595
}
584596

585597
return task_process_status::task_success;
@@ -666,7 +678,19 @@ task_process_status BufferOrch::processPriorityGroup(Consumer &consumer)
666678
}
667679
else
668680
{
669-
SWSS_LOG_ERROR("PG profile '%s' was inserted after BufferOrch init", key.c_str());
681+
// If a buffer pg profile is not in the initial CONFIG_DB BUFFER_PG table
682+
// at BufferOrch object instantiation, it is considered being applied
683+
// at run time, and, in this case, is not tracked in the m_ready_list. It is up to
684+
// the application to guarantee the set order that the buffer pg profile
685+
// should be applied to a physical port before the physical port is brought up to
686+
// carry traffic. Here, we alert to application through syslog when such a wrong
687+
// set order is detected.
688+
for (const auto &port_name : port_names)
689+
{
690+
if (gPortsOrch->isPortAdminUp(port_name)) {
691+
SWSS_LOG_ERROR("PG profile '%s' applied after port %s is up", key.c_str(), port_name.c_str());
692+
}
693+
}
670694
}
671695

672696
return task_process_status::task_success;

orchagent/portsorch.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,17 @@ bool PortsOrch::isInitDone()
400400
return m_initDone;
401401
}
402402

403+
bool PortsOrch::isPortAdminUp(const string &alias)
404+
{
405+
auto it = m_portList.find(alias);
406+
if (it == m_portList.end())
407+
{
408+
SWSS_LOG_ERROR("Failed to get Port object by port alias: %s", alias.c_str());
409+
return false;
410+
}
411+
412+
return it->second.m_admin_state_up;
413+
}
403414

404415
map<string, Port>& PortsOrch::getAllPorts()
405416
{

orchagent/portsorch.h

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class PortsOrch : public Orch, public Subject
5757

5858
bool allPortsReady();
5959
bool isInitDone();
60+
bool isPortAdminUp(const string &alias);
6061

6162
map<string, Port>& getAllPorts();
6263
bool bake() override;

portsyncd/portsyncd.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ int main(int argc, char **argv)
166166
return EXIT_FAILURE;
167167
}
168168

169-
170169
return 1;
171170
}
172171

0 commit comments

Comments
 (0)