-
Notifications
You must be signed in to change notification settings - Fork 283
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
Conversation
merge from Azure/sonic-sairedis master
syncd/syncd.cpp
Outdated
@@ -2936,6 +2936,88 @@ bool handleRestartQuery(swss::NotificationConsumer &restartQuery) | |||
return false; | |||
} | |||
|
|||
bool getSwitchRid(sai_object_id_t* switch_rid) |
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.
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.
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"); |
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.
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.
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.
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.
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.
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.
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.
@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.
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
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.
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; |
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.
bool ?
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.
changed to bool.
] | ||
}] | ||
*/ | ||
SWSS_LOG_NOTICE("received a flush all fdb event"); |
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 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.
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.
syncd/syncd_notifications.cpp
Outdated
else | ||
{ | ||
SWSS_LOG_ERROR("received a unknown flush fdb event, unsupported"); | ||
} |
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.
those 2 erros can be combined in 1 error message and print port_oid and 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.
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.
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
* add code to support clear fdb cli * remove redundant code and revise the error log * remove the fdb flush trigger from syncd
* Add empty case * Update teamshow * Update teamshow
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