From 692ce87393de9497a7821e9e0856ff70a7973ff6 Mon Sep 17 00:00:00 2001
From: Paul Manley <paul.manley@wholefoods.com>
Date: Thu, 9 Jul 2020 11:21:16 -0500
Subject: [PATCH 1/2] tools: create sub-context for bfd peers

add lines starting with 'peer' to the list of sub-contexts that are handled by frr-reload.py.

https://github.com/FRRouting/frr/issues/6511#issuecomment-655163833

Signed-off-by: Paul Manley <paul.manley@wholefoods.com>
(cherry picked from commit 1c23a0aaa1c5d20af50af75b070e93e1eff21222)
---
 tools/frr-reload.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/frr-reload.py b/tools/frr-reload.py
index d4020cdfc9..e9641b2b13 100755
--- a/tools/frr-reload.py
+++ b/tools/frr-reload.py
@@ -496,6 +496,7 @@ def load_contexts(self):
                   line.startswith("vnc defaults") or
                   line.startswith("vnc l2-group") or
                   line.startswith("vnc nve-group") or
+                  line.startswith("peer") or
                   line.startswith("member pseudowire")):
                 main_ctx_key = []
 

From 2604086c3d9face0aca2497a982782c865bb2b59 Mon Sep 17 00:00:00 2001
From: Paul Manley <paul.manley@wholefoods.com>
Date: Thu, 9 Jul 2020 11:25:34 -0500
Subject: [PATCH 2/2] vtysh: properly exit BFD_PEER_NODE when marking file

vtysh needs to be aware of how to properly exit a bfd peer when subsequent commands only succeed in a higher context.

https://github.com/FRRouting/frr/issues/6511#issuecomment-656166206

Signed-off-by: Paul Manley <paul.manley@wholefoods.com>
(cherry picked from commit b727c12aabf1afc2b6e33f8590c9786e349e4fcb)
---
 vtysh/vtysh.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c
index 15ec866fc9..4fdf68c0e6 100644
--- a/vtysh/vtysh.c
+++ b/vtysh/vtysh.c
@@ -809,6 +809,9 @@ int vtysh_mark_file(const char *filename)
 			} else if ((prev_node == KEYCHAIN_KEY_NODE)
 				   && (tried == 1)) {
 				vty_out(vty, "exit\n");
+			} else if ((prev_node == BFD_PEER_NODE)
+				   && (tried == 1)) {
+				vty_out(vty, "exit\n");
 			} else if (tried) {
 				vty_out(vty, "end\n");
 			}
