diff --git a/orchagent/fdborch.cpp b/orchagent/fdborch.cpp index 03c854fee3..e3f9f67957 100644 --- a/orchagent/fdborch.cpp +++ b/orchagent/fdborch.cpp @@ -1138,6 +1138,44 @@ void FdbOrch::flushFDBEntries(sai_object_id_t bridge_port_oid, } } } +void FdbOrch::flushFdbByVlan(const string &alias, bool flush_static) +{ + sai_status_t status; + Port vlan; + sai_attribute_t vlan_attr[2]; + + if (!m_portsOrch->getPort(alias, vlan)) + { + SWSS_LOG_NOTICE("could not locate vlan from alias %s", alias.c_str()); + return; + } + SWSS_LOG_NOTICE("Start: Flush by vlan %s vlan_oid 0x%lx flush_static %d", + alias.c_str(), vlan.m_vlan_info.vlan_oid, flush_static); + + vlan_attr[0].id = SAI_FDB_FLUSH_ATTR_BV_ID; + vlan_attr[0].value.oid = vlan.m_vlan_info.vlan_oid; + if (!flush_static) + { + vlan_attr[1].id = SAI_FDB_FLUSH_ATTR_ENTRY_TYPE; + vlan_attr[1].value.s32 = SAI_FDB_FLUSH_ENTRY_TYPE_DYNAMIC; + status = sai_fdb_api->flush_fdb_entries(gSwitchId, 2, vlan_attr); + } + else + { + status = sai_fdb_api->flush_fdb_entries(gSwitchId, 1, vlan_attr); + } + if (status != SAI_STATUS_SUCCESS) + { + SWSS_LOG_ERROR("Flush fdb failed, return code %x", status); + } + else + { + SWSS_LOG_NOTICE("End: Flush by vlan %s vlan_oid 0x%lx flush_static %d", + alias.c_str(), vlan.m_vlan_info.vlan_oid, flush_static); + } + + return; +} void FdbOrch::notifyObserversFDBFlush(Port &port, sai_object_id_t& bvid) { diff --git a/orchagent/fdborch.h b/orchagent/fdborch.h index 9e71bc8c6b..e225c64ea0 100644 --- a/orchagent/fdborch.h +++ b/orchagent/fdborch.h @@ -102,6 +102,7 @@ class FdbOrch: public Orch, public Subject, public Observer static const int fdborch_pri; void flushFDBEntries(sai_object_id_t bridge_port_oid, sai_object_id_t vlan_oid); + void flushFdbByVlan(const string &, bool flush_static); void notifyObserversFDBFlush(Port &p, sai_object_id_t&); private: diff --git a/orchagent/stporch.cpp b/orchagent/stporch.cpp index 9ff89f4f3c..39212b4527 100644 --- a/orchagent/stporch.cpp +++ b/orchagent/stporch.cpp @@ -8,8 +8,8 @@ extern sai_stp_api_t *sai_stp_api; extern sai_vlan_api_t *sai_vlan_api; extern sai_switch_api_t *sai_switch_api; -extern FdbOrch *gFdbOrch; -extern PortsOrch* gPortsOrch; +extern FdbOrch *gFdbOrch; +extern PortsOrch *gPortsOrch; extern sai_object_id_t gSwitchId; @@ -368,7 +368,7 @@ bool StpOrch::stpVlanFdbFlush(string vlan_alias) return false; } - //gFdbOrch->flushFdbByVlan(vlan_alias, 0); + gFdbOrch->flushFdbByVlan(vlan_alias, 0); SWSS_LOG_NOTICE("Set STP FDB flush vlan %s ", vlan_alias.c_str()); return true; diff --git a/orchagent/stporch.h b/orchagent/stporch.h index 5b1269602e..154ac7695b 100644 --- a/orchagent/stporch.h +++ b/orchagent/stporch.h @@ -26,7 +26,6 @@ class StpOrch : public Orch bool updateMaxStpInstance(uint32_t max_stp_instance); bool removeStpPorts(Port &port); bool removeVlanFromStpInstance(string vlan, sai_uint16_t stp_instance); - bool stpVlanPortFdbFlush(string port_alias, string vlan_alias); private: unique_ptr