Skip to content

Commit f17b20e

Browse files
committed
Update fdborch.cpp
1 parent 41a4a18 commit f17b20e

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

orchagent/fdborch.cpp

+38-3
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,10 @@ void FdbOrch::update(sai_fdb_event_t type,
201201
update.add = true;
202202
update.entry.port_name = update.port.m_alias;
203203
update.type = "dynamic";
204+
update.port.m_fdb_count++;
205+
m_portsOrch->setPort(update.port.m_alias, update.port);
206+
vlan.m_fdb_count++;
207+
m_portsOrch->setPort(vlan.m_alias, vlan);
204208

205209
storeFdbEntryState(update);
206210
notify(SUBJECT_TYPE_FDB_CHANGE, &update);
@@ -279,7 +283,16 @@ void FdbOrch::update(sai_fdb_event_t type,
279283
}
280284

281285
update.add = false;
282-
286+
if (!update.port.m_alias.empty())
287+
{
288+
update.port.m_fdb_count--;
289+
m_portsOrch->setPort(update.port.m_alias, update.port);
290+
}
291+
if (!vlan.m_alias.empty())
292+
{
293+
vlan.m_fdb_count--;
294+
m_portsOrch->setPort(vlan.m_alias, vlan);
295+
}
283296
storeFdbEntryState(update);
284297

285298
notify(SUBJECT_TYPE_FDB_CHANGE, &update);
@@ -313,7 +326,13 @@ void FdbOrch::update(sai_fdb_event_t type,
313326
}
314327

315328
update.add = true;
316-
329+
if (!port_old.m_alias.empty())
330+
{
331+
port_old.m_fdb_count--;
332+
m_portsOrch->setPort(port_old.m_alias, port_old);
333+
}
334+
update.port.m_fdb_count++;
335+
m_portsOrch->setPort(update.port.m_alias, update.port);
317336
storeFdbEntryState(update);
318337

319338
notify(SUBJECT_TYPE_FDB_CHANGE, &update);
@@ -1057,6 +1076,13 @@ bool FdbOrch::addFdbEntry(const FdbEntry& entry, const string& port_name,
10571076
return false;
10581077
}
10591078
}
1079+
if (oldPort.m_bridge_port_id != port.m_bridge_port_id)
1080+
{
1081+
oldPort.m_fdb_count--;
1082+
m_portsOrch->setPort(oldPort.m_alias, oldPort);
1083+
port.m_fdb_count++;
1084+
m_portsOrch->setPort(port.m_alias, port);
1085+
}
10601086
}
10611087
else
10621088
{
@@ -1070,6 +1096,10 @@ bool FdbOrch::addFdbEntry(const FdbEntry& entry, const string& port_name,
10701096
vlan.m_alias.c_str(), port_name.c_str(), status);
10711097
return false; //FIXME: it should be based on status. Some could be retried, some not
10721098
}
1099+
port.m_fdb_count++;
1100+
m_portsOrch->setPort(port.m_alias, port);
1101+
vlan.m_fdb_count++;
1102+
m_portsOrch->setPort(vlan.m_alias, vlan);
10731103
}
10741104

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

1218+
port.m_fdb_count--;
1219+
m_portsOrch->setPort(port.m_alias, port);
1220+
vlan.m_fdb_count--;
1221+
m_portsOrch->setPort(vlan.m_alias, vlan);
11881222
(void)m_entries.erase(entry);
11891223

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

1264-
if (port.m_type != Port::TUNNEL)
1298+
if((port.m_type != Port::TUNNEL) ||
1299+
(port.m_fdb_count != 0))
12651300
return;
12661301

12671302
tunnel_orch->deleteTunnelPort(port);

0 commit comments

Comments
 (0)