Skip to content

Commit

Permalink
[portsortch]: Convert the oper_status to string and remove oper_statu…
Browse files Browse the repository at this point in the history
…s in portsyncd (#192)

- Front panel ports' oper_status should be notified from the SAI instead of getting
  it from kernel via portsyncd. Thus in this commit, oper_status is removed from the
  portsyncd.

- VLAN and LAG oper_status on the contrary need to be updated from the protocol daemon,
  the kernel and the teamd.

Signed-off-by: Shuotian Cheng <[email protected]>
  • Loading branch information
Shuotian Cheng authored Apr 19, 2017
1 parent cbbe9f4 commit 93dd3e9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
6 changes: 5 additions & 1 deletion orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ bool PortsOrch::isInitDone()

bool PortsOrch::getPort(string alias, Port &p)
{
SWSS_LOG_ENTER();

if (m_portList.find(alias) == m_portList.end())
return false;
p = m_portList[alias];
Expand All @@ -163,6 +165,8 @@ bool PortsOrch::getPort(string alias, Port &p)

bool PortsOrch::getPort(sai_object_id_t id, Port &port)
{
SWSS_LOG_ENTER();

for (const auto& portIter: m_portList)
{
switch (portIter.second.m_type)
Expand Down Expand Up @@ -255,7 +259,7 @@ void PortsOrch::updateDbPortOperStatus(sai_object_id_t id, sai_port_oper_status_
if (it->second.m_port_id == id)
{
vector<FieldValueTuple> vector;
FieldValueTuple tuple("oper_status", to_string(status));
FieldValueTuple tuple("oper_status", oper_status_strings.at(status));
vector.push_back(tuple);
m_portTable->set(it->first, vector);
}
Expand Down
9 changes: 9 additions & 0 deletions orchagent/portsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@

#include <map>

static const map<sai_port_oper_status_t, string> oper_status_strings =
{
{ SAI_PORT_OPER_STATUS_UNKNOWN, "unknown" },
{ SAI_PORT_OPER_STATUS_UP, "up" },
{ SAI_PORT_OPER_STATUS_DOWN, "down" },
{ SAI_PORT_OPER_STATUS_TESTING, "testing" },
{ SAI_PORT_OPER_STATUS_NOT_PRESENT, "not present" }
};

struct LagMemberUpdate
{
Port lag;
Expand Down
4 changes: 2 additions & 2 deletions portsyncd/linksync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,8 @@ void LinkSync::onMsg(int nlmsg_type, struct nl_object *obj)

vector<FieldValueTuple> fvVector;
FieldValueTuple a("admin_status", admin ? "up" : "down");
FieldValueTuple o("oper_status", oper ? "up" : "down");
FieldValueTuple m("mtu", to_string(mtu));
fvVector.push_back(a);
fvVector.push_back(o);
fvVector.push_back(m);

/* VLAN interfaces: Check if the type is bridge */
Expand All @@ -180,6 +178,8 @@ void LinkSync::onMsg(int nlmsg_type, struct nl_object *obj)
}
else
{
FieldValueTuple o("oper_status", oper ? "up" : "down");
fvVector.push_back(o);
m_vlanTableProducer.set(key, fvVector);
}
return;
Expand Down

0 comments on commit 93dd3e9

Please sign in to comment.