Skip to content

Commit 9126e7f

Browse files
[config/show] Add command to control pending FIB suppression (#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.
1 parent 9e32962 commit 9126e7f

File tree

4 files changed

+97
-2
lines changed

4 files changed

+97
-2
lines changed

config/main.py

+14-2
Original file line numberDiff line numberDiff line change
@@ -1793,7 +1793,7 @@ def load_minigraph(db, no_service_restart, traffic_shift_away, override_config,
17931793
cfggen_namespace_option = " -n {}".format(namespace)
17941794
clicommon.run_command(db_migrator + ' -o set_version' + cfggen_namespace_option)
17951795

1796-
# Keep device isolated with TSA
1796+
# Keep device isolated with TSA
17971797
if traffic_shift_away:
17981798
clicommon.run_command("TSA", display_cmd=True)
17991799
if override_config:
@@ -2006,9 +2006,21 @@ def synchronous_mode(sync_mode):
20062006
config reload -y \n
20072007
Option 2. systemctl restart swss""" % sync_mode)
20082008

2009+
#
2010+
# 'suppress-fib-pending' command ('config suppress-fib-pending ...')
2011+
#
2012+
@config.command('suppress-fib-pending')
2013+
@click.argument('state', metavar='<enabled|disabled>', required=True, type=click.Choice(['enabled', 'disabled']))
2014+
@clicommon.pass_db
2015+
def suppress_pending_fib(db, state):
2016+
''' Enable or disable pending FIB suppression. Once enabled, BGP will not advertise routes that are not yet installed in the hardware '''
2017+
2018+
config_db = db.cfgdb
2019+
config_db.mod_entry('DEVICE_METADATA' , 'localhost', {"suppress-fib-pending" : state})
2020+
20092021
#
20102022
# 'yang_config_validation' command ('config yang_config_validation ...')
2011-
#
2023+
#
20122024
@config.command('yang_config_validation')
20132025
@click.argument('yang_config_validation', metavar='<enable|disable>', required=True)
20142026
def yang_config_validation(yang_config_validation):

doc/Command-Reference.md

+38
Original file line numberDiff line numberDiff line change
@@ -2055,6 +2055,26 @@ This command displays the routing policy that takes precedence over the other ro
20552055
Exit routemap
20562056
```
20572057
2058+
**show suppress-fib-pending**
2059+
2060+
This command is used to show the status of suppress pending FIB feature.
2061+
When enabled, BGP will not advertise routes which aren't yet offloaded.
2062+
2063+
- Usage:
2064+
```
2065+
show suppress-fib-pending
2066+
```
2067+
2068+
- Examples:
2069+
```
2070+
admin@sonic:~$ show suppress-fib-pending
2071+
Enabled
2072+
```
2073+
```
2074+
admin@sonic:~$ show suppress-fib-pending
2075+
Disabled
2076+
```
2077+
20582078
Go Back To [Beginning of the document](#) or [Beginning of this section](#bgp)
20592079
20602080
### BGP config commands
@@ -2147,6 +2167,24 @@ This command is used to remove particular IPv4 or IPv6 BGP neighbor configuratio
21472167
admin@sonic:~$ sudo config bgp remove neighbor SONIC02SPINE
21482168
```
21492169
2170+
**config suppress-fib-pending**
2171+
2172+
This command is used to enable or disable announcements of routes not yet installed in the HW.
2173+
Once enabled, BGP will not advertise routes which aren't yet offloaded.
2174+
2175+
- Usage:
2176+
```
2177+
config suppress-fib-pending <enabled|disabled>
2178+
```
2179+
2180+
- Examples:
2181+
```
2182+
admin@sonic:~$ sudo config suppress-fib-pending enabled
2183+
```
2184+
```
2185+
admin@sonic:~$ sudo config suppress-fib-pending disabled
2186+
```
2187+
21502188
Go Back To [Beginning of the document](#) or [Beginning of this section](#bgp)
21512189
21522190
## Console

show/main.py

+11
Original file line numberDiff line numberDiff line change
@@ -2093,6 +2093,17 @@ def peer(db, peer_ip):
20932093
click.echo(tabulate(bfd_body, bfd_headers))
20942094

20952095

2096+
# 'suppress-fib-pending' subcommand ("show suppress-fib-pending")
2097+
@cli.command('suppress-fib-pending')
2098+
@clicommon.pass_db
2099+
def suppress_pending_fib(db):
2100+
""" Show the status of suppress pending FIB feature """
2101+
2102+
field_values = db.cfgdb.get_entry('DEVICE_METADATA', 'localhost')
2103+
state = field_values.get('suppress-fib-pending', 'disabled').title()
2104+
click.echo(state)
2105+
2106+
20962107
# Load plugins and register them
20972108
helper = util_base.UtilHelper()
20982109
helper.load_and_register_plugins(plugins, cli)

tests/suppress_pending_fib_test.py

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from click.testing import CliRunner
2+
3+
import config.main as config
4+
import show.main as show
5+
from utilities_common.db import Db
6+
7+
8+
class TestSuppressFibPending:
9+
def test_synchronous_mode(self):
10+
runner = CliRunner()
11+
12+
db = Db()
13+
14+
result = runner.invoke(config.config.commands['suppress-fib-pending'], ['enabled'], obj=db)
15+
print(result.output)
16+
assert result.exit_code == 0
17+
assert db.cfgdb.get_entry('DEVICE_METADATA' , 'localhost')['suppress-fib-pending'] == 'enabled'
18+
19+
result = runner.invoke(show.cli.commands['suppress-fib-pending'], obj=db)
20+
assert result.exit_code == 0
21+
assert result.output == 'Enabled\n'
22+
23+
result = runner.invoke(config.config.commands['suppress-fib-pending'], ['disabled'], obj=db)
24+
print(result.output)
25+
assert result.exit_code == 0
26+
assert db.cfgdb.get_entry('DEVICE_METADATA' , 'localhost')['suppress-fib-pending'] == 'disabled'
27+
28+
result = runner.invoke(show.cli.commands['suppress-fib-pending'], obj=db)
29+
assert result.exit_code == 0
30+
assert result.output == 'Disabled\n'
31+
32+
result = runner.invoke(config.config.commands['suppress-fib-pending'], ['invalid-input'], obj=db)
33+
print(result.output)
34+
assert result.exit_code != 0

0 commit comments

Comments
 (0)