summaryrefslogtreecommitdiffstats
path: root/tools/frr-reload.py
diff options
context:
space:
mode:
authorChirag Shah <chirag@nvidia.com>2023-06-06 06:48:12 +0200
committerChirag Shah <chirag@nvidia.com>2023-06-06 07:22:27 +0200
commit9845c09d61a7e509bfae369648cb5f9893455ac4 (patch)
tree0b775be1e1a9f27d991edd6d0fc5e1b84e0f1e00 /tools/frr-reload.py
parentMerge pull request #13670 from donaldsharp/coverity_99 (diff)
downloadfrr-9845c09d61a7e509bfae369648cb5f9893455ac4.tar.xz
frr-9845c09d61a7e509bfae369648cb5f9893455ac4.zip
tools: fix list value remove in frr-reload
There might be a time element(s) from temporary list are removed more than once which leads to valueError in certain python3 version. commit-id 1543f58b5 did not handle valueError properly. This caused regression where prefix-list config leads to delete followed by add. The new fix should just pass the exception as value removal from list_to_add or list_to_del is best effort. This allows prefix-list config has no change then removes the lines from lines_to_del and lines_to_add properly. Ticket:#3490252 Testing: Configure prefix-list in frr.conf and perform multiple frr-reload. After first reload operatoin subsequent ones should not result in delete followed by add of the prefix-list but rather no-op operation. (Pdb) lines_to_add [(('ip prefix-list FOO permit 10.2.1.0/24',), None)] (Pdb) lines_to_del [(('ip prefix-list FOO seq 5 permit 10.2.1.0/24',), None), (('ip prefix-list FOO seq 10 permit 10.2.1.0/24',), None)] (Pdb) lines_to_del_to_del [(('ip prefix-list FOO seq 5 permit 10.2.1.0/24',), None), (('ip prefix-list FOO seq 10 permit 10.2.1.0/24',), None)] (Pdb) lines_to_add_to_del [(('ip prefix-list FOO permit 10.2.1.0/24',), None), (('ip prefix-list FOO permit 10.2.1.0/24',), None)] (Pdb) c > /usr/lib/frr/frr-reload.py(1562)ignore_delete_re_add_lines() -> return (lines_to_add, lines_to_del) (Pdb) lines_to_add [] (Pdb) lines_to_del [] Signed-off-by: Chirag Shah <chirag@nvidia.com>
Diffstat (limited to 'tools/frr-reload.py')
-rwxr-xr-xtools/frr-reload.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/tools/frr-reload.py b/tools/frr-reload.py
index 0e0aec983..c2be9f78e 100755
--- a/tools/frr-reload.py
+++ b/tools/frr-reload.py
@@ -1480,12 +1480,17 @@ def ignore_delete_re_add_lines(lines_to_add, lines_to_del):
lines_to_add_to_del.append((tmp_ctx_keys, line))
for (ctx_keys, line) in lines_to_del_to_del:
- if line is not None:
+ try:
lines_to_del.remove((ctx_keys, line))
+ except ValueError:
+ pass
for (ctx_keys, line) in lines_to_add_to_del:
- if line is not None:
+ try:
lines_to_add.remove((ctx_keys, line))
+ except ValueError:
+ pass
+
return (lines_to_add, lines_to_del)