Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
tools: fix frr-reload BFD profile support
Fix the handling of multiple BFD profiles by adding the appropriated
code to push/pop contexts inside BFD configuration node.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
  • Loading branch information
rzalamena authored and idryzhov committed Jan 22, 2021
1 parent 7f6c81f commit 46a2b56
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tools/frr-reload.py
Expand Up @@ -533,6 +533,18 @@ def load_contexts(self):
if line.startswith('!') or line.startswith('#'):
continue

if (len(ctx_keys) == 2
and ctx_keys[0].startswith('bfd')
and ctx_keys[1].startswith('profile ')
and line == 'end'):
log.debug('LINE %-50s: popping from sub context, %-50s', line, ctx_keys)

if main_ctx_key:
self.save_contexts(ctx_keys, current_context_lines)
ctx_keys = copy.deepcopy(main_ctx_key)
current_context_lines = []
continue

# one line contexts
# there is one exception though: ldpd accepts a 'router-id' clause
# as part of its 'mpls ldp' config context. If we are processing
Expand Down Expand Up @@ -649,6 +661,22 @@ def load_contexts(self):
log.debug('LINE %-50s: entering sub-sub-context, append to ctx_keys', line)
ctx_keys.append(line)

elif (
line.startswith('profile ')
and len(ctx_keys) == 1
and ctx_keys[0].startswith('bfd')
):

# Save old context first
self.save_contexts(ctx_keys, current_context_lines)
current_context_lines = []
main_ctx_key = copy.deepcopy(ctx_keys)
log.debug(
"LINE %-50s: entering BFD profile sub-context, append to ctx_keys",
line
)
ctx_keys.append(line)

else:
# Continuing in an existing context, add non-commented lines to it
current_context_lines.append(line)
Expand Down

0 comments on commit 46a2b56

Please sign in to comment.