SONiC Clear FDB CLI Design - Staphylo/SONiC GitHub Wiki
SONiC Clear FDB CLI Design
Rev 0.1
Revision
Rev | Date | Author | Change Description |
---|---|---|---|
0.1 | Liu Kebo | Initial version |
About This Manual
This document is intended to provide general information about the SONiC Clear FDB CLI implementation.
1. Functional Requirements
The SONiC Clear FDB CLI shall provide a user interface to clear All the dynamic FDB entries in the SONiC system, including the FDB table inside SDK/HW and ASIC_DB of sairedis.
2. CLI Design
Generally, this CLI will be implemented by the following approach:
-
When CLI command executed, CLI utility will connect to APPL_DB and publish a notification via "FLUSHFDBREQUEST" channel.
-
Add a NotificationConsumer to FdbOrch of Orchagent, which subscribe to a new notification channel "FLUSHFDBREQUEST" of APPL_DB. When FdbOrch received this notification it will call the flush FDB API which provided by sairedis.
-
On the FDB flush event callback, syncd will update the ASIC_DB to remove all the FDB entries.
-
On the FDB flush event callback, FdbOrch will update the internal data structure "m_entries".
2.1 FdbOrch extension for the new notification
-
Add a new NotificationConsumer to FdbOrch
auto consumer = new NotificationConsumer(db, "FLUSHFDBREQUEST") auto fdbNotification = new Notifier(consumer, this); Orch::addExecutor("", fdbNotification);
-
Add a new doTask function to FdbOrch to handle this notification
void FdbOrch::doTask(NotificationConsumer& consumer);
-
In the "update" function of FdbOrch revise the handling for FLUSH event.
2.2 Syncd extension for the new notification
In function redisPutFdbEntryToAsicView, revise the handling of the FLUSH event, remove all the dynamic FDB entries from the ASIC_DB.
2.3 New "sonic-clear fdb" CLI command design
-
Implement a new python script in "sonic-utilities/script" named "fdbclear", in this script will connect to the APPL_DB and send out notification.
-
clear fdb CLI interface
this command will extend current "sonic-clear" command line by adding a new subcommand:
SONiC:# sonic-clear ? Usage: sonic-clear [OPTIONS] COMMAND [ARGS]... SONiC command line - 'Clear' command Options: -?, -h, --help Show this message and exit. Commands: arp Clear IP ARP table counters Clear counters ip Clear IP ipv6 Clear IPv6 information fdb Clear FDB /*new added sub command*/
the "sonic-clear fdb" command can support to clear all FDB in the system or clear per port and per vlan.
SONiC# sonic-clear fdb ? Usage: sonic-clear fdb [OPTIONS] COMMAND [ARGS]... Clear FDB table Options: -?, -h, --help Show this message and exit. Commands: all Clear All FDB entries port Clear FDB For a Certain Port /*will be supported later*/ vlan Clear FDB for a Certain Vlan /*will be supported later*/
In the implementation of the new sub command, python code will be like following:
command = “fdbclear” run_command(command)