[syncd] Add support for a clear fdb cli#279
[syncd] Add support for a clear fdb cli#279lguohan merged 4 commits intosonic-net:masterfrom keboliu:clear-fdb-cli
Conversation
merge from Azure/sonic-sairedis master
syncd/syncd.cpp
Outdated
| return false; | ||
| } | ||
|
|
||
| bool getSwitchRid(sai_object_id_t* switch_rid) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
optimized as suggested.
syncd/syncd.cpp
Outdated
|
|
||
| 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"); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@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.
There was a problem hiding this comment.
@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?
syncd/syncd_notifications.cpp
Outdated
| 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; |
There was a problem hiding this comment.
extra variable not needed, use direct attr_count in line 109
There was a problem hiding this comment.
optimized as suggested.
syncd/syncd_notifications.cpp
Outdated
| { | ||
| sai_vlan_id_t vlan_id = fdb->fdb_entry.vlan_id; | ||
| sai_object_id_t port_oid = 0; | ||
| int port_oid_found = 0; |
| ] | ||
| }] | ||
| */ | ||
| SWSS_LOG_NOTICE("received a flush all fdb event"); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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"); | ||
| } |
There was a problem hiding this comment.
those 2 erros can be combined in 1 error message and print port_oid and vlan_id
|
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; |
There was a problem hiding this comment.
Just a note, you can break from here once port_oid_found is set to true
* add code to support clear fdb cli * remove redundant code and revise the error log * remove the fdb flush trigger from syncd
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