Blame SOURCES/0011-reload-bfd-profile.patch

dfe9c0
diff --git a/tools/frr-reload.py b/tools/frr-reload.py
dfe9c0
index 9979c8b..1c24f90 100755
dfe9c0
--- a/tools/frr-reload.py
dfe9c0
+++ b/tools/frr-reload.py
dfe9c0
@@ -785,6 +785,48 @@ def line_exist(lines, target_ctx_keys, target_line, exact_match=True):
dfe9c0
                     return True
dfe9c0
     return False
dfe9c0
 
dfe9c0
+def delete_bgp_bfd(lines_to_add, lines_to_del):
dfe9c0
+    """
dfe9c0
+    When 'neighbor <peer> bfd profile <profile>' is present without a
dfe9c0
+    'neighbor <peer> bfd' line, FRR explicitily adds it to the running
dfe9c0
+    configuration. When the new configuration drops the bfd profile
dfe9c0
+    line, the user's intent is to delete any bfd configuration on the
dfe9c0
+    peer. On reload, deleting the bfd profile line after the bfd line
dfe9c0
+    will re-enable BFD with the default BFD profile. Move the bfd line
dfe9c0
+    to the end, if it exists in the new configuration.
dfe9c0
+
dfe9c0
+    Example:
dfe9c0
+
dfe9c0
+     neighbor 10.0.0.1 bfd
dfe9c0
+     neighbor 10.0.0.1 bfd profile bfd-profile-1
dfe9c0
+
dfe9c0
+     Move to end:
dfe9c0
+     neighbor 10.0.0.1 bfd profile bfd-profile-1
dfe9c0
+     ...
dfe9c0
+
dfe9c0
+     neighbor 10.0.0.1 bfd
dfe9c0
+
dfe9c0
+    """
dfe9c0
+    lines_to_del_to_app = []
dfe9c0
+    for (ctx_keys, line) in lines_to_del:
dfe9c0
+        if (
dfe9c0
+            ctx_keys[0].startswith("router bgp")
dfe9c0
+            and line
dfe9c0
+            and line.startswith("neighbor ")
dfe9c0
+        ):
dfe9c0
+            # 'no neighbor [peer] bfd>'
dfe9c0
+            nb_bfd = "neighbor (\S+) .*bfd$"
dfe9c0
+            re_nb_bfd = re.search(nb_bfd, line)
dfe9c0
+            if re_nb_bfd:
dfe9c0
+                lines_to_del_to_app.append((ctx_keys, line))
dfe9c0
+
dfe9c0
+    for (ctx_keys, line) in lines_to_del_to_app:
dfe9c0
+        lines_to_del.remove((ctx_keys, line))
dfe9c0
+        lines_to_del.append((ctx_keys, line))
dfe9c0
+
dfe9c0
+    return (lines_to_add, lines_to_del)
dfe9c0
+
dfe9c0
+
dfe9c0
 def check_for_exit_vrf(lines_to_add, lines_to_del):
dfe9c0
 
dfe9c0
     # exit-vrf is a bit tricky.  If the new config is missing it but we
dfe9c0
@@ -1248,6 +1290,7 @@ def compare_context_objects(newconf, running):
dfe9c0
             for line in newconf_ctx.lines:
dfe9c0
                 lines_to_add.append((newconf_ctx_keys, line))
dfe9c0
 
dfe9c0
+    (lines_to_add, lines_to_del) = delete_bgp_bfd(lines_to_add, lines_to_del)
dfe9c0
     (lines_to_add, lines_to_del) = check_for_exit_vrf(lines_to_add, lines_to_del)
dfe9c0
     (lines_to_add, lines_to_del) = ignore_delete_re_add_lines(lines_to_add, lines_to_del)
dfe9c0
     (lines_to_add, lines_to_del) = ignore_unconfigurable_lines(lines_to_add, lines_to_del)
dfe9c0
diff --git a/bgpd/bgp_bfd.c b/bgpd/bgp_bfd.c
dfe9c0
index b566b0e..1bd6249 100644
dfe9c0
--- a/bgpd/bgp_bfd.c
dfe9c0
+++ b/bgpd/bgp_bfd.c
dfe9c0
@@ -686,9 +686,9 @@ void bgp_bfd_peer_config_write(struct vty *vty, struct peer *peer, char *addr)
dfe9c0
 
dfe9c0
 	if (!CHECK_FLAG(bfd_info->flags, BFD_FLAG_PARAM_CFG)
dfe9c0
 	    && (bfd_info->type == BFD_TYPE_NOT_CONFIGURED)) {
dfe9c0
-		vty_out(vty, " neighbor %s bfd", addr);
dfe9c0
+		vty_out(vty, " neighbor %s bfd\n", addr);
dfe9c0
 		if (bfd_info->profile[0])
dfe9c0
-			vty_out(vty, " profile %s", bfd_info->profile);
dfe9c0
+			vty_out(vty, " neighbor %s bfd profile %s", addr, bfd_info->profile);
dfe9c0
 		vty_out(vty, "\n");
dfe9c0
 	}
dfe9c0