-
Notifications
You must be signed in to change notification settings - Fork 545
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
[fdborch]Add the support for a clear fdb cli #426
Conversation
merge from Azure/sonic-swss master
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.
As commented
orchagent/fdborch.cpp
Outdated
|
||
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 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.
orchagent/fdborch.cpp
Outdated
|
||
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 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.
orchagent/fdborch.cpp
Outdated
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
revised.
orchagent/fdborch.cpp
Outdated
|
||
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 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.
orchagent/fdborch.cpp
Outdated
} | ||
} | ||
} | ||
else if(bridge_port_id && !(entry->vlan_id)) |
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.
redundand parenthesis around entry->vlan_id
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.
orchagent/fdborch.cpp
Outdated
/*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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
revised.
orchagent/fdborch.cpp
Outdated
case SAI_FDB_EVENT_FLUSHED: | ||
if( !bridge_port_id && !(entry->vlan_id)) | ||
{ | ||
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
revised.
orchagent/fdborch.cpp
Outdated
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 comment
The reason will be displayed to describe this comment to others. Learn more.
please follow existing code convention for the whitespaces.
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.
change to bridge_port_id == SAI_NULL_OBJECT_ID
for (auto observer: m_observers) | ||
{ | ||
observer->update(SUBJECT_TYPE_FDB_CHANGE, &update); | ||
} |
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.
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 comment
The 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.
orchagent/fdborch.cpp
Outdated
case SAI_FDB_EVENT_FLUSHED: | ||
if( !bridge_port_id && !entry->vlan_id) | ||
{ | ||
for(auto itr = m_entries.begin(); itr != m_entries.end(); ++itr ) |
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.
keep white space convention as existing code, thanks.
/*this is a placeholder for flush vlan fdb case, not supported yet.*/ | ||
SWSS_LOG_ERROR("FdbOrch notification: not supported flush vlan fdb action, port_id = %lu, vlan_id = %d.", bridge_port_id, entry->vlan_id); | ||
} | ||
else |
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.
@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 comment
The reason will be displayed to describe this comment to others. Learn more.
Observed in testing that per-entry delete is coming with event type SAI_FDB_EVENT_AGED
instead of event FLUSHED, which is handled in the above case. Also, I think, deleting mac one-by-one doesn't fall into this category as there could be multiple mac entries learnt on the same port-vlan combination
orchagent/fdborch.cpp
Outdated
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 comment
The 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 comment
The 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.
/*this is a placeholder for flush vlan fdb case, not supported yet.*/ | ||
SWSS_LOG_ERROR("FdbOrch notification: not supported flush vlan fdb action, port_id = %lu, vlan_id = %d.", bridge_port_id, entry->vlan_id); | ||
} | ||
else |
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.
Observed in testing that per-entry delete is coming with event type SAI_FDB_EVENT_AGED
instead of event FLUSHED, which is handled in the above case. Also, I think, deleting mac one-by-one doesn't fall into this category as there could be multiple mac entries learnt on the same port-vlan combination
orchagent/fdborch.cpp
Outdated
attr.id = SAI_FDB_FLUSH_ATTR_ENTRY_TYPE; | ||
attr.value.s32 = SAI_FDB_FLUSH_ENTRY_TYPE_DYNAMIC; | ||
|
||
status = sai_fdb_api->flush_fdb_entries(gSwitchId, 1, &attr); |
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.
when flushing all, there should be 0 attributes passed, all static and dynamic entries should be cleared
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.
Signed-off-by: Wataru Ishida <ishida@nel-america.com>
What I did
revise the FdbOrch::update(sai_fdb_event_t type, const sai_fdb_entry_t* entry, sai_object_id_t bridge_port_id) function to support a clear fdb cli
Why I did it
the current implementation is assuming that SAI will send all the flushed fdb entries to upper layers, but actually SAI only send one event to indicate the flush type, like flush all, flush fdb entries in certain port or certain vlan. upper layer need to find out all the flushed fdb entries by itself and then update it.
How I verified it
tested on MLNX plat form with various flush fdb cases.
Details if related
design doc see https://github.com/Azure/SONiC/wiki/SONiC-Clear-FDB-CLI-Design