From 037aee61dc26048dd4d761c1bac184be6ffcc79c Mon Sep 17 00:00:00 2001 From: Madhan Babu Date: Wed, 23 Sep 2020 23:24:50 +0300 Subject: [PATCH 1/8] remove FDB entires of BridgePort before removing the BridgePort --- orchagent/portsorch.cpp | 39 +++++++++++++++++++++++++++++++++++++++ orchagent/portsorch.h | 1 + 2 files changed, 40 insertions(+) diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 5ceed76760..f415df8435 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -3130,6 +3130,37 @@ void PortsOrch::doTask(Consumer &consumer) } } +bool PortsOrch::flushFDBEntries(sai_object_id_t bridge_port_id) +{ + vector attrs; + sai_attribute_t attr; + sai_status_t rv = SAI_STATUS_SUCCESS; + + SWSS_LOG_ENTER(); + + if (SAI_NULL_OBJECT_ID == bridge_port_id) + { + SWSS_LOG_WARN("Couldn't flush FDB. Bridge port OID: 0x%" PRIx64, + bridge_port_id); + return false; + } + + attr.id = SAI_FDB_FLUSH_ATTR_BRIDGE_PORT_ID; + attr.value.oid = bridge_port_id; + attrs.push_back(attr); + + SWSS_LOG_INFO("Flushing FDB bridge_port_oid: 0x%" PRIx64, bridge_port_id); + + rv = sai_fdb_api->flush_fdb_entries(gSwitchId, (uint32_t)attrs.size(), attrs.data()); + if (SAI_STATUS_SUCCESS != rv) + { + SWSS_LOG_ERROR("Flushing FDB failed. rv:%d", rv); + return false; + } + + return true; +} + void PortsOrch::initializeQueues(Port &port) { SWSS_LOG_ENTER(); @@ -3431,6 +3462,14 @@ bool PortsOrch::removeBridgePort(Port &port) return false; } + //Flush the FDB entires corresponding to the port + if (!flushFDBEntries(port.m_bridge_port_id)) + { + SWSS_LOG_ERROR("Failed to flush FDB entries for the port %s", + port.m_alias.c_str()); + return false; + } + /* Remove bridge port */ status = sai_bridge_api->remove_bridge_port(port.m_bridge_port_id); if (status != SAI_STATUS_SUCCESS) diff --git a/orchagent/portsorch.h b/orchagent/portsorch.h index 936f1ff07e..1330c2157c 100755 --- a/orchagent/portsorch.h +++ b/orchagent/portsorch.h @@ -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 &portv); + bool flushFDBEntries(sai_object_id_t); private: unique_ptr m_counterTable; unique_ptr
m_counterLagTable; From 0060a3328177105deb834d39e07479270c48d49b Mon Sep 17 00:00:00 2001 From: Madhan Babu Date: Thu, 24 Sep 2020 23:20:27 +0300 Subject: [PATCH 2/8] fixed function naming and other print related information --- orchagent/portsorch.cpp | 18 +++++++++--------- orchagent/portsorch.h | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index f415df8435..1718033319 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -3130,7 +3130,7 @@ void PortsOrch::doTask(Consumer &consumer) } } -bool PortsOrch::flushFDBEntries(sai_object_id_t bridge_port_id) +bool PortsOrch::flushFdbEntries(Port port) { vector attrs; sai_attribute_t attr; @@ -3138,23 +3138,23 @@ bool PortsOrch::flushFDBEntries(sai_object_id_t bridge_port_id) SWSS_LOG_ENTER(); - if (SAI_NULL_OBJECT_ID == bridge_port_id) + if (SAI_NULL_OBJECT_ID == port.m_bridge_port_id) { - SWSS_LOG_WARN("Couldn't flush FDB. Bridge port OID: 0x%" PRIx64, - bridge_port_id); + SWSS_LOG_WARN("Couldn't flush FDB entries for port: %s", + port.m_alias.c_str()); return false; } attr.id = SAI_FDB_FLUSH_ATTR_BRIDGE_PORT_ID; - attr.value.oid = bridge_port_id; + attr.value.oid = port.m_bridge_port_id; attrs.push_back(attr); - SWSS_LOG_INFO("Flushing FDB bridge_port_oid: 0x%" PRIx64, bridge_port_id); + 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 failed. rv:%d", rv); + SWSS_LOG_ERROR("Flushing FDB for port %s failed. rv:%d", port.m_alias.c_str(), rv); return false; } @@ -3463,9 +3463,9 @@ bool PortsOrch::removeBridgePort(Port &port) } //Flush the FDB entires corresponding to the port - if (!flushFDBEntries(port.m_bridge_port_id)) + if (!flushFdbEntries(port)) { - SWSS_LOG_ERROR("Failed to flush FDB entries for the port %s", + SWSS_LOG_ERROR("Failed to flush FDB entries for port %s", port.m_alias.c_str()); return false; } diff --git a/orchagent/portsorch.h b/orchagent/portsorch.h index 1330c2157c..7daa48863c 100755 --- a/orchagent/portsorch.h +++ b/orchagent/portsorch.h @@ -127,7 +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 &portv); - bool flushFDBEntries(sai_object_id_t); + bool flushFDBEntries(Port); private: unique_ptr
m_counterTable; unique_ptr
m_counterLagTable; From 82e467e956d015c09f933b1bc039b51cf151e287 Mon Sep 17 00:00:00 2001 From: Madhan Babu Date: Thu, 24 Sep 2020 23:28:35 +0300 Subject: [PATCH 3/8] fixed indentation issue --- orchagent/portsorch.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 1718033319..e821ec70e0 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -3155,7 +3155,7 @@ bool PortsOrch::flushFdbEntries(Port port) 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 false; } return true; From c165697df2124d971a1c80254e1100c760e99fde Mon Sep 17 00:00:00 2001 From: Madhan Babu Date: Sun, 27 Sep 2020 16:54:02 +0300 Subject: [PATCH 4/8] Fixing function name in portsorch.h --- orchagent/portsorch.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/orchagent/portsorch.h b/orchagent/portsorch.h index 7daa48863c..dfce86c0d0 100755 --- a/orchagent/portsorch.h +++ b/orchagent/portsorch.h @@ -127,7 +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 &portv); - bool flushFDBEntries(Port); + bool flushFdbEntries(Port); private: unique_ptr
m_counterTable; unique_ptr
m_counterLagTable; From 7dd0610ccf1662d716b6a946fcb1e011089691bb Mon Sep 17 00:00:00 2001 From: Madhan Babu Date: Wed, 30 Sep 2020 05:11:39 +0300 Subject: [PATCH 5/8] added function call to flushFdbEntries() also in removeDefaultBridgePorts() function --- orchagent/portsorch.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index e821ec70e0..a8c37cfa7c 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -444,6 +444,16 @@ 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) { From 6c87e0fb71724a5f364d1a988cf233db81d3a01a Mon Sep 17 00:00:00 2001 From: Madhan Babu Date: Wed, 30 Sep 2020 21:45:20 +0300 Subject: [PATCH 6/8] fixed indentation issues --- orchagent/portsorch.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index a8c37cfa7c..bc25296a94 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -445,13 +445,12 @@ void PortsOrch::removeDefaultBridgePorts() if (attr.value.s32 == SAI_BRIDGE_PORT_TYPE_PORT) { Port port; - getPortByBridgePortId(bridge_port_list[i], 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()); + 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]); @@ -3150,8 +3149,7 @@ bool PortsOrch::flushFdbEntries(Port port) 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()); + SWSS_LOG_WARN("Couldn't flush FDB entries for port: %s", port.m_alias.c_str()); return false; } From c5ab0dc2fc849f1e63b533f7e8b7ef973a7fefc5 Mon Sep 17 00:00:00 2001 From: Madhan Babu Date: Fri, 2 Oct 2020 00:34:39 +0300 Subject: [PATCH 7/8] instead of a new member function for portsorch used fdborch member function --- orchagent/portsorch.cpp | 49 ++++------------------------------------- orchagent/portsorch.h | 1 - 2 files changed, 4 insertions(+), 46 deletions(-) diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index bc25296a94..20663b35c2 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -26,6 +26,7 @@ #include "countercheckorch.h" #include "notifier.h" #include "redisclient.h" +#include "fdborch.h" extern sai_switch_api_t *sai_switch_api; extern sai_bridge_api_t *sai_bridge_api; @@ -41,6 +42,7 @@ extern IntfsOrch *gIntfsOrch; extern NeighOrch *gNeighOrch; extern CrmOrch *gCrmOrch; extern BufferOrch *gBufferOrch; +extern FdbOrch *gFdbOrch; #define VLAN_PREFIX "Vlan" #define DEFAULT_VLAN_ID 1 @@ -444,15 +446,6 @@ 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) { @@ -3139,36 +3132,6 @@ void PortsOrch::doTask(Consumer &consumer) } } -bool PortsOrch::flushFdbEntries(Port port) -{ - vector 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; - } - - 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(); @@ -3471,12 +3434,8 @@ bool PortsOrch::removeBridgePort(Port &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()); - return false; - } + gFdbOrch->flushFDBEntries(port.m_bridge_port_id, SAI_NULL_OBJECT_ID); + SWSS_LOG_INFO("Flush FDB entries for port %s", port.m_alias.c_str()); /* Remove bridge port */ status = sai_bridge_api->remove_bridge_port(port.m_bridge_port_id); diff --git a/orchagent/portsorch.h b/orchagent/portsorch.h index dfce86c0d0..936f1ff07e 100755 --- a/orchagent/portsorch.h +++ b/orchagent/portsorch.h @@ -127,7 +127,6 @@ 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 &portv); - bool flushFdbEntries(Port); private: unique_ptr
m_counterTable; unique_ptr
m_counterLagTable; From 09c5a41368d12aa966752e9fd149c9103af5675a Mon Sep 17 00:00:00 2001 From: Madhan Babu Date: Fri, 2 Oct 2020 00:36:54 +0300 Subject: [PATCH 8/8] moved flushFDBEntries member function of fdborch from private to public --- orchagent/fdborch.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/orchagent/fdborch.h b/orchagent/fdborch.h index 83f3086a0a..415215d0c2 100644 --- a/orchagent/fdborch.h +++ b/orchagent/fdborch.h @@ -47,6 +47,8 @@ class FdbOrch: public Orch, public Subject, public Observer void update(sai_fdb_event_t, const sai_fdb_entry_t *, sai_object_id_t); void update(SubjectType type, void *cntx); bool getPort(const MacAddress&, uint16_t, Port&); + void flushFDBEntries(sai_object_id_t bridge_port_oid, + sai_object_id_t vlan_oid); private: PortsOrch *m_portsOrch; @@ -64,9 +66,6 @@ class FdbOrch: public Orch, public Subject, public Observer void updatePortOperState(const PortOperStateUpdate&); bool addFdbEntry(const FdbEntry&, const string&); bool removeFdbEntry(const FdbEntry&); - void flushFDBEntries(sai_object_id_t bridge_port_oid, - sai_object_id_t vlan_oid); - bool storeFdbEntryState(const FdbUpdate& update); };