Blame SOURCES/0008-bfd-reload.patch

17297e
From 46a2b560fa84c5f8ece8dbb82cbf355af675ad41 Mon Sep 17 00:00:00 2001
17297e
From: Rafael Zalamena <rzalamena@opensourcerouting.org>
17297e
Date: Tue, 19 Jan 2021 08:49:23 -0300
17297e
Subject: [PATCH] tools: fix frr-reload BFD profile support
17297e
17297e
Fix the handling of multiple BFD profiles by adding the appropriated
17297e
code to push/pop contexts inside BFD configuration node.
17297e
17297e
Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
17297e
---
17297e
 tools/frr-reload.py | 28 ++++++++++++++++++++++++++++
17297e
 1 file changed, 28 insertions(+)
17297e
17297e
diff --git a/tools/frr-reload.py b/tools/frr-reload.py
17297e
index da005b6f874..ca6fe81f007 100755
17297e
--- a/tools/frr-reload.py
17297e
+++ b/tools/frr-reload.py
17297e
@@ -533,6 +533,18 @@ def load_contexts(self):
17297e
             if line.startswith('!') or line.startswith('#'):
17297e
                 continue
17297e
 
17297e
+            if (len(ctx_keys) == 2
17297e
+                and ctx_keys[0].startswith('bfd')
17297e
+                and ctx_keys[1].startswith('profile ')
17297e
+                and line == 'end'):
17297e
+                log.debug('LINE %-50s: popping from sub context, %-50s', line, ctx_keys)
17297e
+
17297e
+                if main_ctx_key:
17297e
+                    self.save_contexts(ctx_keys, current_context_lines)
17297e
+                    ctx_keys = copy.deepcopy(main_ctx_key)
17297e
+                    current_context_lines = []
17297e
+                    continue
17297e
+
17297e
             # one line contexts
17297e
             # there is one exception though: ldpd accepts a 'router-id' clause
17297e
             # as part of its 'mpls ldp' config context. If we are processing
17297e
@@ -649,6 +661,22 @@ def load_contexts(self):
17297e
                 log.debug('LINE %-50s: entering sub-sub-context, append to ctx_keys', line)
17297e
                 ctx_keys.append(line)
17297e
 
17297e
+            elif (
17297e
+                line.startswith('profile ')
17297e
+                and len(ctx_keys) == 1
17297e
+                and ctx_keys[0].startswith('bfd')
17297e
+            ):
17297e
+
17297e
+                # Save old context first
17297e
+                self.save_contexts(ctx_keys, current_context_lines)
17297e
+                current_context_lines = []
17297e
+                main_ctx_key = copy.deepcopy(ctx_keys)
17297e
+                log.debug(
17297e
+                    "LINE %-50s: entering BFD profile sub-context, append to ctx_keys",
17297e
+                    line
17297e
+                )
17297e
+                ctx_keys.append(line)
17297e
+
17297e
             else:
17297e
                 # Continuing in an existing context, add non-commented lines to it
17297e
                 current_context_lines.append(line)
17297e