summaryrefslogtreecommitdiff
path: root/smoketest
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2022-05-07 12:45:08 +0200
committerChristian Poessinger <christian@poessinger.com>2022-05-07 12:45:08 +0200
commitda9fb81131db0e4ca3566cac31257ee212638406 (patch)
tree7f770f082133aeda60a92d8ba703bff5be2f8cfa /smoketest
parent9395a96ce86a53ee75ce8b8ed7feea20ee603764 (diff)
downloadvyos-1x-da9fb81131db0e4ca3566cac31257ee212638406.tar.gz
vyos-1x-da9fb81131db0e4ca3566cac31257ee212638406.zip
vrf: T4419: support to disable IP forwarding within a given VRF
Diffstat (limited to 'smoketest')
-rwxr-xr-xsmoketest/scripts/cli/test_vrf.py24
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)