Blame SOURCES/0010-bfd-reload.patch

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