Skip to content

Commit

Permalink
support flush FDB entries per port and per vlan (sonic-net#1064)
Browse files Browse the repository at this point in the history
Fdb entries can be deleted with user specifying vlan or port or vlan&&port. 

Signed-off-by: yangshiping@jd.com
  • Loading branch information
yangshp1987 authored May 19, 2021
1 parent 3629d70 commit 031f536
Showing 1 changed file with 70 additions and 4 deletions.
74 changes: 70 additions & 4 deletions orchagent/fdborch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,10 @@ void FdbOrch::doTask(NotificationConsumer& consumer)
std::string op;
std::string data;
std::vector<swss::FieldValueTuple> values;
string alias;
string vlan;
Port port;
Port vlanPort;

consumer.pop(op, data, values);

Expand All @@ -706,14 +710,76 @@ void FdbOrch::doTask(NotificationConsumer& consumer)
}
else if (op == "PORT")
{
/*place holder for flush port fdb*/
SWSS_LOG_ERROR("Received unsupported flush port fdb request");
alias = data;
if (alias.empty())
{
SWSS_LOG_ERROR("Receive wrong port to flush fdb!");
return;
}
if (!gPortsOrch->getPort(alias, port))
{
SWSS_LOG_ERROR("Get Port from port(%s) failed!", alias.c_str());
return;
}
if (port.m_bridge_port_id == SAI_NULL_OBJECT_ID)
{
return;
}
flushFDBEntries(port.m_bridge_port_id, SAI_NULL_OBJECT_ID);
SWSS_LOG_NOTICE("Clear fdb by port(%s)", alias.c_str());
return;
}
else if (op == "VLAN")
{
/*place holder for flush vlan fdb*/
SWSS_LOG_ERROR("Received unsupported flush vlan fdb request");
vlan = data;
if (vlan.empty())
{
SWSS_LOG_ERROR("Receive wrong vlan to flush fdb!");
return;
}
if (!gPortsOrch->getPort(vlan, vlanPort))
{
SWSS_LOG_ERROR("Get Port from vlan(%s) failed!", vlan.c_str());
return;
}
if (vlanPort.m_vlan_info.vlan_oid == SAI_NULL_OBJECT_ID)
{
return;
}
flushFDBEntries(SAI_NULL_OBJECT_ID, vlanPort.m_vlan_info.vlan_oid);
SWSS_LOG_NOTICE("Clear fdb by vlan(%s)", vlan.c_str());
return;
}
else if (op == "PORTVLAN")
{
size_t found = data.find('|');
if (found != string::npos)
{
alias = data.substr(0, found);
vlan = data.substr(found+1);
}
if (alias.empty() || vlan.empty())
{
SWSS_LOG_ERROR("Receive wrong port or vlan to flush fdb!");
return;
}
if (!gPortsOrch->getPort(alias, port))
{
SWSS_LOG_ERROR("Get Port from port(%s) failed!", alias.c_str());
return;
}
if (!gPortsOrch->getPort(vlan, vlanPort))
{
SWSS_LOG_ERROR("Get Port from vlan(%s) failed!", vlan.c_str());
return;
}
if (port.m_bridge_port_id == SAI_NULL_OBJECT_ID ||
vlanPort.m_vlan_info.vlan_oid == SAI_NULL_OBJECT_ID)
{
return;
}
flushFDBEntries(port.m_bridge_port_id, vlanPort.m_vlan_info.vlan_oid);
SWSS_LOG_NOTICE("Clear fdb by port(%s)+vlan(%s)", alias.c_str(), vlan.c_str());
return;
}
else
Expand Down

0 comments on commit 031f536

Please sign in to comment.