Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ extern sai_hostif_api_t* sai_hostif_api;
extern sai_acl_api_t* sai_acl_api;
extern sai_queue_api_t *sai_queue_api;
extern sai_object_id_t gSwitchId;
extern sai_fdb_api_t *sai_fdb_api;
extern IntfsOrch *gIntfsOrch;
extern NeighOrch *gNeighOrch;
extern CrmOrch *gCrmOrch;
Expand Down Expand Up @@ -149,6 +150,7 @@ PortsOrch::PortsOrch(DBConnector *db, vector<table_name_with_pri_t> &tableNames)

/* Initialize port table */
m_portTable = unique_ptr<Table>(new Table(db, APP_PORT_TABLE_NAME));
m_lagTable = unique_ptr<Table>(new Table(db, APP_LAG_TABLE_NAME));

/* Initialize queue tables */
m_queueTable = unique_ptr<Table>(new Table(m_counter_db.get(), COUNTERS_QUEUE_NAME_MAP));
Expand Down Expand Up @@ -2856,6 +2858,10 @@ bool PortsOrch::removeLag(Port lag)

SWSS_LOG_NOTICE("Remove LAG %s lid:%lx", lag.m_alias.c_str(), lag.m_lag_id);

/* Remove FDB Entries */
SWSS_LOG_NOTICE("%s was be removed, clear the FDB entries.", lag.m_alias.c_str());
removeFDBEntriesByBridgePortID(lag.m_bridge_port_id);

m_portList.erase(lag.m_alias);

PortUpdate update = { lag, false };
Expand Down Expand Up @@ -2968,6 +2974,25 @@ bool PortsOrch::removeLagMember(Port &lag, Port &port)
LagMemberUpdate update = { lag, port, false };
notify(SUBJECT_TYPE_LAG_MEMBER_CHANGE, static_cast<void *>(&update));

// If the number of enabled members is less than the value of this channel miniport,
// It will cause that the LAG channel oper_status DOWN,
// then we should clear the entire FDB entry.
vector<FieldValueTuple> lag_value;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to do this here? there is a doLagTask that gets the oper_status command and you could invoke the function removeFDBEntriesByBridgePortID in that flow.

if (m_lagTable->get(lag.m_alias.c_str(), lag_value))
{
for (auto it : lag_value)
{
if (fvField(it) == "oper_status")
{
if (fvValue(it) == "down")
{
SWSS_LOG_NOTICE("%s oper_status is DOWN, remove the FDB entries.", lag.m_alias.c_str());
removeFDBEntriesByBridgePortID(lag.m_bridge_port_id);
break;
}
}
}
}
return true;
}

Expand Down Expand Up @@ -3163,6 +3188,16 @@ void PortsOrch::doTask(NotificationConsumer &consumer)

updatePortOperStatus(port, status);

if ( status == SAI_PORT_OPER_STATUS_DOWN )
{
Port port;
if (getPort(id, port))
{
SWSS_LOG_NOTICE("%s status is DOWN, remove the FDB entries.", port.m_alias.c_str());
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add the bridge port id as well to log message?

removeFDBEntriesByBridgePortID( port.m_bridge_port_id );
}
}

/* update m_portList */
m_portList[port.m_alias] = port;
}
Expand Down Expand Up @@ -3297,3 +3332,21 @@ bool PortsOrch::removeAclTableGroup(const Port &p)
return true;
}

void PortsOrch::removeFDBEntriesByBridgePortID(sai_object_id_t bridge_port_id)
{
sai_attribute_t flush_attr;
vector<sai_attribute_t> flush_attrs;
sai_status_t rv;

SWSS_LOG_NOTICE("SAI_FDB_FLUSH_ATTR_BRIDGE_PORT_ID By 0x%lx", bridge_port_id);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be INFO level

flush_attr.id = SAI_FDB_FLUSH_ATTR_BRIDGE_PORT_ID;
flush_attr.value.oid = bridge_port_id;
flush_attrs.push_back(flush_attr);
rv = sai_fdb_api->flush_fdb_entries(gSwitchId, (uint32_t)flush_attrs.size(), flush_attrs.data());
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when the CRM counter be updated?


if (rv != SAI_STATUS_SUCCESS)
{
SWSS_LOG_WARN("Flush fdb by BRIDGE PORT failed, return code %d", rv);
}
}

3 changes: 3 additions & 0 deletions orchagent/portsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class PortsOrch : public Orch, public Subject
private:
unique_ptr<Table> m_counterTable;
unique_ptr<Table> m_portTable;
unique_ptr<Table> m_lagTable;
unique_ptr<Table> m_queueTable;
unique_ptr<Table> m_queuePortTable;
unique_ptr<Table> m_queueIndexTable;
Expand Down Expand Up @@ -189,6 +190,8 @@ class PortsOrch : public Orch, public Subject

bool getPortOperStatus(const Port& port, sai_port_oper_status_t& status) const;
void updatePortOperStatus(Port &port, sai_port_oper_status_t status);

void removeFDBEntriesByBridgePortID(sai_object_id_t bridge_port_id);
};
#endif /* SWSS_PORTSORCH_H */