summaryrefslogtreecommitdiffstats
path: root/tools/frr-reload.py
diff options
context:
space:
mode:
authorChirag Shah <chirag@nvidia.com>2021-12-04 22:27:29 +0100
committerChirag Shah <chirag@nvidia.com>2022-04-23 21:49:47 +0200
commitd2acc328bd776f31638d957444ea610eb7e4d132 (patch)
tree8e29c477aa042fb63fc774c2b24d47e4cf48b1cc /tools/frr-reload.py
parentMerge pull request #11064 from opensourcerouting/fix/allow_only_euid_0_runnin... (diff)
downloadfrr-d2acc328bd776f31638d957444ea610eb7e4d132.tar.xz
frr-d2acc328bd776f31638d957444ea610eb7e4d132.zip
tools: fix bgp instances deletion in frr-reload
BGPd does not allow default instance deletion in presence of bgp vrf instance; frr-reload script fails if delete list contains default instance followed by vrf instance. Fix: frr-reload scans lines_to_delete to look for 'router bgp' and 'router bgp vrf ...' line. If both are present switch the order to delete bgp vrf instance(s) than default instance at the end. Testing Done: Before: INFO: Loading Config object from file /etc/frr/frr.conf INFO: Loading Config object from vtysh show running INFO: Failed to execute no router bgp 40201 <-- Failed to delete INFO: Failed to execute no router bgp INFO: Failed to execute no router ERROR: "no router" we failed to remove this command ERROR: % Cannot delete default BGP instance. Dependent VRF instances exist INFO: Executed "no router bgp 40201 vrf bgp-test" <-- vrf instance deleted INFO: Loading Config object from vtysh show running After: order of deletion switched INFO: Loading Config object from file /etc/frr/frr.conf INFO: Loading Config object from vtysh show running INFO: Executed "no router bgp 40201 vrf bgp-test" INFO: Executed "no router bgp 40201" INFO: Loading Config object from vtysh show running Signed-off-by: Chirag Shah <chirag@nvidia.com>
Diffstat (limited to 'tools/frr-reload.py')
-rwxr-xr-xtools/frr-reload.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/tools/frr-reload.py b/tools/frr-reload.py
index 4f30f7fbd..8749215b1 100755
--- a/tools/frr-reload.py
+++ b/tools/frr-reload.py
@@ -763,6 +763,38 @@ def check_for_exit_vrf(lines_to_add, lines_to_del):
return (lines_to_add, lines_to_del)
+def bgp_delete_inst_move_line(lines_to_del):
+ # Deletion of bgp default inst followed by
+ # bgp vrf inst leads to issue of default
+ # instance can not be removed.
+ # Move the bgp default instance line to end.
+ bgp_defult_inst = False
+ bgp_vrf_inst = False
+
+ for (ctx_keys, line) in lines_to_del:
+ # Find bgp default inst
+ if (
+ ctx_keys[0].startswith("router bgp")
+ and not line
+ and "vrf" not in ctx_keys[0]
+ ):
+ bgp_defult_inst = True
+ # Find bgp vrf inst
+ if ctx_keys[0].startswith("router bgp") and not line and "vrf" in ctx_keys[0]:
+ bgp_vrf_inst = True
+
+ if bgp_defult_inst and bgp_vrf_inst:
+ for (ctx_keys, line) in lines_to_del:
+ # move bgp default inst to end
+ if (
+ ctx_keys[0].startswith("router bgp")
+ and not line
+ and "vrf" not in ctx_keys[0]
+ ):
+ lines_to_del.remove((ctx_keys, line))
+ lines_to_del.append((ctx_keys, line))
+
+
def bgp_delete_nbr_remote_as_line(lines_to_add):
# Handle deletion of neighbor <nbr> remote-as line from
# lines_to_add if the nbr is configured with peer-group and
@@ -948,6 +980,7 @@ def delete_move_lines(lines_to_add, lines_to_del):
found_pg_del_cmd = True
if found_pg_del_cmd == False:
+ bgp_delete_inst_move_line(lines_to_del)
return (lines_to_add, lines_to_del)
for (ctx_keys, line) in lines_to_del_to_app:
@@ -1001,6 +1034,8 @@ def delete_move_lines(lines_to_add, lines_to_del):
lines_to_del.remove((ctx_keys, line))
lines_to_del.append((ctx_keys, line))
+ bgp_delete_inst_move_line(lines_to_del)
+
return (lines_to_add, lines_to_del)