]> git.puffer.fish Git - mirror/frr.git/commitdiff
tools: fix more frr-reload vrf static errors 6764/head
authorDon Slice <dslice@cumulusnetworks.com>
Tue, 14 Jul 2020 14:39:06 +0000 (14:39 +0000)
committerDon Slice <dslice@nvidia.com>
Fri, 17 Jul 2020 16:45:54 +0000 (16:45 +0000)
Reported that in certain config changes, a static intended for the
default table would be duplicated into a vrf context.  Determined
that we still weren't keeping or adding the exit-vrf command when
necessary to keep the contexts straight.  Added logic to look for
the failing circumstances and add or remove the delete of the
exit-vrf command as needed.

Signed-off-by: Don Slice <dslice@nvidia.com>
tools/frr-reload.py

index 9e86cf2156784dcfac2111daf2c189590952f719..4c637d84bc8acd3be6389c06c635c4e4602bf546 100755 (executable)
@@ -729,6 +729,36 @@ def line_exist(lines, target_ctx_keys, target_line, exact_match=True):
                     return True
     return False
 
+def check_for_exit_vrf(lines_to_add, lines_to_del):
+
+    # exit-vrf is a bit tricky.  If the new config is missing it but we
+    # have configs under a vrf, we need to add it at the end to do the
+    # right context changes.  If exit-vrf exists in both the running and
+    # new config, we cannot delete it or it will break context changes.
+    add_exit_vrf = False
+    index = 0
+
+    for (ctx_keys, line) in lines_to_add:
+        if add_exit_vrf == True:
+            if ctx_keys[0] != prior_ctx_key:
+                insert_key=(prior_ctx_key),
+                lines_to_add.insert(index, ((insert_key, "exit-vrf")))
+                add_exit_vrf = False
+
+        if ctx_keys[0].startswith('vrf') and line:
+            if line is not "exit-vrf":
+                add_exit_vrf = True
+                prior_ctx_key = (ctx_keys[0])
+            else:
+                add_exit_vrf = False
+        index+=1
+
+    for (ctx_keys, line) in lines_to_del:
+        if line == "exit-vrf":
+            if (line_exist(lines_to_add, ctx_keys, line)):
+                lines_to_del.remove((ctx_keys, line))
+
+    return (lines_to_add, lines_to_del)
 
 def ignore_delete_re_add_lines(lines_to_add, lines_to_del):
 
@@ -1156,6 +1186,7 @@ def compare_context_objects(newconf, running):
             for line in newconf_ctx.lines:
                 lines_to_add.append((newconf_ctx_keys, line))
 
+    (lines_to_add, lines_to_del) = check_for_exit_vrf(lines_to_add, lines_to_del)
     (lines_to_add, lines_to_del) = ignore_delete_re_add_lines(lines_to_add, lines_to_del)
     (lines_to_add, lines_to_del) = ignore_unconfigurable_lines(lines_to_add, lines_to_del)