From a4b54175d62de975fc9274d3a455a8fac377b464 Mon Sep 17 00:00:00 2001 From: sudhanshukumar22 Date: Fri, 18 Oct 2019 01:48:17 -0700 Subject: [PATCH] Changes for supporting install-then-advertise behavior Functional specification: Azure/SONiC#424 The routes will be pushed by BGP to Zebra to fpm to be installed in hardware. If fpm returns error, the routes will not be sent by BGP to its peers. Only successful routes are sent by BGP to its peers. The feature can be enabled/disabled in BGP by a CLI. By default, the feature is disabled. Functional specification: Azure/SONiC#424 Signed-off by: Preetham Singh preetham.singh@broadcom.com Signed-off by: Sudhanshu Kumar sudhanshu.kumar@broadcom.com --- config/main.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/config/main.py b/config/main.py index dae0c8b604..2e9b1a4a82 100755 --- a/config/main.py +++ b/config/main.py @@ -1055,6 +1055,37 @@ def bgp(): def shutdown(): """Shut down BGP session(s)""" pass +@bgp.group('error-handling') +def error_handling(): + """Handle BGP route install errors""" + pass +@error_handling.group(invoke_without_command=True) +@click.pass_context +def disable(ctx): + """Administratively Disable BGP error-handling""" + config_db = ConfigDBConnector(host="127.0.0.1") + config_db.connect() + curr_mode = config_db.get_entry('BGP_ERROR_CFG_TABLE', "config").get('enable') + if (curr_mode == "true"): + cmd = 'sudo vtysh -c "configure terminal" -c "no bgp error-handling enable"' + run_command(cmd) + config_db.set_entry("BGP_ERROR_CFG_TABLE", "config", {"enable": "false"}) + pass + pass +@error_handling.group(invoke_without_command=True) +@click.pass_context +def enable(ctx): + """Administratively Enable BGP error handling""" + if ctx.invoked_subcommand is None: + config_db = ConfigDBConnector(host="127.0.0.1") + config_db.connect() + curr_mode = config_db.get_entry('BGP_ERROR_CFG_TABLE', "config").get('enable') + if (curr_mode != "true"): + cmd = 'sudo vtysh -c "configure terminal" -c "bgp error-handling enable"' + run_command(cmd) + config_db.set_entry("BGP_ERROR_CFG_TABLE", "config", {"enable": "true"}) + pass + pass # 'all' subcommand @shutdown.command()