Skip to content

Commit

Permalink
tools: fix reload script for bgp graceful-shutdown
Browse files Browse the repository at this point in the history
Global BGP configuration knob like 'bgp graceful-shutdown'
is not rendered properly via frr-reload script.
when the config line is rendered if happened to be post
router bgp config lines, frr end up rendering bgp gr-shut
under bgp instance config though global config knob is set.

Two fixes:
1) Move bgp global config line at the beginning of pending
config lines to add.

2) Skip adding bgp global config line in second pass of
frr-reload script run.

The second fix is required to avoid following scenario:
2022-08-30 20:40:53,397 DEBUG: Running Frr Config (Pass #0)

['bgp graceful-shutdown\n',
 'router bgp 65564\n timers bgp 3 9\n',
 'router bgp 65564\n bgp deterministic-med\n',

2022-08-30 20:40:54,042 DEBUG: Running Frr Config (Pass #1)

 'vrf mgmt\n',
 'router bgp 65564 vrf sym_1\n address-family l2vpn evpn\n',
 'bgp graceful-shutdown\n',   <<<<<<< reapp

%Failed: per-vrf graceful-shutdown config not permitted
  with global graceful-shutdown
line 97: Failure to communicate[13] to bgpd, line: bgp graceful-shutdown

[8816|bgpd] Configuration file[/etc/frr/frr.conf] processing failure: 13

Ticket: #3187405
Testing Done:

Add and remove 'bgp graceful-shutdown' config in
frr.conf and perform frr-reload.

Signed-off-by: Chirag Shah <chirag@nvidia.com>
  • Loading branch information
chiragshah6 authored and donaldsharp committed Dec 13, 2024
1 parent 3d6426e commit 0d05314
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tools/frr-reload.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,30 @@ def bgp_delete_inst_move_line(lines_to_del):
lines_to_del.append((ctx_keys, line))


def bgp_move_global_cfg_line_to_add(lines_to_add):

# Move global bgp config lines like 'bgp graceful-shutdown'
# at the begining of the config line so they do not appear
# after router bgp sets of config lines as it may turn out
# the config line is applied at bgp instance level.

index = 0
lines_to_insert = []

for ctx_keys, line in lines_to_add:
if (
ctx_keys[0].startswith("bgp graceful-shutdown")
and not line
):
lines_to_add.remove((ctx_keys, line))
lines_to_insert.append((ctx_keys, line))

for ctx_keys, line in lines_to_insert:
lines_to_add.insert(index, ((ctx_keys, line)))

return lines_to_add


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
Expand Down Expand Up @@ -922,6 +946,7 @@ def bgp_delete_move_lines(lines_to_add, lines_to_del):
# config line to the end of the lines_to_del list.

bgp_delete_nbr_remote_as_line(lines_to_add)
bgp_move_global_cfg_line_to_add(lines_to_add)

del_dict = dict()
del_nbr_dict = dict()
Expand Down Expand Up @@ -2454,6 +2479,13 @@ def is_evpn_enabled():
if x == 1 and ctx_keys[0].startswith("no "):
continue

# Also, do not run bgp global config knob in second run
# as it may end being in different vtysh context.
if x == 1:
if ctx_keys[0].startswith("no ") or \
ctx_keys[0].startswith("bgp graceful-shutdown"):
continue

cmd = "\n".join(lines_to_config(ctx_keys, line, False)) + "\n"
lines_to_configure.append(cmd)

Expand Down

0 comments on commit 0d05314

Please sign in to comment.