Skip to content

Commit 031f536

Browse files
authored
support flush FDB entries per port and per vlan (#1064)
Fdb entries can be deleted with user specifying vlan or port or vlan&&port. Signed-off-by: [email protected]
1 parent 3629d70 commit 031f536

File tree

1 file changed

+70
-4
lines changed

1 file changed

+70
-4
lines changed

orchagent/fdborch.cpp

Lines changed: 70 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,10 @@ void FdbOrch::doTask(NotificationConsumer& consumer)
685685
std::string op;
686686
std::string data;
687687
std::vector<swss::FieldValueTuple> values;
688+
string alias;
689+
string vlan;
690+
Port port;
691+
Port vlanPort;
688692

689693
consumer.pop(op, data, values);
690694

@@ -706,14 +710,76 @@ void FdbOrch::doTask(NotificationConsumer& consumer)
706710
}
707711
else if (op == "PORT")
708712
{
709-
/*place holder for flush port fdb*/
710-
SWSS_LOG_ERROR("Received unsupported flush port fdb request");
713+
alias = data;
714+
if (alias.empty())
715+
{
716+
SWSS_LOG_ERROR("Receive wrong port to flush fdb!");
717+
return;
718+
}
719+
if (!gPortsOrch->getPort(alias, port))
720+
{
721+
SWSS_LOG_ERROR("Get Port from port(%s) failed!", alias.c_str());
722+
return;
723+
}
724+
if (port.m_bridge_port_id == SAI_NULL_OBJECT_ID)
725+
{
726+
return;
727+
}
728+
flushFDBEntries(port.m_bridge_port_id, SAI_NULL_OBJECT_ID);
729+
SWSS_LOG_NOTICE("Clear fdb by port(%s)", alias.c_str());
711730
return;
712731
}
713732
else if (op == "VLAN")
714733
{
715-
/*place holder for flush vlan fdb*/
716-
SWSS_LOG_ERROR("Received unsupported flush vlan fdb request");
734+
vlan = data;
735+
if (vlan.empty())
736+
{
737+
SWSS_LOG_ERROR("Receive wrong vlan to flush fdb!");
738+
return;
739+
}
740+
if (!gPortsOrch->getPort(vlan, vlanPort))
741+
{
742+
SWSS_LOG_ERROR("Get Port from vlan(%s) failed!", vlan.c_str());
743+
return;
744+
}
745+
if (vlanPort.m_vlan_info.vlan_oid == SAI_NULL_OBJECT_ID)
746+
{
747+
return;
748+
}
749+
flushFDBEntries(SAI_NULL_OBJECT_ID, vlanPort.m_vlan_info.vlan_oid);
750+
SWSS_LOG_NOTICE("Clear fdb by vlan(%s)", vlan.c_str());
751+
return;
752+
}
753+
else if (op == "PORTVLAN")
754+
{
755+
size_t found = data.find('|');
756+
if (found != string::npos)
757+
{
758+
alias = data.substr(0, found);
759+
vlan = data.substr(found+1);
760+
}
761+
if (alias.empty() || vlan.empty())
762+
{
763+
SWSS_LOG_ERROR("Receive wrong port or vlan to flush fdb!");
764+
return;
765+
}
766+
if (!gPortsOrch->getPort(alias, port))
767+
{
768+
SWSS_LOG_ERROR("Get Port from port(%s) failed!", alias.c_str());
769+
return;
770+
}
771+
if (!gPortsOrch->getPort(vlan, vlanPort))
772+
{
773+
SWSS_LOG_ERROR("Get Port from vlan(%s) failed!", vlan.c_str());
774+
return;
775+
}
776+
if (port.m_bridge_port_id == SAI_NULL_OBJECT_ID ||
777+
vlanPort.m_vlan_info.vlan_oid == SAI_NULL_OBJECT_ID)
778+
{
779+
return;
780+
}
781+
flushFDBEntries(port.m_bridge_port_id, vlanPort.m_vlan_info.vlan_oid);
782+
SWSS_LOG_NOTICE("Clear fdb by port(%s)+vlan(%s)", alias.c_str(), vlan.c_str());
717783
return;
718784
}
719785
else

0 commit comments

Comments
 (0)