Skip to content

[fdborch] Fixed Orchagent crash in FDB flush on port disable. #1369

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 29, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions orchagent/fdborch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,13 @@ void FdbOrch::update(sai_fdb_event_t type,
update.entry.mac.to_string().c_str(),
vlanName.c_str(), update.port.m_alias.c_str());

for (const auto& itr : m_entries)
for (auto itr = m_entries.begin(); itr != m_entries.end();)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.
Just a suggestion, can we just update the for loop to the below, instead of increment iterator at multiple places?

for (auto itr = m_entries.begin(); itr != m_entries.end(); itr = next_item)
{
    auto next_item = std::next(itr, 1);
    .....
    ....
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoided multiple iterator increment. Updated patch. Pls check.

{
if (itr.port_name == update.port.m_alias)
auto next_item = std::next(itr);
if (itr->port_name == update.port.m_alias)
{
update.entry.mac = itr.mac;
update.entry.bv_id = itr.bv_id;
update.entry.mac = itr->mac;
update.entry.bv_id = itr->bv_id;
update.add = false;

storeFdbEntryState(update);
Expand All @@ -246,7 +247,8 @@ void FdbOrch::update(sai_fdb_event_t type,
{
observer->update(SUBJECT_TYPE_FDB_CHANGE, &update);
}
}
}
itr = next_item;
}
}
else if (bridge_port_id == SAI_NULL_OBJECT_ID)
Expand Down