Skip to content

Commit 756dd9c

Browse files
madhanmellanoxMadhan Babu
and
Madhan Babu
authored
[201911 sonic-swss] Flushing FDB entries before removing BridgePort (#1516)
**What I did** I added coded in sonic-swss orchagent to flush the FDB entries corresponding to the bridge port before removing the bridgeport. **Why I did it** I did it because if we don't flush the FDB entries before removing the bridge port and try to remove the bridge port, the bridge port removal results in a failure and the port operational status is set to down. **How I verified it** I created a VLAN interface, assigned IP address to it and added 2 Ethernet ports as tagged members to it. I waited for the switch to add its neighbors through these bridge ports. Then I removed VLAN membership of one of the bridge ports and see it is successful and the operational state of the port does not go down on removing the VLAN membership. **Details if related** flushFDBEntries() function is introduce in orchagent/fdborch.cpp and called from orchagent/portsorch.cpp Co-authored-by: Madhan Babu <[email protected]>
1 parent e3f22ea commit 756dd9c

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

orchagent/fdborch.cpp

+40
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,46 @@ void FdbOrch::doTask(NotificationConsumer& consumer)
416416
}
417417
}
418418

419+
void FdbOrch::flushFDBEntries(sai_object_id_t bridge_port_oid,
420+
sai_object_id_t vlan_oid)
421+
{
422+
vector<sai_attribute_t> attrs;
423+
sai_attribute_t attr;
424+
sai_status_t rv = SAI_STATUS_SUCCESS;
425+
426+
SWSS_LOG_ENTER();
427+
428+
if (SAI_NULL_OBJECT_ID == bridge_port_oid &&
429+
SAI_NULL_OBJECT_ID == vlan_oid)
430+
{
431+
SWSS_LOG_WARN("Couldn't flush FDB. Bridge port OID: 0x%" PRIx64 " bvid:%" PRIx64 ",",
432+
bridge_port_oid, vlan_oid);
433+
return;
434+
}
435+
436+
if (SAI_NULL_OBJECT_ID != bridge_port_oid)
437+
{
438+
attr.id = SAI_FDB_FLUSH_ATTR_BRIDGE_PORT_ID;
439+
attr.value.oid = bridge_port_oid;
440+
attrs.push_back(attr);
441+
}
442+
443+
if (SAI_NULL_OBJECT_ID != vlan_oid)
444+
{
445+
attr.id = SAI_FDB_FLUSH_ATTR_BV_ID;
446+
attr.value.oid = vlan_oid;
447+
attrs.push_back(attr);
448+
}
449+
450+
SWSS_LOG_INFO("Flushing FDB bridge_port_oid: 0x%" PRIx64 ", and bvid_oid:0x%" PRIx64 ".", bridge_port_oid, vlan_oid);
451+
452+
rv = sai_fdb_api->flush_fdb_entries(gSwitchId, (uint32_t)attrs.size(), attrs.data());
453+
if (SAI_STATUS_SUCCESS != rv)
454+
{
455+
SWSS_LOG_ERROR("Flushing FDB failed. rv:%d", rv);
456+
}
457+
}
458+
419459
void FdbOrch::updateVlanMember(const VlanMemberUpdate& update)
420460
{
421461
SWSS_LOG_ENTER();

orchagent/fdborch.h

+2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ class FdbOrch: public Orch, public Subject, public Observer
4646
void update(sai_fdb_event_t, const sai_fdb_entry_t *, sai_object_id_t);
4747
void update(SubjectType type, void *cntx);
4848
bool getPort(const MacAddress&, uint16_t, Port&);
49+
void flushFDBEntries(sai_object_id_t bridge_port_oid,
50+
sai_object_id_t vlan_oid);
4951

5052
private:
5153
PortsOrch *m_portsOrch;

orchagent/portsorch.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "crmorch.h"
2424
#include "countercheckorch.h"
2525
#include "notifier.h"
26+
#include "fdborch.h"
2627

2728
extern sai_switch_api_t *sai_switch_api;
2829
extern sai_bridge_api_t *sai_bridge_api;
@@ -37,6 +38,7 @@ extern IntfsOrch *gIntfsOrch;
3738
extern NeighOrch *gNeighOrch;
3839
extern CrmOrch *gCrmOrch;
3940
extern BufferOrch *gBufferOrch;
41+
extern FdbOrch *gFdbOrch;
4042

4143
#define VLAN_PREFIX "Vlan"
4244
#define DEFAULT_VLAN_ID 1
@@ -3019,6 +3021,8 @@ bool PortsOrch::removeBridgePort(Port &port)
30193021
/* Flush FDB entries pointing to this bridge port */
30203022
// TODO: Remove all FDB entries associated with this bridge port before
30213023
// removing the bridge port itself
3024+
gFdbOrch->flushFDBEntries(port.m_bridge_port_id, SAI_NULL_OBJECT_ID);
3025+
SWSS_LOG_INFO("Flush FDB entries for port %s", port.m_alias.c_str());
30223026

30233027
/* Remove bridge port */
30243028
status = sai_bridge_api->remove_bridge_port(port.m_bridge_port_id);

0 commit comments

Comments
 (0)