Skip to content

Commit

Permalink
[route_check] check if suppress fib is enabled in bgp
Browse files Browse the repository at this point in the history
Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>
  • Loading branch information
stepanblyschak committed May 27, 2024
1 parent db0735a commit 9f5d67c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
31 changes: 21 additions & 10 deletions scripts/route_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,16 @@ def get_asicdb_routes(namespace):
return (selector, subs, sorted(rt))


def is_bgp_suppress_fib_pending_enabled(namespace):
"""
Retruns True if FIB suppression is enabled in BGP config, False otherwise
"""
show_run_cmd = ['show', 'runningconfiguration', 'bgp', '-n', namespace]

output = subprocess.check_output(show_run_cmd, text=True)
return 'bgp suppress-fib-pending' in output


def is_suppress_fib_pending_enabled(namespace):
"""
Returns True if FIB suppression is enabled, False otherwise
Expand Down Expand Up @@ -781,18 +791,19 @@ def check_routes(namespace):
results[namespace] = {}
results[namespace]["Unaccounted_ROUTE_ENTRY_TABLE_entries"] = rt_asic_miss

rt_frr_miss = check_frr_pending_routes(namespace)
if is_bgp_suppress_fib_pending_enabled(namespace):
rt_frr_miss = check_frr_pending_routes(namespace)

if rt_frr_miss:
if namespace not in results:
results[namespace] = {}
results[namespace]["missed_FRR_routes"] = rt_frr_miss
if rt_frr_miss:
if namespace not in results:
results[namespace] = {}
results[namespace]["missed_FRR_routes"] = rt_frr_miss

if results:
if rt_frr_miss and not rt_appl_miss and not rt_asic_miss:
print_message(syslog.LOG_ERR, "Some routes are not set offloaded in FRR{} but all routes in APPL_DB and ASIC_DB are in sync".format(namespace))
if is_suppress_fib_pending_enabled(namespace):
mitigate_installed_not_offloaded_frr_routes(namespace, rt_frr_miss, rt_appl)
if results:
if rt_frr_miss and not rt_appl_miss and not rt_asic_miss:
print_message(syslog.LOG_ERR, "Some routes are not set offloaded in FRR{} but all routes in APPL_DB and ASIC_DB are in sync".format(namespace))
if is_suppress_fib_pending_enabled(namespace):
mitigate_installed_not_offloaded_frr_routes(namespace, rt_frr_miss, rt_appl)

if results:
print_message(syslog.LOG_WARNING, "Failure results: {", json.dumps(results, indent=4), "}")
Expand Down
7 changes: 5 additions & 2 deletions tests/route_check_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,11 @@ def run_test(self, ct_data):

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

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

0 comments on commit 9f5d67c

Please # to comment.