Skip to content

Commit ee90681

Browse files
authored
Revert "Remove suppress-fib-pending CLI and make route_check.py check suppress-fib in BGP configuration" (#3477)
Reverts #3331 BGP zebra enhancements is merged to master branch #19717 Reverting the revert of bgp suppress pending feature to enable it in master branch
1 parent c4ce5ae commit ee90681

6 files changed

Lines changed: 111 additions & 28 deletions

File tree

config/main.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2376,6 +2376,20 @@ def synchronous_mode(sync_mode):
23762376
config reload -y \n
23772377
Option 2. systemctl restart swss""" % sync_mode)
23782378

2379+
2380+
#
2381+
# 'suppress-fib-pending' command ('config suppress-fib-pending ...')
2382+
#
2383+
@config.command('suppress-fib-pending')
2384+
@click.argument('state', metavar='<enabled|disabled>', required=True, type=click.Choice(['enabled', 'disabled']))
2385+
@clicommon.pass_db
2386+
def suppress_pending_fib(db, state):
2387+
''' Enable or disable pending FIB suppression. Once enabled,
2388+
BGP will not advertise routes that are not yet installed in the hardware '''
2389+
2390+
config_db = db.cfgdb
2391+
config_db.mod_entry('DEVICE_METADATA', 'localhost', {"suppress-fib-pending": state})
2392+
23792393
#
23802394
# 'yang_config_validation' command ('config yang_config_validation ...')
23812395
#

doc/Command-Reference.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2612,6 +2612,26 @@ This command displays the routing policy that takes precedence over the other ro
26122612
Exit routemap
26132613
```
26142614
2615+
**show suppress-fib-pending**
2616+
2617+
This command is used to show the status of suppress pending FIB feature.
2618+
When enabled, BGP will not advertise routes which aren't yet offloaded.
2619+
2620+
- Usage:
2621+
```
2622+
show suppress-fib-pending
2623+
```
2624+
2625+
- Examples:
2626+
```
2627+
admin@sonic:~$ show suppress-fib-pending
2628+
Enabled
2629+
```
2630+
```
2631+
admin@sonic:~$ show suppress-fib-pending
2632+
Disabled
2633+
```
2634+
26152635
**show bgp device-global**
26162636
26172637
This command displays BGP device global configuration.
@@ -2724,6 +2744,24 @@ This command is used to remove particular IPv4 or IPv6 BGP neighbor configuratio
27242744
admin@sonic:~$ sudo config bgp remove neighbor SONIC02SPINE
27252745
```
27262746

2747+
**config suppress-fib-pending**
2748+
2749+
This command is used to enable or disable announcements of routes not yet installed in the HW.
2750+
Once enabled, BGP will not advertise routes which aren't yet offloaded.
2751+
2752+
- Usage:
2753+
```
2754+
config suppress-fib-pending <enabled|disabled>
2755+
```
2756+
2757+
- Examples:
2758+
```
2759+
admin@sonic:~$ sudo config suppress-fib-pending enabled
2760+
```
2761+
```
2762+
admin@sonic:~$ sudo config suppress-fib-pending disabled
2763+
```
2764+
27272765
**config bgp device-global tsa/w-ecmp**
27282766

27292767
This command is used to manage BGP device global configuration.

scripts/route_check.py

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -328,16 +328,6 @@ def get_asicdb_routes(namespace):
328328
return (selector, subs, sorted(rt))
329329

330330

331-
def is_bgp_suppress_fib_pending_enabled(namespace):
332-
"""
333-
Retruns True if FIB suppression is enabled in BGP config, False otherwise
334-
"""
335-
show_run_cmd = ['show', 'runningconfiguration', 'bgp', '-n', namespace]
336-
337-
output = subprocess.check_output(show_run_cmd, text=True)
338-
return 'bgp suppress-fib-pending' in output
339-
340-
341331
def is_suppress_fib_pending_enabled(namespace):
342332
"""
343333
Returns True if FIB suppression is enabled, False otherwise
@@ -791,20 +781,19 @@ def check_routes(namespace):
791781
results[namespace] = {}
792782
results[namespace]["Unaccounted_ROUTE_ENTRY_TABLE_entries"] = rt_asic_miss
793783

794-
if is_bgp_suppress_fib_pending_enabled(namespace):
795-
rt_frr_miss = check_frr_pending_routes(namespace)
796-
797-
if rt_frr_miss:
798-
if namespace not in results:
799-
results[namespace] = {}
800-
results[namespace]["missed_FRR_routes"] = rt_frr_miss
784+
rt_frr_miss = check_frr_pending_routes(namespace)
801785

802-
if results:
803-
if rt_frr_miss and not rt_appl_miss and not rt_asic_miss:
804-
print_message(syslog.LOG_ERR, "Some routes are not set offloaded in FRR{} but all "
805-
"routes in APPL_DB and ASIC_DB are in sync".format(namespace))
806-
if is_suppress_fib_pending_enabled(namespace):
807-
mitigate_installed_not_offloaded_frr_routes(namespace, rt_frr_miss, rt_appl)
786+
if rt_frr_miss:
787+
if namespace not in results:
788+
results[namespace] = {}
789+
results[namespace]["missed_FRR_routes"] = rt_frr_miss
790+
791+
if results:
792+
if rt_frr_miss and not rt_appl_miss and not rt_asic_miss:
793+
print_message(syslog.LOG_ERR, "Some routes are not set offloaded in FRR{} \
794+
but all routes in APPL_DB and ASIC_DB are in sync".format(namespace))
795+
if is_suppress_fib_pending_enabled(namespace):
796+
mitigate_installed_not_offloaded_frr_routes(namespace, rt_frr_miss, rt_appl)
808797

809798
if results:
810799
print_message(syslog.LOG_WARNING, "Failure results: {", json.dumps(results, indent=4), "}")

show/main.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2159,6 +2159,17 @@ def peer(db, peer_ip):
21592159
click.echo(tabulate(bfd_body, bfd_headers))
21602160

21612161

2162+
# 'suppress-fib-pending' subcommand ("show suppress-fib-pending")
2163+
@cli.command('suppress-fib-pending')
2164+
@clicommon.pass_db
2165+
def suppress_pending_fib(db):
2166+
""" Show the status of suppress pending FIB feature """
2167+
2168+
field_values = db.cfgdb.get_entry('DEVICE_METADATA', 'localhost')
2169+
state = field_values.get('suppress-fib-pending', 'disabled').title()
2170+
click.echo(state)
2171+
2172+
21622173
# asic-sdk-health-event subcommand ("show asic-sdk-health-event")
21632174
@cli.group(cls=clicommon.AliasedGroup)
21642175
def asic_sdk_health_event():

tests/route_check_test.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,8 @@ def run_test(self, ct_data):
252252

253253
def mock_check_output(self, ct_data, *args, **kwargs):
254254
ns = self.extract_namespace_from_args(args[0])
255-
if 'show runningconfiguration bgp' in ' '.join(args[0]):
256-
return 'bgp suppress-fib-pending'
257-
else:
258-
routes = ct_data.get(FRR_ROUTES, {}).get(ns, {})
259-
return json.dumps(routes)
255+
routes = ct_data.get(FRR_ROUTES, {}).get(ns, {})
256+
return json.dumps(routes)
260257

261258
def assert_results(self, ct_data, ret, res):
262259
expect_ret = ct_data.get(RET, 0)

tests/suppress_pending_fib_test.py

Lines changed: 34 additions & 0 deletions
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)