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

[syncd] Add support for a clear fdb cli #279

Merged
merged 4 commits into from
Jan 26, 2018
Merged

[syncd] Add support for a clear fdb cli #279

merged 4 commits into from
Jan 26, 2018

Conversation

keboliu
Copy link
Collaborator

@keboliu keboliu commented Jan 12, 2018

To implement a clear fdb cli, added code in syncd.cpp and syncd_notifications.cpp.

for syncd_notifications.cpp
- revise funtion redisPutFdbEntryToAsicView to flush the fdb entries in ASIC_DB.

design doc see https://github.com/Azure/SONiC/wiki/SONiC-Clear-FDB-CLI-Design

@keboliu keboliu changed the title Add support for a clear fdb cli [syncd] Add support for a clear fdb cli Jan 12, 2018
syncd/syncd.cpp Outdated
@@ -2936,6 +2936,88 @@ bool handleRestartQuery(swss::NotificationConsumer &restartQuery)
return false;
}

bool getSwitchRid(sai_object_id_t* switch_rid)
Copy link
Collaborator

Choose a reason for hiding this comment

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

switch rid can be obtained in much easier way: global object "switches" contains all the switches where key is VID of the switch, take a look syncd.cpp at line 50, usually there will be 1 or 0 switches

this is not needed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

optimized as suggested.

syncd/syncd.cpp Outdated
@@ -3228,6 +3310,7 @@ int syncd_main(int argc, char **argv)

std::shared_ptr<swss::ConsumerTable> asicState = std::make_shared<swss::ConsumerTable>(dbAsic.get(), ASIC_STATE_TABLE);
std::shared_ptr<swss::NotificationConsumer> restartQuery = std::make_shared<swss::NotificationConsumer>(dbAsic.get(), "RESTARTQUERY");
std::shared_ptr<swss::NotificationConsumer> flushfdbRequest = std::make_shared<swss::NotificationConsumer>(dbAsic.get(), "FLUSHFDBREQUEST");
Copy link
Collaborator

Choose a reason for hiding this comment

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

flush fdb request should be initiated via SAI api, and IMO it should be synchronous call similar to GET, and called as GET api, no need for another handler

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When started the design my idea is that since "clear fdb" is a one-shot action, not like a normal configuration, should not change configurations in the DB, so implement it via publish/subscribe mechanism is a quite straightforward way. Make it synchronous is a good suggestion, I am thinking next phase when adding "flush port" and "flush vlan" support, also make cli utilities to wait for a response from syncd or somewhere.

Copy link
Contributor

@lguohan lguohan Jan 16, 2018

Choose a reason for hiding this comment

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

I agree with @kcudnik , the request should be initiated via SAI API. Besides, the sonic-clear command should invoke APP DB and let orchagent to issue corresponding SAI API.

Copy link
Contributor

Choose a reason for hiding this comment

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

@keboliu, you probably did not understand "synchronous call similiar to GET api". You probably need to look at how GET api are implemented in syncd and sairedis.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@lguohan yes, can you give some example for GET api if you have now? And for your previous comments "regarding invoke APP DB and let orchagent to call SAI API", do you mean we need to add some new configuration in the APP DB and trigger orchagent with manipulating this new configuration?

sai_vlan_id_t vlan_id = fdb->fdb_entry.vlan_id;
sai_object_id_t port_oid = 0;
int port_oid_found = 0;
int attr_num = fdb->attr_count;
Copy link
Collaborator

Choose a reason for hiding this comment

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

extra variable not needed, use direct attr_count in line 109

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

optimized as suggested.

{
sai_vlan_id_t vlan_id = fdb->fdb_entry.vlan_id;
sai_object_id_t port_oid = 0;
int port_oid_found = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

bool ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

changed to bool.

]
}]
*/
SWSS_LOG_NOTICE("received a flush all fdb event");
Copy link
Collaborator

Choose a reason for hiding this comment

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

this behaviour is not described in SAI headers that when no port and no vlan id then 1 notification is send to notify that all have been flushed from the device, please put that description (and consult with SAI community?) whether that behavior is good
for example,
-all entries were flushed if "mac == all 0, vlanid == 0, bridge_id == 0"

this is fine by me, but please update SAI headers

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will talk to SAI guys see whether they already have something similar if not may ask them to add.

else
{
SWSS_LOG_ERROR("received a unknown flush fdb event, unsupported");
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

those 2 erros can be combined in 1 error message and print port_oid and 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.

@kcudnik
Copy link
Collaborator

kcudnik commented Jan 23, 2018

take a look at #288 i added support for sairedis to clear fdb entries, which request can come from orchagent directly

if(fdb->attr[i].id == SAI_FDB_ENTRY_ATTR_BRIDGE_PORT_ID)
{
port_oid = fdb->attr[i].value.oid;
port_oid_found = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a note, you can break from here once port_oid_found is set to true

@lguohan lguohan merged commit a6b5be8 into sonic-net:master Jan 26, 2018
@keboliu keboliu deleted the clear-fdb-cli branch January 27, 2018 05:12
pettershao-ragilenetworks pushed a commit to pettershao-ragilenetworks/sonic-sairedis that referenced this pull request Nov 18, 2022
* add code to support clear fdb cli

* remove redundant code and revise the error log

* remove the fdb flush trigger from syncd
jianyuewu pushed a commit to jianyuewu/sonic-sairedis that referenced this pull request Feb 7, 2025
* Add empty case

* Update teamshow

* Update teamshow
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.

4 participants