diff options
author | Christian Poessinger <christian@poessinger.com> | 2022-05-07 12:45:08 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2022-05-07 12:45:08 +0200 |
commit | da9fb81131db0e4ca3566cac31257ee212638406 (patch) | |
tree | 7f770f082133aeda60a92d8ba703bff5be2f8cfa /smoketest/scripts/cli/test_vrf.py | |
parent | 9395a96ce86a53ee75ce8b8ed7feea20ee603764 (diff) | |
download | vyos-1x-da9fb81131db0e4ca3566cac31257ee212638406.tar.gz vyos-1x-da9fb81131db0e4ca3566cac31257ee212638406.zip |
vrf: T4419: support to disable IP forwarding within a given VRF
Diffstat (limited to 'smoketest/scripts/cli/test_vrf.py')
-rwxr-xr-x | smoketest/scripts/cli/test_vrf.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/smoketest/scripts/cli/test_vrf.py b/smoketest/scripts/cli/test_vrf.py index ff18f7261..176c095fb 100755 --- a/smoketest/scripts/cli/test_vrf.py +++ b/smoketest/scripts/cli/test_vrf.py @@ -127,6 +127,9 @@ class VRFTest(VyOSUnitTestSHIM.TestCase): for vrf in vrfs: # Ensure VRF was created self.assertIn(vrf, interfaces()) + # Verify IP forwarding is 1 (enabled) + self.assertEqual(read_file(f'/proc/sys/net/ipv4/conf/{vrf}/forwarding'), '1') + self.assertEqual(read_file(f'/proc/sys/net/ipv6/conf/{vrf}/forwarding'), '1') # Test for proper loopback IP assignment for addr in loopbacks: self.assertTrue(is_intf_addr_assigned(vrf, addr)) @@ -267,5 +270,26 @@ class VRFTest(VyOSUnitTestSHIM.TestCase): self.cli_delete(['interfaces', 'dummy', interface]) self.cli_commit() + def test_vrf_disable_forwarding(self): + table = '2000' + for vrf in vrfs: + base = base_path + ['name', vrf] + self.cli_set(base + ['table', table]) + self.cli_set(base + ['ip', 'disable-forwarding']) + self.cli_set(base + ['ipv6', 'disable-forwarding']) + table = str(int(table) + 1) + + # commit changes + self.cli_commit() + + # Verify VRF configuration + loopbacks = ['127.0.0.1', '::1'] + for vrf in vrfs: + # Ensure VRF was created + self.assertIn(vrf, interfaces()) + # Verify IP forwarding is 0 (disabled) + self.assertEqual(read_file(f'/proc/sys/net/ipv4/conf/{vrf}/forwarding'), '0') + self.assertEqual(read_file(f'/proc/sys/net/ipv6/conf/{vrf}/forwarding'), '0') + if __name__ == '__main__': unittest.main(verbosity=2) |