]> git.puffer.fish Git - matthieu/frr.git/commitdiff
tools: fix pim interface config deletion
authorChirag Shah <chirag@nvidia.com>
Thu, 29 Jun 2023 16:55:12 +0000 (09:55 -0700)
committerChirag Shah <chirag@nvidia.com>
Fri, 30 Jun 2023 01:09:05 +0000 (18:09 -0700)
When no ip pim is performed subsequent pim related
configs under the interface also implicitly deleted.

When doing this via frr-reload requires to remove any
explicit no ip pim <blah> lines so delete list.

Testing Done:

running-config:
interface lo
 ip pim
 ip pim use-source 6.0.0.1
exit

frr.conf:
remove two pim config lines.
interface lo
exit

Before fix:
2023-06-29 23:44:26,062  INFO: Failed to execute interface lo  no ip pim use-source 6.0.0.1
2023-06-29 23:44:26,142  INFO: Failed to execute interface lo  no ip pim use-source
2023-06-29 23:44:26,221  INFO: Executed "interface lo  no ip pim"

After fix:
Only no ip pim executed and rest of the other lines removed from delete
list.

2023-06-30 01:07:32,618  INFO: Executed "interface lo  no ip pim"

Signed-off-by: Chirag Shah <chirag@nvidia.com>
tools/frr-reload.py

index c2be9f78eb0814c75664356e2666db290c03a593..69a986ba0d00897920bb4566679ea32f17947f1f 100755 (executable)
@@ -891,7 +891,7 @@ def bgp_remove_neighbor_cfg(lines_to_del, del_nbr_dict):
         lines_to_del.remove((ctx_keys, line))
 
 
-def delete_move_lines(lines_to_add, lines_to_del):
+def bgp_delete_move_lines(lines_to_add, lines_to_del):
     # This method handles deletion of bgp peer group config.
     # The objective is to delete config lines related to peers
     # associated with the peer-group and move the peer-group
@@ -1066,6 +1066,39 @@ def delete_move_lines(lines_to_add, lines_to_del):
     return (lines_to_add, lines_to_del)
 
 
+def pim_delete_move_lines(lines_to_add, lines_to_del):
+
+    # Under interface context, if 'no ip pim' is present
+    # remove subsequent 'no ip pim <blah>' options as it
+    # they are implicitly deleted by 'no ip pim'.
+    # Remove all such depdendent options from delete
+    # pending list.
+    pim_disable = False
+
+    for (ctx_keys, line) in lines_to_del:
+        if ctx_keys[0].startswith("interface") and line and line == "ip pim":
+            pim_disable = True
+
+    if pim_disable:
+        for (ctx_keys, line) in lines_to_del:
+            if (
+                ctx_keys[0].startswith("interface")
+                and line
+                and line.startswith("ip pim ")
+            ):
+                lines_to_del.remove((ctx_keys, line))
+
+    return (lines_to_add, lines_to_del)
+
+
+def delete_move_lines(lines_to_add, lines_to_del):
+
+    lines_to_add, lines_to_del = bgp_delete_move_lines(lines_to_add, lines_to_del)
+    lines_to_add, lines_to_del = pim_delete_move_lines(lines_to_add, lines_to_del)
+
+    return (lines_to_add, lines_to_del)
+
+
 def ignore_delete_re_add_lines(lines_to_add, lines_to_del):
 
     # Quite possibly the most confusing (while accurate) variable names in history