Skip to content
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

Merged
merged 7 commits into from
Jan 26, 2018
Merged

[fdborch]Add the support for a clear fdb cli #426

merged 7 commits into from
Jan 26, 2018

Conversation

keboliu
Copy link
Collaborator

@keboliu keboliu commented Jan 12, 2018

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

@keboliu keboliu changed the title [orchagent]Add the support for a clear fdb cli [fdborch]Add the support for a clear fdb cli Jan 12, 2018
Copy link
Contributor

@pavel-shirshov pavel-shirshov left a comment

Choose a reason for hiding this comment

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

As commented


for (auto observer: m_observers)
{
observer->update(SUBJECT_TYPE_FDB_CHANGE, static_cast<void *>(&update));
Copy link
Contributor

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

revised.


for (auto observer: m_observers)
{
observer->update(SUBJECT_TYPE_FDB_CHANGE, static_cast<void *>(&update));
Copy link
Contributor

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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))
Copy link
Contributor

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

revised.


for (auto observer: m_observers)
{
observer->update(SUBJECT_TYPE_FDB_CHANGE, static_cast<void *>(&update));
Copy link
Contributor

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

revised.

}
}
}
else if(bridge_port_id && !(entry->vlan_id))
Copy link
Contributor

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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))
Copy link
Contributor

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

revised.

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 )
Copy link
Contributor

Choose a reason for hiding this comment

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

for (auto itr = ....)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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)
Copy link
Contributor

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.

Copy link
Contributor

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);
}
Copy link
Contributor

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?

Copy link
Collaborator Author

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.

case SAI_FDB_EVENT_FLUSHED:
if( !bridge_port_id && !entry->vlan_id)
{
for(auto itr = m_entries.begin(); itr != m_entries.end(); ++itr )
Copy link
Contributor

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
Copy link
Contributor

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?

Copy link
Collaborator

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

update.entry.vlan = itr->vlan;
update.add = false;

m_entries.erase(itr);
Copy link
Collaborator

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?

Copy link
Collaborator Author

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
Copy link
Collaborator

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

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);
Copy link
Contributor

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

revised.

@lguohan lguohan merged commit 918cf5a into sonic-net:master Jan 26, 2018
@keboliu keboliu deleted the clear-fdb-cli branch January 27, 2018 05:12
EdenGri pushed a commit to EdenGri/sonic-swss that referenced this pull request Feb 28, 2022
Signed-off-by: Wataru Ishida <ishida@nel-america.com>
oleksandrivantsiv pushed a commit to oleksandrivantsiv/sonic-swss that referenced this pull request Mar 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants