Skip to content

Commit

Permalink
Update fdborch.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
anilkpandey committed Dec 28, 2020
1 parent 41a4a18 commit f17b20e
Showing 1 changed file with 38 additions and 3 deletions.
41 changes: 38 additions & 3 deletions orchagent/fdborch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ void FdbOrch::update(sai_fdb_event_t type,
update.add = true;
update.entry.port_name = update.port.m_alias;
update.type = "dynamic";
update.port.m_fdb_count++;
m_portsOrch->setPort(update.port.m_alias, update.port);
vlan.m_fdb_count++;
m_portsOrch->setPort(vlan.m_alias, vlan);

storeFdbEntryState(update);
notify(SUBJECT_TYPE_FDB_CHANGE, &update);
Expand Down Expand Up @@ -279,7 +283,16 @@ void FdbOrch::update(sai_fdb_event_t type,
}

update.add = false;

if (!update.port.m_alias.empty())
{
update.port.m_fdb_count--;
m_portsOrch->setPort(update.port.m_alias, update.port);
}
if (!vlan.m_alias.empty())
{
vlan.m_fdb_count--;
m_portsOrch->setPort(vlan.m_alias, vlan);
}
storeFdbEntryState(update);

notify(SUBJECT_TYPE_FDB_CHANGE, &update);
Expand Down Expand Up @@ -313,7 +326,13 @@ void FdbOrch::update(sai_fdb_event_t type,
}

update.add = true;

if (!port_old.m_alias.empty())
{
port_old.m_fdb_count--;
m_portsOrch->setPort(port_old.m_alias, port_old);
}
update.port.m_fdb_count++;
m_portsOrch->setPort(update.port.m_alias, update.port);
storeFdbEntryState(update);

notify(SUBJECT_TYPE_FDB_CHANGE, &update);
Expand Down Expand Up @@ -1057,6 +1076,13 @@ bool FdbOrch::addFdbEntry(const FdbEntry& entry, const string& port_name,
return false;
}
}
if (oldPort.m_bridge_port_id != port.m_bridge_port_id)
{
oldPort.m_fdb_count--;
m_portsOrch->setPort(oldPort.m_alias, oldPort);
port.m_fdb_count++;
m_portsOrch->setPort(port.m_alias, port);
}
}
else
{
Expand All @@ -1070,6 +1096,10 @@ bool FdbOrch::addFdbEntry(const FdbEntry& entry, const string& port_name,
vlan.m_alias.c_str(), port_name.c_str(), status);
return false; //FIXME: it should be based on status. Some could be retried, some not
}
port.m_fdb_count++;
m_portsOrch->setPort(port.m_alias, port);
vlan.m_fdb_count++;
m_portsOrch->setPort(vlan.m_alias, vlan);
}

FdbData storeFdbData = fdbData;
Expand Down Expand Up @@ -1185,6 +1215,10 @@ bool FdbOrch::removeFdbEntry(const FdbEntry& entry, FdbOrigin origin)
SWSS_LOG_NOTICE("Removed mac=%s bv_id=0x%lx port:%s",
entry.mac.to_string().c_str(), entry.bv_id, port.m_alias.c_str());

port.m_fdb_count--;
m_portsOrch->setPort(port.m_alias, port);
vlan.m_fdb_count--;
m_portsOrch->setPort(vlan.m_alias, vlan);
(void)m_entries.erase(entry);

// Remove in StateDb
Expand Down Expand Up @@ -1261,7 +1295,8 @@ void FdbOrch::notifyTunnelOrch(Port& port)
{
VxlanTunnelOrch* tunnel_orch = gDirectory.get<VxlanTunnelOrch*>();

if (port.m_type != Port::TUNNEL)
if((port.m_type != Port::TUNNEL) ||
(port.m_fdb_count != 0))
return;

tunnel_orch->deleteTunnelPort(port);
Expand Down

0 comments on commit f17b20e

Please sign in to comment.