From 6a8306598218824ef48d302f6095ae8e854bdd95 Mon Sep 17 00:00:00 2001 From: Sander Klein Date: Sat, 17 Dec 2022 18:06:44 +0100 Subject: T4809: radvd: Allow the use of AdvRASrcAddress This add the AdvRASrcAddress configuration option to configure a source address for the router advertisements. The source address still must be configured on the system. This is useful for VRRP setups where you want fe80::1 on the VRRP interface for cleaner VRRP failovers. --- data/templates/router-advert/radvd.conf.tmpl | 7 +++++++ interface-definitions/service_router-advert.xml.in | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/data/templates/router-advert/radvd.conf.tmpl b/data/templates/router-advert/radvd.conf.tmpl index 88d066491..17869e318 100644 --- a/data/templates/router-advert/radvd.conf.tmpl +++ b/data/templates/router-advert/radvd.conf.tmpl @@ -43,6 +43,13 @@ interface {{ iface }} { }; {% endfor %} {% endif %} +{% if iface_config.source_address is defined %} + AdvRASrcAddress { +{% for source_address in iface_config.source_address %} + {{ source_address }} +{% endfor %} + }; +{% endif %} {% if iface_config.prefix is defined and iface_config.prefix is not none %} {% for prefix, prefix_options in iface_config.prefix.items() %} prefix {{ prefix }} { diff --git a/interface-definitions/service_router-advert.xml.in b/interface-definitions/service_router-advert.xml.in index 0f4009f5c..a15ce8b8f 100644 --- a/interface-definitions/service_router-advert.xml.in +++ b/interface-definitions/service_router-advert.xml.in @@ -276,6 +276,19 @@ + + + Use IPv6 address as source address. Useful with VRRP. + + ipv6 + IPv6 address to be advertized (must be configured on interface) + + + + + + + Time, in milliseconds, that a node assumes a neighbor is reachable after having received a reachability confirmation -- cgit v1.2.3 From 45f66196b724b7cc147c9622502837a99a57a19d Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Tue, 20 Dec 2022 18:05:39 +0100 Subject: radvd: T4809: fix AdvRASrcAddress missing semicolon Commit 13071a4a ("T4809: radvd: Allow the use of AdvRASrcAddress") added a new feature to set the RA source-address. Unfortunately it missed a semicolon. (cherry picked from commit 4e61fb1f0fd075c5b1a67165204e13f88a7d3015) --- data/templates/router-advert/radvd.conf.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/templates/router-advert/radvd.conf.tmpl b/data/templates/router-advert/radvd.conf.tmpl index 17869e318..4be6797ee 100644 --- a/data/templates/router-advert/radvd.conf.tmpl +++ b/data/templates/router-advert/radvd.conf.tmpl @@ -46,7 +46,7 @@ interface {{ iface }} { {% if iface_config.source_address is defined %} AdvRASrcAddress { {% for source_address in iface_config.source_address %} - {{ source_address }} + {{ source_address }}; {% endfor %} }; {% endif %} -- cgit v1.2.3 From df18e6510bb94d1a3acf018c3a8fc3ffc5b61028 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Tue, 20 Dec 2022 18:19:14 +0100 Subject: smoketest: radvd: T4809: add test case for RA source address (cherry picked from commit 65b104d6e0608e229aa36d948fabddaf3f4a0a8b) --- .../scripts/cli/test_service_router-advert.py | 36 +++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/smoketest/scripts/cli/test_service_router-advert.py b/smoketest/scripts/cli/test_service_router-advert.py index 4875fb5d1..da08421d3 100755 --- a/smoketest/scripts/cli/test_service_router-advert.py +++ b/smoketest/scripts/cli/test_service_router-advert.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -# Copyright (C) 2019-2020 VyOS maintainers and contributors +# Copyright (C) 2019-2022 VyOS maintainers and contributors # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 or later as @@ -27,6 +27,7 @@ RADVD_CONF = '/run/radvd/radvd.conf' interface = 'eth1' base_path = ['service', 'router-advert', 'interface', interface] address_base = ['interfaces', 'ethernet', interface, 'address'] +prefix = '::/64' def get_config_value(key): tmp = read_file(RADVD_CONF) @@ -113,5 +114,38 @@ class TestServiceRADVD(VyOSUnitTestSHIM.TestCase): tmp = 'DNSSL ' + ' '.join(dnssl) + ' {' self.assertIn(tmp, config) + def test_route(self): + route = '2001:db8:1000::/64' + + self.cli_set(base_path + ['prefix', prefix]) + self.cli_set(base_path + ['route', route]) + + # commit changes + self.cli_commit() + + config = read_file(RADVD_CONF) + + tmp = f'route {route}' + ' {' + self.assertIn(tmp, config) + + self.assertIn('AdvRouteLifetime 1800;', config) + self.assertIn('AdvRoutePreference medium;', config) + self.assertIn('RemoveRoute on;', config) + + def test_rasrcaddress(self): + ra_src = ['fe80::1', 'fe80::2'] + + self.cli_set(base_path + ['prefix', prefix]) + for src in ra_src: + self.cli_set(base_path + ['source-address', src]) + + # commit changes + self.cli_commit() + + config = read_file(RADVD_CONF) + self.assertIn('AdvRASrcAddress {', config) + for src in ra_src: + self.assertIn(f' {src};', config) + if __name__ == '__main__': unittest.main(verbosity=2) -- cgit v1.2.3