diff options
author | Christian Poessinger <christian@poessinger.com> | 2021-01-02 12:20:34 +0100 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2021-01-02 12:20:34 +0100 |
commit | 79f44d3cf8dc366e652f9fa01b34eff5314830ec (patch) | |
tree | 52638d525892aa701020d196ff2889dd014946ca | |
parent | a6993fc98fa86a5e4b27194ed151bf6dda8ed6b4 (diff) | |
download | vyos-1x-79f44d3cf8dc366e652f9fa01b34eff5314830ec.tar.gz vyos-1x-79f44d3cf8dc366e652f9fa01b34eff5314830ec.zip |
vrf: T2321: assign loopback IP addresses to individual VRF interfaces
47: bar: <NOARP,MASTER,UP,LOWER_UP> mtu 65536 qdisc noqueue state UP group default qlen 1000
link/ether 76:7d:c0:53:6d:89 brd ff:ff:ff:ff:ff:ff
inet 127.0.0.1/8 scope host bar
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
-rwxr-xr-x | smoketest/scripts/cli/test_vrf.py | 18 | ||||
-rwxr-xr-x | src/conf_mode/vrf.py | 4 |
2 files changed, 20 insertions, 2 deletions
diff --git a/smoketest/scripts/cli/test_vrf.py b/smoketest/scripts/cli/test_vrf.py index d8ed46f0b..7bcfea861 100755 --- a/smoketest/scripts/cli/test_vrf.py +++ b/smoketest/scripts/cli/test_vrf.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -# Copyright (C) 2020 VyOS maintainers and contributors +# Copyright (C) 2020-2021 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 @@ -19,6 +19,7 @@ import unittest from vyos.configsession import ConfigSession, ConfigSessionError from vyos.util import read_file +from vyos.validate import is_intf_addr_assigned class VRFTest(unittest.TestCase): def setUp(self): @@ -31,7 +32,7 @@ class VRFTest(unittest.TestCase): self.session.commit() del self.session - def test_table_id(self): + def test_vrf_table_id(self): table = 1000 for vrf in self._vrfs: base = ['vrf', 'name', vrf] @@ -48,5 +49,18 @@ class VRFTest(unittest.TestCase): # commit changes self.session.commit() + def test_vrf_loopback_ips(self): + table = 1000 + for vrf in self._vrfs: + base = ['vrf', 'name', vrf] + self.session.set(base + ['table', str(table)]) + table += 1 + + # commit changes + self.session.commit() + for vrf in self._vrfs: + self.assertTrue(is_intf_addr_assigned(vrf, '127.0.0.1')) + self.assertTrue(is_intf_addr_assigned(vrf, '::1')) + if __name__ == '__main__': unittest.main(verbosity=2) diff --git a/src/conf_mode/vrf.py b/src/conf_mode/vrf.py index 2f4da0240..c4ba859b7 100755 --- a/src/conf_mode/vrf.py +++ b/src/conf_mode/vrf.py @@ -223,6 +223,10 @@ def apply(vrf_config): # afterwards are taken. _cmd(f'ip -4 route add vrf {name} unreachable default metric 4278198272') _cmd(f'ip -6 route add vrf {name} unreachable default metric 4278198272') + # We also should add proper loopback IP addresses to the newly + # created VRFs for services bound to the loopback address (SNMP, NTP) + _cmd(f'ip -4 addr add 127.0.0.1/8 dev {name}') + _cmd(f'ip -6 addr add ::1/128 dev {name}') # set VRF description for e.g. SNMP monitoring Interface(name).set_alias(vrf['description']) |