From c5af4d398a77aafc743579f68603f4e30ff1bc20 Mon Sep 17 00:00:00 2001 From: fett0 Date: Fri, 21 Apr 2023 18:07:16 +0000 Subject: static: T5161: add BFD monitoring for static routes --- data/templates/frr/static_routes_macro.j2 | 7 ++++- .../include/static/static-route-bfd.xml.i | 32 ++++++++++++++++++++++ .../include/static/static-route.xml.i | 1 + op-mode-definitions/show-bfd.xml.in | 13 +++++++++ smoketest/scripts/cli/test_protocols_static.py | 11 ++++++++ 5 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 interface-definitions/include/static/static-route-bfd.xml.i diff --git a/data/templates/frr/static_routes_macro.j2 b/data/templates/frr/static_routes_macro.j2 index 1c64ac58b..8afd4a68a 100644 --- a/data/templates/frr/static_routes_macro.j2 +++ b/data/templates/frr/static_routes_macro.j2 @@ -18,7 +18,12 @@ {% endif %} {% if prefix_config.next_hop is vyos_defined and prefix_config.next_hop is not none %} {% for next_hop, next_hop_config in prefix_config.next_hop.items() if next_hop_config.disable is not defined %} -{{ ip_ipv6 }} route {{ prefix }} {{ next_hop }} {{ next_hop_config.interface if next_hop_config.interface is vyos_defined }} {{ next_hop_config.distance if next_hop_config.distance is vyos_defined }} {{ 'nexthop-vrf ' ~ next_hop_config.vrf if next_hop_config.vrf is vyos_defined }} {{ 'table ' ~ table if table is vyos_defined }} +{{ ip_ipv6 }} route {{ prefix }} {{ next_hop }} {{ next_hop_config.interface if next_hop_config.interface is vyos_defined }} {{ next_hop_config.distance if next_hop_config.distance is vyos_defined }} {{ 'nexthop-vrf ' ~ next_hop_config.vrf if next_hop_config.vrf is vyos_defined }} {{ 'bfd profile ' ~ next_hop_config.bfd.profile if next_hop_config.bfd.profile is vyos_defined }} {{ 'table ' ~ table if table is vyos_defined }} +{% if next_hop_config.bfd.multi_hop.source is vyos_defined %} +{% for source, source_config in next_hop_config.bfd.multi_hop.source.items() %} +{{ ip_ipv6 }} route {{ prefix }} {{ next_hop }} bfd multi-hop source {{ source }} profile {{ source_config.profile }} +{% endfor %} +{% endif %} {% endfor %} {% endif %} {% endmacro %} diff --git a/interface-definitions/include/static/static-route-bfd.xml.i b/interface-definitions/include/static/static-route-bfd.xml.i new file mode 100644 index 000000000..dad8272c4 --- /dev/null +++ b/interface-definitions/include/static/static-route-bfd.xml.i @@ -0,0 +1,32 @@ + + + + BFD monitoring + + + #include + + + Use BFD multi hop session + + + + + Use source for BFD session + + ipv4 + IPv4 source + + + + + + + #include + + + + + + + \ No newline at end of file diff --git a/interface-definitions/include/static/static-route.xml.i b/interface-definitions/include/static/static-route.xml.i index 268cfa005..29921a731 100644 --- a/interface-definitions/include/static/static-route.xml.i +++ b/interface-definitions/include/static/static-route.xml.i @@ -51,6 +51,7 @@ #include #include #include + #include diff --git a/op-mode-definitions/show-bfd.xml.in b/op-mode-definitions/show-bfd.xml.in index 39e42e6ec..87d672e04 100644 --- a/op-mode-definitions/show-bfd.xml.in +++ b/op-mode-definitions/show-bfd.xml.in @@ -49,6 +49,19 @@ + + + Show route Routing Table + + + + + Showing BFD monitored static routes + + vtysh -c "show bfd static route" + + + diff --git a/smoketest/scripts/cli/test_protocols_static.py b/smoketest/scripts/cli/test_protocols_static.py index 706663ce5..c21dfc8be 100755 --- a/smoketest/scripts/cli/test_protocols_static.py +++ b/smoketest/scripts/cli/test_protocols_static.py @@ -31,6 +31,8 @@ routes = { '192.0.2.100' : { 'distance' : '100' }, '192.0.2.110' : { 'distance' : '110', 'interface' : 'eth0' }, '192.0.2.120' : { 'distance' : '120', 'disable' : '' }, + '192.0.2.130' : { 'bfd' : '' }, + '192.0.2.140' : { 'bfd_source' : '192.0.2.10' }, }, 'interface' : { 'eth0' : { 'distance' : '130' }, @@ -117,6 +119,7 @@ class TestProtocolsStatic(VyOSUnitTestSHIM.TestCase): self.cli_commit() def test_01_static(self): + bfd_profile = 'vyos-test' for route, route_config in routes.items(): route_type = 'route' if is_ipv6(route): @@ -133,6 +136,10 @@ class TestProtocolsStatic(VyOSUnitTestSHIM.TestCase): self.cli_set(base + ['next-hop', next_hop, 'interface', next_hop_config['interface']]) if 'vrf' in next_hop_config: self.cli_set(base + ['next-hop', next_hop, 'vrf', next_hop_config['vrf']]) + if 'bfd' in next_hop_config: + self.cli_set(base + ['next-hop', next_hop, 'bfd', 'profile', bfd_profile ]) + if 'bfd_source' in next_hop_config: + self.cli_set(base + ['next-hop', next_hop, 'bfd', 'multi-hop','source', next_hop_config['bfd_source'], 'profile', bfd_profile]) if 'interface' in route_config: @@ -187,6 +194,10 @@ class TestProtocolsStatic(VyOSUnitTestSHIM.TestCase): tmp += ' ' + next_hop_config['distance'] if 'vrf' in next_hop_config: tmp += ' nexthop-vrf ' + next_hop_config['vrf'] + if 'bfd' in next_hop_config: + tmp += ' bfd profile ' + bfd_profile + if 'bfd_source' in next_hop_config: + tmp += ' bfd multi-hop source ' + next_hop_config['bfd_source'] + 'profile' + bfd_profile if 'disable' in next_hop_config: self.assertNotIn(tmp, frrconfig) -- cgit v1.2.3 From 4c0164755a5d7c74c35d9cef1442b77301ca6366 Mon Sep 17 00:00:00 2001 From: fett0 Date: Mon, 24 Apr 2023 14:44:12 +0000 Subject: static: T5161: add BFD monitoring for static IPv6 routes --- interface-definitions/include/static/static-route-bfd.xml.i | 9 +++++++-- interface-definitions/include/static/static-route6.xml.i | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/interface-definitions/include/static/static-route-bfd.xml.i b/interface-definitions/include/static/static-route-bfd.xml.i index dad8272c4..a05a08d12 100644 --- a/interface-definitions/include/static/static-route-bfd.xml.i +++ b/interface-definitions/include/static/static-route-bfd.xml.i @@ -13,12 +13,17 @@ Use source for BFD session - + ipv4 - IPv4 source + IPv4 source address + + + ipv6 + IPv6 source address + diff --git a/interface-definitions/include/static/static-route6.xml.i b/interface-definitions/include/static/static-route6.xml.i index 1f8d54108..a83cc230b 100644 --- a/interface-definitions/include/static/static-route6.xml.i +++ b/interface-definitions/include/static/static-route6.xml.i @@ -50,6 +50,7 @@ #include #include #include + #include -- cgit v1.2.3 From 8f3c9b4a803f5e5c7baa60ecc21a24c57eefc70b Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Sat, 29 Apr 2023 08:15:37 +0200 Subject: smoketest: T5161: add missing whitespace in BFD profile during validation --- smoketest/scripts/cli/test_protocols_static.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/smoketest/scripts/cli/test_protocols_static.py b/smoketest/scripts/cli/test_protocols_static.py index c21dfc8be..fbf336f1a 100755 --- a/smoketest/scripts/cli/test_protocols_static.py +++ b/smoketest/scripts/cli/test_protocols_static.py @@ -139,7 +139,7 @@ class TestProtocolsStatic(VyOSUnitTestSHIM.TestCase): if 'bfd' in next_hop_config: self.cli_set(base + ['next-hop', next_hop, 'bfd', 'profile', bfd_profile ]) if 'bfd_source' in next_hop_config: - self.cli_set(base + ['next-hop', next_hop, 'bfd', 'multi-hop','source', next_hop_config['bfd_source'], 'profile', bfd_profile]) + self.cli_set(base + ['next-hop', next_hop, 'bfd', 'multi-hop', 'source', next_hop_config['bfd_source'], 'profile', bfd_profile]) if 'interface' in route_config: @@ -197,7 +197,7 @@ class TestProtocolsStatic(VyOSUnitTestSHIM.TestCase): if 'bfd' in next_hop_config: tmp += ' bfd profile ' + bfd_profile if 'bfd_source' in next_hop_config: - tmp += ' bfd multi-hop source ' + next_hop_config['bfd_source'] + 'profile' + bfd_profile + tmp += ' bfd multi-hop source ' + next_hop_config['bfd_source'] + ' profile ' + bfd_profile if 'disable' in next_hop_config: self.assertNotIn(tmp, frrconfig) -- cgit v1.2.3 From 98a072a8d8d95a8a15353b0b771d1724a5520353 Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Sat, 29 Apr 2023 08:20:13 +0200 Subject: smoketest: T5161: add IPv6 static route BFD tests --- smoketest/scripts/cli/test_protocols_static.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/smoketest/scripts/cli/test_protocols_static.py b/smoketest/scripts/cli/test_protocols_static.py index fbf336f1a..275f1a1df 100755 --- a/smoketest/scripts/cli/test_protocols_static.py +++ b/smoketest/scripts/cli/test_protocols_static.py @@ -69,6 +69,8 @@ routes = { '2001:db8::1' : { 'distance' : '10' }, '2001:db8::2' : { 'distance' : '20', 'interface' : 'eth0' }, '2001:db8::3' : { 'distance' : '30', 'disable' : '' }, + '2001:db8::4' : { 'bfd' : '' }, + '2001:db8::5' : { 'bfd_source' : '2001:db8::ffff' }, }, 'interface' : { 'eth0' : { 'distance' : '40', 'vrf' : 'black' }, -- cgit v1.2.3