diff options
-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']) |