Skip to content

Commit

Permalink
Merge pull request #2783 from vyos/mergify/bp/sagitta/pr-2263
Browse files Browse the repository at this point in the history
T5530: isis: Adding loop free alternate feature (backport #2263)
  • Loading branch information
c-po committed Jan 10, 2024
2 parents 7a03e2b + 2d778c4 commit d7c50c8
Show file tree
Hide file tree
Showing 9 changed files with 353 additions and 3 deletions.
42 changes: 42 additions & 0 deletions data/templates/frr/isisd.frr.j2
Expand Up @@ -165,6 +165,48 @@ advertise-passive-only
{% endfor %}
{% endfor %}
{% endif %}
{% if fast_reroute.lfa is vyos_defined %}
{% if fast_reroute.lfa.local is vyos_defined %}
{% if fast_reroute.lfa.local.load_sharing.disable.level_1 is vyos_defined %}
fast-reroute load-sharing disable level-1
{% elif fast_reroute.lfa.local.load_sharing.disable.level_2 is vyos_defined %}
fast-reroute load-sharing disable level-2
{% elif fast_reroute.lfa.local.load_sharing.disable is vyos_defined %}
fast-reroute load-sharing disable
{% endif %}
{% if fast_reroute.lfa.local.priority_limit is vyos_defined %}
{% for priority, priority_limit_options in fast_reroute.lfa.local.priority_limit.items() %}
{% for level in priority_limit_options %}
fast-reroute priority-limit {{ priority }} {{ level | replace('_', '-') }}
{% endfor %}
{% endfor %}
{% endif %}
{% if fast_reroute.lfa.local.tiebreaker is vyos_defined %}
{% for tiebreaker, tiebreaker_options in fast_reroute.lfa.local.tiebreaker.items() %}
{% for index, index_options in tiebreaker_options.items() %}
{% for index_value, index_value_options in index_options.items() %}
{% for level in index_value_options %}
fast-reroute lfa tiebreaker {{ tiebreaker | replace('_', '-') }} index {{ index_value }} {{ level | replace('_', '-') }}
{% endfor %}
{% endfor %}
{% endfor %}
{% endfor %}
{% endif %}
{% endif %}
{% if fast_reroute.lfa.remote.prefix_list is vyos_defined %}
{% for prefix_list, prefix_list_options in fast_reroute.lfa.remote.prefix_list.items() %}
{% if prefix_list_options.level_1 is vyos_defined %}
fast-reroute remote-lfa prefix-list {{ prefix_list }} level-1
{% endif %}
{% if prefix_list_options.level_2 is vyos_defined %}
fast-reroute remote-lfa prefix-list {{ prefix_list }} level-2
{% endif %}
{% if prefix_list is vyos_defined and prefix_list_options.level_1 is not vyos_defined and prefix_list_options.level_2 is not vyos_defined %}
fast-reroute remote-lfa prefix-list {{ prefix_list }}
{% endif %}
{% endfor %}
{% endif %}
{% endif %}
{% if redistribute.ipv4 is vyos_defined %}
{% for protocol, protocol_options in redistribute.ipv4.items() %}
{% for level, level_config in protocol_options.items() %}
Expand Down
13 changes: 13 additions & 0 deletions interface-definitions/include/isis/level-1-2-leaf.xml.i
@@ -0,0 +1,13 @@
<!-- include start from isis/level-1-2-leaf.xml.i -->
<leafNode name="level-1">
<properties>
<help>Match on IS-IS level-1 routes</help>
<valueless/>
</properties>
</leafNode>
<leafNode name="level-2">
<properties>
<help>Match on IS-IS level-2 routes</help>
<valueless/>
</properties>
</leafNode>
128 changes: 128 additions & 0 deletions interface-definitions/include/isis/lfa-local.xml.i
@@ -0,0 +1,128 @@
<!-- include start from isis/lfa-local.xml.i -->
<node name="local">
<properties>
<help>Local loop free alternate options</help>
</properties>
<children>
<node name="load-sharing">
<properties>
<help>Load share prefixes across multiple backups</help>
</properties>
<children>
<node name="disable">
<properties>
<help>Disable load sharing</help>
</properties>
<children>
#include <include/isis/level-1-2-leaf.xml.i>
</children>
</node>
</children>
</node>
<node name="priority-limit">
<properties>
<help>Limit backup computation up to the prefix priority</help>
</properties>
<children>
<node name="medium">
<properties>
<help>Compute for critical, high, and medium priority prefixes</help>
</properties>
<children>
#include <include/isis/level-1-2-leaf.xml.i>
</children>
</node>
<node name="high">
<properties>
<help>Compute for critical, and high priority prefixes</help>
</properties>
<children>
#include <include/isis/level-1-2-leaf.xml.i>
</children>
</node>
<node name="critical">
<properties>
<help>Compute for critical priority prefixes only</help>
</properties>
<children>
#include <include/isis/level-1-2-leaf.xml.i>
</children>
</node>
</children>
</node>
<node name="tiebreaker">
<properties>
<help>Configure tiebreaker for multiple backups</help>
</properties>
<children>
<node name="downstream">
<properties>
<help>Prefer backup path via downstream node</help>
</properties>
<children>
<tagNode name="index">
<properties>
<help>Set preference order among tiebreakers</help>
<valueHelp>
<format>u32:1-255</format>
<description>The index integer value</description>
</valueHelp>
<constraint>
<validator name="numeric" argument="--range 1-255"/>
</constraint>
</properties>
<children>
#include <include/isis/level-1-2-leaf.xml.i>
</children>
</tagNode>
</children>
</node>
<node name="lowest-backup-metric">
<properties>
<help>Prefer backup path with lowest total metric</help>
</properties>
<children>
<tagNode name="index">
<properties>
<help>Set preference order among tiebreakers</help>
<valueHelp>
<format>u32:1-255</format>
<description>The index integer value</description>
</valueHelp>
<constraint>
<validator name="numeric" argument="--range 1-255"/>
</constraint>
</properties>
<children>
#include <include/isis/level-1-2-leaf.xml.i>
</children>
</tagNode>
</children>
</node>
<node name="node-protecting">
<properties>
<help>Prefer node protecting backup path</help>
</properties>
<children>
<tagNode name="index">
<properties>
<help>Set preference order among tiebreakers</help>
<valueHelp>
<format>u32:1-255</format>
<description>The index integer value</description>
</valueHelp>
<constraint>
<validator name="numeric" argument="--range 1-255"/>
</constraint>
</properties>
<children>
#include <include/isis/level-1-2-leaf.xml.i>
</children>
</tagNode>
</children>
</node>
</children>
</node>
</children>
</node>
<!-- include end -->
11 changes: 11 additions & 0 deletions interface-definitions/include/isis/lfa-protocol.xml.i
@@ -0,0 +1,11 @@
<!-- include start from isis/lfa-protocol.xml.i -->
<node name="lfa">
<properties>
<help>Loop free alternate functionality</help>
</properties>
<children>
#include <include/isis/lfa-remote.xml.i>
#include <include/isis/lfa-local.xml.i>
</children>
</node>
<!-- include end -->
28 changes: 28 additions & 0 deletions interface-definitions/include/isis/lfa-remote.xml.i
@@ -0,0 +1,28 @@
<!-- include start from isis/lfa-remote.xml.i -->
<node name="remote">
<properties>
<help>Remote loop free alternate options</help>
</properties>
<children>
<tagNode name="prefix-list">
<properties>
<help>Filter PQ node router ID based on prefix list</help>
<completionHelp>
<path>policy prefix-list</path>
</completionHelp>
<valueHelp>
<format>txt</format>
<description>Name of IPv4/IPv6 prefix-list</description>
</valueHelp>
<constraint>
#include <include/constraint/alpha-numeric-hyphen-underscore.xml.i>
</constraint>
<constraintErrorMessage>Name of prefix-list can only contain alpha-numeric letters, hyphen and underscores</constraintErrorMessage>
</properties>
<children>
#include <include/isis/level-1-2-leaf.xml.i>
</children>
</tagNode>
</children>
</node>
<!-- include end -->
Expand Up @@ -165,6 +165,14 @@
</properties>
</leafNode>
#include <include/isis/ldp-sync-protocol.xml.i>
<node name="fast-reroute">
<properties>
<help>IS-IS fast reroute configuration</help>
</properties>
<children>
#include <include/isis/lfa-protocol.xml.i>
</children>
</node>
<leafNode name="net">
<properties>
<help>A Network Entity Title for this process (ISO only)</help>
Expand Down
27 changes: 27 additions & 0 deletions op-mode-definitions/include/isis-common.xml.i
Expand Up @@ -17,6 +17,33 @@
</properties>
<command>${vyos_op_scripts_dir}/vtysh_wrapper.sh $@</command>
</tagNode>
<node name="fast-reroute">
<properties>
<help>Show IS-IS fast reroute/loop free alternate (lfa) information</help>
</properties>
<children>
<node name="summary">
<properties>
<help>Show summary of fast reroute/loop free alternate (lfa) information</help>
</properties>
<children>
<leafNode name="level-1">
<properties>
<help>Show level-1 specific fast reroute/loop free alternate (lfa) information</help>
</properties>
<command>${vyos_op_scripts_dir}/vtysh_wrapper.sh $@</command>
</leafNode>
<leafNode name="level-2">
<properties>
<help>Show level-2 specific fast reroute/loop free alternate (lfa) information</help>
</properties>
<command>${vyos_op_scripts_dir}/vtysh_wrapper.sh $@</command>
</leafNode>
</children>
<command>${vyos_op_scripts_dir}/vtysh_wrapper.sh $@</command>
</node>
</children>
</node>
<leafNode name="hostname">
<properties>
<help>Show IS-IS dynamic hostname mapping</help>
Expand Down
62 changes: 61 additions & 1 deletion smoketest/scripts/cli/test_protocols_isis.py
Expand Up @@ -329,5 +329,65 @@ def test_isis_08_ldp_sync(self):
self.assertIn(f' ipv6 router isis {domain}', tmp)
self.assertIn(f' no isis mpls ldp-sync', tmp)

def test_isis_09_lfa(self):
prefix_list = 'lfa-prefix-list-test-1'
prefix_list_address = '192.168.255.255/32'
interface = 'lo'

self.cli_set(base_path + ['net', net])
self.cli_set(base_path + ['interface', interface])
self.cli_set(['policy', 'prefix-list', prefix_list, 'rule', '1', 'action', 'permit'])
self.cli_set(['policy', 'prefix-list', prefix_list, 'rule', '1', 'prefix', prefix_list_address])

# Commit main ISIS changes
self.cli_commit()

# Add remote portion of LFA with prefix list with validation
for level in ['level-1', 'level-2']:
self.cli_set(base_path + ['fast-reroute', 'lfa', 'remote', 'prefix-list', prefix_list, level])
self.cli_commit()
tmp = self.getFRRconfig(f'router isis {domain}', daemon='isisd')
self.assertIn(f' net {net}', tmp)
self.assertIn(f' fast-reroute remote-lfa prefix-list {prefix_list} {level}', tmp)
self.cli_delete(base_path + ['fast-reroute'])
self.cli_commit()

# Add local portion of LFA load-sharing portion with validation
for level in ['level-1', 'level-2']:
self.cli_set(base_path + ['fast-reroute', 'lfa', 'local', 'load-sharing', 'disable', level])
self.cli_commit()
tmp = self.getFRRconfig(f'router isis {domain}', daemon='isisd')
self.assertIn(f' net {net}', tmp)
self.assertIn(f' fast-reroute load-sharing disable {level}', tmp)
self.cli_delete(base_path + ['fast-reroute'])
self.cli_commit()

# Add local portion of LFA priority-limit portion with validation
for priority in ['critical', 'high', 'medium']:
for level in ['level-1', 'level-2']:
self.cli_set(base_path + ['fast-reroute', 'lfa', 'local', 'priority-limit', priority, level])
self.cli_commit()
tmp = self.getFRRconfig(f'router isis {domain}', daemon='isisd')
self.assertIn(f' net {net}', tmp)
self.assertIn(f' fast-reroute priority-limit {priority} {level}', tmp)
self.cli_delete(base_path + ['fast-reroute'])
self.cli_commit()

# Add local portion of LFA tiebreaker portion with validation
index = '100'
for tiebreaker in ['downstream','lowest-backup-metric','node-protecting']:
for level in ['level-1', 'level-2']:
self.cli_set(base_path + ['fast-reroute', 'lfa', 'local', 'tiebreaker', tiebreaker, 'index', index, level])
self.cli_commit()
tmp = self.getFRRconfig(f'router isis {domain}', daemon='isisd')
self.assertIn(f' net {net}', tmp)
self.assertIn(f' fast-reroute lfa tiebreaker {tiebreaker} index {index} {level}', tmp)
self.cli_delete(base_path + ['fast-reroute'])
self.cli_commit()

# Clean up and remove prefix list
self.cli_delete(['policy', 'prefix-list', prefix_list])
self.cli_commit()

if __name__ == '__main__':
unittest.main(verbosity=2)
unittest.main(verbosity=2)

0 comments on commit d7c50c8

Please sign in to comment.