Skip to content

Commit

Permalink
[config/show] Add command to control pending FIB suppression (sonic-n…
Browse files Browse the repository at this point in the history
…et#2495)

* [config/show] Add command to control pending FIB suppression

What I did
I added a command config suppress-pending-fib that will allow user to enable/disable this feature.
Once it is enabled, BGP will wait for route to be programmed to HW before announcing the route to the peers.

I also added a corresponding show command that prints the status of this feature.
  • Loading branch information
stepanblyschak authored and isabelmsft committed Mar 23, 2023
1 parent 5244e3b commit 18a3d00
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 2 deletions.
16 changes: 14 additions & 2 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1794,7 +1794,7 @@ def load_minigraph(db, no_service_restart, traffic_shift_away, override_config,
cfggen_namespace_option = " -n {}".format(namespace)
clicommon.run_command(db_migrator + ' -o set_version' + cfggen_namespace_option)

# Keep device isolated with TSA
# Keep device isolated with TSA
if traffic_shift_away:
clicommon.run_command("TSA", display_cmd=True)
if override_config:
Expand Down Expand Up @@ -2007,9 +2007,21 @@ def synchronous_mode(sync_mode):
config reload -y \n
Option 2. systemctl restart swss""" % sync_mode)

#
# 'suppress-fib-pending' command ('config suppress-fib-pending ...')
#
@config.command('suppress-fib-pending')
@click.argument('state', metavar='<enabled|disabled>', required=True, type=click.Choice(['enabled', 'disabled']))
@clicommon.pass_db
def suppress_pending_fib(db, state):
''' Enable or disable pending FIB suppression. Once enabled, BGP will not advertise routes that are not yet installed in the hardware '''

config_db = db.cfgdb
config_db.mod_entry('DEVICE_METADATA' , 'localhost', {"suppress-fib-pending" : state})

#
# 'yang_config_validation' command ('config yang_config_validation ...')
#
#
@config.command('yang_config_validation')
@click.argument('yang_config_validation', metavar='<enable|disable>', required=True)
def yang_config_validation(yang_config_validation):
Expand Down
38 changes: 38 additions & 0 deletions doc/Command-Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2055,6 +2055,26 @@ This command displays the routing policy that takes precedence over the other ro
Exit routemap
```

**show suppress-fib-pending**

This command is used to show the status of suppress pending FIB feature.
When enabled, BGP will not advertise routes which aren't yet offloaded.

- Usage:
```
show suppress-fib-pending
```

- Examples:
```
admin@sonic:~$ show suppress-fib-pending
Enabled
```
```
admin@sonic:~$ show suppress-fib-pending
Disabled
```

Go Back To [Beginning of the document](#) or [Beginning of this section](#bgp)

### BGP config commands
Expand Down Expand Up @@ -2147,6 +2167,24 @@ This command is used to remove particular IPv4 or IPv6 BGP neighbor configuratio
admin@sonic:~$ sudo config bgp remove neighbor SONIC02SPINE
```

**config suppress-fib-pending**

This command is used to enable or disable announcements of routes not yet installed in the HW.
Once enabled, BGP will not advertise routes which aren't yet offloaded.

- Usage:
```
config suppress-fib-pending <enabled|disabled>
```

- Examples:
```
admin@sonic:~$ sudo config suppress-fib-pending enabled
```
```
admin@sonic:~$ sudo config suppress-fib-pending disabled
```

Go Back To [Beginning of the document](#) or [Beginning of this section](#bgp)

## Console
Expand Down
11 changes: 11 additions & 0 deletions show/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2093,6 +2093,17 @@ def peer(db, peer_ip):
click.echo(tabulate(bfd_body, bfd_headers))


# 'suppress-fib-pending' subcommand ("show suppress-fib-pending")
@cli.command('suppress-fib-pending')
@clicommon.pass_db
def suppress_pending_fib(db):
""" Show the status of suppress pending FIB feature """

field_values = db.cfgdb.get_entry('DEVICE_METADATA', 'localhost')
state = field_values.get('suppress-fib-pending', 'disabled').title()
click.echo(state)


# Load plugins and register them
helper = util_base.UtilHelper()
helper.load_and_register_plugins(plugins, cli)
Expand Down
34 changes: 34 additions & 0 deletions tests/suppress_pending_fib_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from click.testing import CliRunner

import config.main as config
import show.main as show
from utilities_common.db import Db


class TestSuppressFibPending:
def test_synchronous_mode(self):
runner = CliRunner()

db = Db()

result = runner.invoke(config.config.commands['suppress-fib-pending'], ['enabled'], obj=db)
print(result.output)
assert result.exit_code == 0
assert db.cfgdb.get_entry('DEVICE_METADATA' , 'localhost')['suppress-fib-pending'] == 'enabled'

result = runner.invoke(show.cli.commands['suppress-fib-pending'], obj=db)
assert result.exit_code == 0
assert result.output == 'Enabled\n'

result = runner.invoke(config.config.commands['suppress-fib-pending'], ['disabled'], obj=db)
print(result.output)
assert result.exit_code == 0
assert db.cfgdb.get_entry('DEVICE_METADATA' , 'localhost')['suppress-fib-pending'] == 'disabled'

result = runner.invoke(show.cli.commands['suppress-fib-pending'], obj=db)
assert result.exit_code == 0
assert result.output == 'Disabled\n'

result = runner.invoke(config.config.commands['suppress-fib-pending'], ['invalid-input'], obj=db)
print(result.output)
assert result.exit_code != 0

0 comments on commit 18a3d00

Please sign in to comment.