-
Notifications
You must be signed in to change notification settings - Fork 580
[fdborch]Add the support for a clear fdb cli #426
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
Changes from 2 commits
3bf6269
17c4235
7a220af
d2f43c5
5eca26e
6fe005e
af8c2b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,21 +34,66 @@ void FdbOrch::update(sai_fdb_event_t type, const sai_fdb_entry_t* entry, sai_obj | |
|
||
(void)m_entries.insert(update.entry); | ||
SWSS_LOG_DEBUG("FdbOrch notification: mac %s was inserted into vlan %d", update.entry.mac.to_string().c_str(), entry->vlan_id); | ||
|
||
for (auto observer: m_observers) | ||
{ | ||
observer->update(SUBJECT_TYPE_FDB_CHANGE, static_cast<void *>(&update)); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is about the fdb flush, why touch both LEARNED, AGED, MOVE events? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. separate the handling FLUSH from AGED and MOVE, at the same time remove unnecessary type cast. No impaction to the handling of other events. |
||
|
||
break; | ||
|
||
case SAI_FDB_EVENT_AGED: | ||
case SAI_FDB_EVENT_FLUSHED: | ||
case SAI_FDB_EVENT_MOVE: | ||
update.add = false; | ||
|
||
(void)m_entries.erase(update.entry); | ||
SWSS_LOG_DEBUG("FdbOrch notification: mac %s was removed from vlan %d", update.entry.mac.to_string().c_str(), entry->vlan_id); | ||
|
||
for (auto observer: m_observers) | ||
{ | ||
observer->update(SUBJECT_TYPE_FDB_CHANGE, static_cast<void *>(&update)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can cast to void pointer without any cast mechanisms. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. revised. |
||
} | ||
|
||
break; | ||
|
||
case SAI_FDB_EVENT_FLUSHED: | ||
if( !bridge_port_id && !(entry->vlan_id)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Parenthesis around entry->vlan_id are redundant There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. revised. |
||
{ | ||
for(set<FdbEntry>::iterator itr = m_entries.begin(); itr != m_entries.end(); ++itr ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for (auto itr = ....) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. revised. |
||
{ | ||
/*This is a flush all case, need to clear up all the fdb entries*/ | ||
update.entry.mac = itr->mac; | ||
update.entry.vlan = itr->vlan; | ||
update.add = false; | ||
|
||
m_entries.erase(itr); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks to me as a non-standard way of deleting the elements of a set in for-loop as it invalidates the iterator after erase. It might have worked in test. Can you check this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will check. and I am revising the solution as Guohan suggested, will update all of these with the new solution. |
||
|
||
SWSS_LOG_DEBUG("FdbOrch notification: mac %s was removed", update.entry.mac.to_string().c_str()); | ||
|
||
for (auto observer: m_observers) | ||
{ | ||
observer->update(SUBJECT_TYPE_FDB_CHANGE, static_cast<void *>(&update)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can cast to void pointer without any cast mechanisms. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. revised. |
||
} | ||
} | ||
} | ||
else if(bridge_port_id && !(entry->vlan_id)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. redundand parenthesis around entry->vlan_id There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. revised. |
||
{ | ||
/*this is a placeholder for flush port fdb case, not supported yet.*/ | ||
SWSS_LOG_ERROR("FdbOrch notification: not supported flush type"); | ||
} | ||
else if(!bridge_port_id && (entry->vlan_id)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. redundand parenthesis around entry->vlan_id There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. revised. |
||
{ | ||
/*this is a placeholder for flush vlan fdb case, not supported yet.*/ | ||
SWSS_LOG_ERROR("FdbOrch notification: not supported flush type"); | ||
} | ||
else | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @prsunny , in case the fdb flush will send notification of deleted mac one-by-one, does it fall into this category? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Observed in testing that per-entry delete is coming with event type |
||
{ | ||
SWSS_LOG_ERROR("FdbOrch notification: not supported flush type"); | ||
} | ||
break; | ||
} | ||
|
||
for (auto observer: m_observers) | ||
{ | ||
observer->update(SUBJECT_TYPE_FDB_CHANGE, static_cast<void *>(&update)); | ||
} | ||
|
||
return; | ||
} | ||
|
||
void FdbOrch::update(SubjectType type, void *cntx) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can cast to void pointer without any cast mechanisms.
Check https://stackoverflow.com/questions/18929225/casting-class-pointer-to-void-pointer
So
observer->update(SUBJECT_TYPE_FDB_CHANGE, &update); is enough
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revised.