Skip to content

Commit 49c9c16

Browse files
wendaniyxieca
authored andcommitted
Allow buffer profile apply after init (#1099)
* Allow buffer profile application after init (i.e., at run time) Signed-off-by: Wenda Ni <wenni@microsoft.com> * Address comment: Alert when a buffer profile is applied after the physical port is brought up Signed-off-by: Wenda Ni <wenni@microsoft.com> * Remove unnecessary space Signed-off-by: Wenda Ni <wenni@microsoft.com> * Correct logic Signed-off-by: Wenda Ni <wenni@microsoft.com> * Correct compile error Signed-off-by: Wenda Ni <wenni@microsoft.com>
1 parent 6453170 commit 49c9c16

4 files changed

Lines changed: 38 additions & 3 deletions

File tree

orchagent/bufferorch.cpp

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,19 @@ task_process_status BufferOrch::processQueue(Consumer &consumer)
444444
}
445445
else
446446
{
447-
SWSS_LOG_ERROR("Queue profile '%s' was inserted after BufferOrch init", key.c_str());
447+
// If a buffer queue profile is not in the initial CONFIG_DB BUFFER_QUEUE table
448+
// at BufferOrch object instantiation, it is considered being applied
449+
// at run time, and, in this case, is not tracked in the m_ready_list. It is up to
450+
// the application to guarantee the set order that the buffer queue profile
451+
// should be applied to a physical port before the physical port is brought up to
452+
// carry traffic. Here, we alert to application through syslog when such a wrong
453+
// set order is detected.
454+
for (const auto &port_name : port_names)
455+
{
456+
if (gPortsOrch->isPortAdminUp(port_name)) {
457+
SWSS_LOG_ERROR("Queue profile '%s' applied after port %s is up", key.c_str(), port_name.c_str());
458+
}
459+
}
448460
}
449461

450462
return task_process_status::task_success;
@@ -531,7 +543,19 @@ task_process_status BufferOrch::processPriorityGroup(Consumer &consumer)
531543
}
532544
else
533545
{
534-
SWSS_LOG_ERROR("PG profile '%s' was inserted after BufferOrch init", key.c_str());
546+
// If a buffer pg profile is not in the initial CONFIG_DB BUFFER_PG table
547+
// at BufferOrch object instantiation, it is considered being applied
548+
// at run time, and, in this case, is not tracked in the m_ready_list. It is up to
549+
// the application to guarantee the set order that the buffer pg profile
550+
// should be applied to a physical port before the physical port is brought up to
551+
// carry traffic. Here, we alert to application through syslog when such a wrong
552+
// set order is detected.
553+
for (const auto &port_name : port_names)
554+
{
555+
if (gPortsOrch->isPortAdminUp(port_name)) {
556+
SWSS_LOG_ERROR("PG profile '%s' applied after port %s is up", key.c_str(), port_name.c_str());
557+
}
558+
}
535559
}
536560

537561
return task_process_status::task_success;

orchagent/portsorch.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,17 @@ bool PortsOrch::isInitDone()
398398
return m_initDone;
399399
}
400400

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

402413
map<string, Port>& PortsOrch::getAllPorts()
403414
{

orchagent/portsorch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class PortsOrch : public Orch, public Subject
5757

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

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

portsyncd/portsyncd.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ int main(int argc, char **argv)
169169
return EXIT_FAILURE;
170170
}
171171

172-
173172
return 1;
174173
}
175174

0 commit comments

Comments
 (0)