Skip to content

SONiC Clear FDB CLI Design

Kebo Liu edited this page Jan 11, 2018 · 2 revisions

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:

  1. Make syncd subscribe to a new notification channel "FLUSHFDBREQUEST" of ASIC_DB, in the main loop of syncd add a branch to handle this notification. On receiving this notification syncd will call related SAI API to flush the FDB.

  2. When cli executed, cli utility will connect to ASIC_DB and publish the notification via "FLUSHFDBREQUEST" channel.

2.1 Syncd extension for the new notification

  1. Add a new notification channel in ASIC_DB

    std::shared_ptr<swss::NotificationConsumer> flushfdbRequest = std::make_shared<swss::NotificationConsumer>(dbAsic.get(), "FLUSHFDBREQUEST");

  2. Make syncd listen to this channel

    s.addSelectable(flushfdbRequest.get());

  3. In the main loop of syncd handle this notification accordingly

     else if (sel == flushfdbRequest.get())
     {
         handleFlushfdbRequest(*flushfdbRequest);
     }
    
  4. In this handler related SAI API will be called to trigger the FDB flush

     sai_attribute_t attr;
     attr.id = SAI_FDB_FLUSH_ATTR_ENTRY_TYPE;
     attr.value.s32 = SAI_FDB_FLUSH_ENTRY_TYPE_DYNAMIC;
     sai_metadata_sai_fdb_api->flush_fdb_entries(0, 1, &attr);
    
  5. Function redisPutFdbEntryToAsicView which to update fdb entries of ASIC_DB on receiving fdb_event callback will be revised for a bug in the hadnling SAI_FDB_EVENT_FLUSHED event.

2.2 New "sonic-clear fdb" CLI command design

  1. Implement a new python script in "sonic-utilities/script" named "fdbclear", in this script will connect to the ASIC_DB and send out notification.

  2. 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)
    

2.3 Flows

3. Open Questions

Clone this wiki locally