From 32db496ac1cb54fc46ad42f924803fd89bf92c75 Mon Sep 17 00:00:00 2001 From: Jonathan Voss Date: Tue, 24 Dec 2024 14:18:43 +0000 Subject: srv6: T6977: add srv6 encapsulation source-address --- data/templates/frr/zebra.segment_routing.frr.j2 | 27 ++++++++++++++-------- .../protocols_segment-routing.xml.in | 8 +++++++ op-mode-definitions/show-segment-routing.xml.in | 6 +++++ .../scripts/cli/test_protocols_segment-routing.py | 17 ++++++++++++++ 4 files changed, 49 insertions(+), 9 deletions(-) diff --git a/data/templates/frr/zebra.segment_routing.frr.j2 b/data/templates/frr/zebra.segment_routing.frr.j2 index 718d47d8f..a0bcc9210 100644 --- a/data/templates/frr/zebra.segment_routing.frr.j2 +++ b/data/templates/frr/zebra.segment_routing.frr.j2 @@ -1,23 +1,32 @@ ! -{% if srv6.locator is vyos_defined %} +{% if srv6 is vyos_defined %} segment-routing srv6 +{% if srv6.encapsulation is vyos_defined %} + encapsulation +{% if srv6.encapsulation.source_address is vyos_defined %} + source-address {{ srv6.encapsulation.source_address }} +{% endif %} + exit +{% endif %} +{% if srv6.locator is vyos_defined %} locators -{% for locator, locator_config in srv6.locator.items() %} +{% for locator, locator_config in srv6.locator.items() %} locator {{ locator }} -{% if locator_config.prefix is vyos_defined %} +{% if locator_config.prefix is vyos_defined %} prefix {{ locator_config.prefix }} block-len {{ locator_config.block_len }} node-len {{ locator_config.node_len }} func-bits {{ locator_config.func_bits }} -{% endif %} -{% if locator_config.behavior_usid is vyos_defined %} +{% endif %} +{% if locator_config.behavior_usid is vyos_defined %} behavior usid -{% endif %} -{% if locator_config.format is vyos_defined %} +{% endif %} +{% if locator_config.format is vyos_defined %} format {{ locator_config.format }} -{% endif %} +{% endif %} exit ! -{% endfor %} +{% endfor %} exit +{% endif %} ! exit ! diff --git a/interface-definitions/protocols_segment-routing.xml.in b/interface-definitions/protocols_segment-routing.xml.in index 075245936..32e61ebfc 100644 --- a/interface-definitions/protocols_segment-routing.xml.in +++ b/interface-definitions/protocols_segment-routing.xml.in @@ -61,6 +61,14 @@ Segment-Routing SRv6 configuration + + + Segment Routing SRv6 encapsulation + + + #include + + Segment-Routing SRv6 locators configuration diff --git a/op-mode-definitions/show-segment-routing.xml.in b/op-mode-definitions/show-segment-routing.xml.in index ebdb51a61..fc17e2f39 100644 --- a/op-mode-definitions/show-segment-routing.xml.in +++ b/op-mode-definitions/show-segment-routing.xml.in @@ -18,6 +18,12 @@ ${vyos_op_scripts_dir}/vtysh_wrapper.sh $@ + + + Verify SRv6 manager + + ${vyos_op_scripts_dir}/vtysh_wrapper.sh $@ + diff --git a/smoketest/scripts/cli/test_protocols_segment-routing.py b/smoketest/scripts/cli/test_protocols_segment-routing.py index a5c0d5983..85c25998c 100755 --- a/smoketest/scripts/cli/test_protocols_segment-routing.py +++ b/smoketest/scripts/cli/test_protocols_segment-routing.py @@ -158,6 +158,23 @@ class TestProtocolsSegmentRouting(VyOSUnitTestSHIM.TestCase): if 'usid' in locator_config: self.assertIn(' behavior usid', frrconfig) + def test_srv6_encap_source_addr(self): + # Set an IPv6 address for SRv6 encapsulation source + source6 = '2001:db8::1' + + # SRv6 must be enabled on at least one interface + for interface in Section.interfaces('ethernet', vlan=False): + self.cli_set(base_path + ['interface', interface, 'srv6']) + + self.cli_set(base_path + ['srv6', 'encapsulation', 'source-address', source6]) + self.cli_commit() + + frrconfig = self.getFRRconfig('segment-routing', stop_section='^exit') + self.assertIn('segment-routing', frrconfig) + self.assertIn(' srv6', frrconfig) + self.assertIn(' encapsulation', frrconfig) + self.assertIn(f' source-address {source6}', frrconfig) + def test_srv6_sysctl(self): interfaces = Section.interfaces('ethernet', vlan=False) -- cgit v1.2.3