Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove FDB entires of BridgePort before removing the BridgePort #1451

Merged
merged 8 commits into from
Oct 2, 2020
47 changes: 47 additions & 0 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,15 @@ void PortsOrch::removeDefaultBridgePorts()
}
if (attr.value.s32 == SAI_BRIDGE_PORT_TYPE_PORT)
{
Port port;
getPortByBridgePortId(bridge_port_list[i], port);

//Flush the FDB entires corresponding to the port
if (!flushFdbEntries(port))
{
SWSS_LOG_ERROR("Failed to flush FDB entries for port %s", port.m_alias.c_str());
}

status = sai_bridge_api->remove_bridge_port(bridge_port_list[i]);
if (status != SAI_STATUS_SUCCESS)
{
Expand Down Expand Up @@ -3130,6 +3139,36 @@ void PortsOrch::doTask(Consumer &consumer)
}
}

bool PortsOrch::flushFdbEntries(Port port)
prsunny marked this conversation as resolved.
Show resolved Hide resolved
{
vector<sai_attribute_t> attrs;
sai_attribute_t attr;
sai_status_t rv = SAI_STATUS_SUCCESS;

SWSS_LOG_ENTER();

if (SAI_NULL_OBJECT_ID == port.m_bridge_port_id)
{
SWSS_LOG_WARN("Couldn't flush FDB entries for port: %s", port.m_alias.c_str());
return false;
prsunny marked this conversation as resolved.
Show resolved Hide resolved
}

attr.id = SAI_FDB_FLUSH_ATTR_BRIDGE_PORT_ID;
attr.value.oid = port.m_bridge_port_id;
attrs.push_back(attr);

SWSS_LOG_INFO("Flushing FDB entries for port: %s", port.m_alias.c_str());

rv = sai_fdb_api->flush_fdb_entries(gSwitchId, (uint32_t)attrs.size(), attrs.data());
if (SAI_STATUS_SUCCESS != rv)
{
SWSS_LOG_ERROR("Flushing FDB for port %s failed. rv:%d", port.m_alias.c_str(), rv);
return false;
}

return true;
}

void PortsOrch::initializeQueues(Port &port)
{
SWSS_LOG_ENTER();
Expand Down Expand Up @@ -3431,6 +3470,14 @@ bool PortsOrch::removeBridgePort(Port &port)
return false;
}

//Flush the FDB entires corresponding to the port
prsunny marked this conversation as resolved.
Show resolved Hide resolved
if (!flushFdbEntries(port))
{
SWSS_LOG_ERROR("Failed to flush FDB entries for port %s",
port.m_alias.c_str());
prsunny marked this conversation as resolved.
Show resolved Hide resolved
return false;
}

/* Remove bridge port */
status = sai_bridge_api->remove_bridge_port(port.m_bridge_port_id);
if (status != SAI_STATUS_SUCCESS)
Expand Down
1 change: 1 addition & 0 deletions orchagent/portsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class PortsOrch : public Orch, public Subject
bool addSubPort(Port &port, const string &alias, const bool &adminUp = true, const uint32_t &mtu = 0);
bool removeSubPort(const string &alias);
void getLagMember(Port &lag, vector<Port> &portv);
bool flushFdbEntries(Port);
private:
unique_ptr<Table> m_counterTable;
unique_ptr<Table> m_counterLagTable;
Expand Down