Blame SOURCES/0010-bfd-reload.patch

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