Skip to content

Commit

Permalink
Merge pull request #5608 from dslicenc/frr-reload-deletes
Browse files Browse the repository at this point in the history
tools: improve frr-reload delete performance for some commands
  • Loading branch information
ton31337 authored Jan 16, 2020
2 parents 354620b + 6024e56 commit c49bafc
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tools/frr-reload.py
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,16 @@ def ignore_delete_re_add_lines(lines_to_add, lines_to_del):
lines_to_del_to_del.append((ctx_keys, route_target_export_line))
lines_to_add_to_del.append((ctx_keys, route_target_both_line))

# Deleting static routes under a vrf can lead to time-outs if each is sent
# as separate vtysh -c commands. Change them from being in lines_to_del and
# put the "no" form in lines_to_add
if ctx_keys[0].startswith('vrf ') and line:
if (line.startswith('ip route') or
line.startswith('ipv6 route')):
add_cmd = ('no ' + line)
lines_to_add.append((ctx_keys, add_cmd))
lines_to_del_to_del.append((ctx_keys, line))

if not deleted:
found_add_line = line_exist(lines_to_add, ctx_keys, line)

Expand Down Expand Up @@ -1054,6 +1064,19 @@ def compare_context_objects(newconf, running):
for line in running_ctx.lines:
lines_to_del.append((running_ctx_keys, line))

# Some commands can happen at higher counts that make
# doing vtysh -c inefficient (and can time out.) For
# these commands, instead of adding them to lines_to_del,
# add the "no " version to lines_to_add.
elif (running_ctx_keys[0].startswith('ip route') or
running_ctx_keys[0].startswith('ipv6 route') or
running_ctx_keys[0].startswith('access-list') or
running_ctx_keys[0].startswith('ipv6 access-list') or
running_ctx_keys[0].startswith('ip prefix-list') or
running_ctx_keys[0].startswith('ipv6 prefix-list')):
add_cmd = ('no ' + running_ctx_keys[0],)
lines_to_add.append((add_cmd, None))

# Non-global context
elif running_ctx_keys and not any("address-family" in key for key in running_ctx_keys):
lines_to_del.append((running_ctx_keys, None))
Expand Down Expand Up @@ -1392,6 +1415,11 @@ def vtysh_config_available(bindir, confdir):
if line == '!':
continue

# Don't run "no" commands twice since they can error
# out the second time due to first deletion
if x == 1 and ctx_keys[0].startswith('no '):
continue

cmd = line_for_vtysh_file(ctx_keys, line, False)
lines_to_configure.append(cmd)

Expand Down

0 comments on commit c49bafc

Please sign in to comment.