summaryrefslogtreecommitdiff
path: root/smoketest/scripts/cli/base_interfaces_test.py
diff options
context:
space:
mode:
Diffstat (limited to 'smoketest/scripts/cli/base_interfaces_test.py')
-rw-r--r--smoketest/scripts/cli/base_interfaces_test.py149
1 files changed, 97 insertions, 52 deletions
diff --git a/smoketest/scripts/cli/base_interfaces_test.py b/smoketest/scripts/cli/base_interfaces_test.py
index aa9c15b65..970f12bd7 100644
--- a/smoketest/scripts/cli/base_interfaces_test.py
+++ b/smoketest/scripts/cli/base_interfaces_test.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2019-2022 VyOS maintainers and contributors
+# Copyright (C) 2019-2023 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
@@ -87,6 +87,12 @@ class BasicInterfaceTest:
# we should extend cli_defined to support more complex queries
cls._test_vlan = cli_defined(cls._base_path, 'vif')
cls._test_qinq = cli_defined(cls._base_path, 'vif-s')
+ cls._test_dhcp = cli_defined(cls._base_path, 'dhcp-options')
+ cls._test_ip = cli_defined(cls._base_path, 'ip')
+ cls._test_ipv6 = cli_defined(cls._base_path, 'ipv6')
+ cls._test_ipv6_dhcpc6 = cli_defined(cls._base_path, 'dhcpv6-options')
+ cls._test_ipv6_pd = cli_defined(cls._base_path + ['dhcpv6-options'], 'pd')
+ cls._test_mtu = cli_defined(cls._base_path, 'mtu')
# Setup mirror interfaces for SPAN (Switch Port Analyzer)
for span in cls._mirror_interfaces:
@@ -640,58 +646,90 @@ class BasicInterfaceTest:
self.cli_set(path + option.split())
# Options
- self.cli_set(path + ['ip', 'adjust-mss', mss])
- self.cli_set(path + ['ip', 'arp-cache-timeout', arp_tmo])
- self.cli_set(path + ['ip', 'disable-arp-filter'])
- self.cli_set(path + ['ip', 'disable-forwarding'])
- self.cli_set(path + ['ip', 'enable-directed-broadcast'])
- self.cli_set(path + ['ip', 'enable-arp-accept'])
- self.cli_set(path + ['ip', 'enable-arp-announce'])
- self.cli_set(path + ['ip', 'enable-arp-ignore'])
- self.cli_set(path + ['ip', 'enable-proxy-arp'])
- self.cli_set(path + ['ip', 'proxy-arp-pvlan'])
- self.cli_set(path + ['ip', 'source-validation', 'loose'])
+ if cli_defined(self._base_path + ['ip'], 'adjust-mss'):
+ self.cli_set(path + ['ip', 'adjust-mss', mss])
+
+ if cli_defined(self._base_path + ['ip'], 'arp-cache-timeout'):
+ self.cli_set(path + ['ip', 'arp-cache-timeout', arp_tmo])
+
+ if cli_defined(self._base_path + ['ip'], 'disable-arp-filter'):
+ self.cli_set(path + ['ip', 'disable-arp-filter'])
+
+ if cli_defined(self._base_path + ['ip'], 'disable-forwarding'):
+ self.cli_set(path + ['ip', 'disable-forwarding'])
+
+ if cli_defined(self._base_path + ['ip'], 'enable-directed-broadcast'):
+ self.cli_set(path + ['ip', 'enable-directed-broadcast'])
+
+ if cli_defined(self._base_path + ['ip'], 'enable-arp-accept'):
+ self.cli_set(path + ['ip', 'enable-arp-accept'])
+
+ if cli_defined(self._base_path + ['ip'], 'enable-arp-announce'):
+ self.cli_set(path + ['ip', 'enable-arp-announce'])
+
+ if cli_defined(self._base_path + ['ip'], 'enable-arp-ignore'):
+ self.cli_set(path + ['ip', 'enable-arp-ignore'])
+
+ if cli_defined(self._base_path + ['ip'], 'enable-proxy-arp'):
+ self.cli_set(path + ['ip', 'enable-proxy-arp'])
+
+ if cli_defined(self._base_path + ['ip'], 'proxy-arp-pvlan'):
+ self.cli_set(path + ['ip', 'proxy-arp-pvlan'])
+
+ if cli_defined(self._base_path + ['ip'], 'source-validation'):
+ self.cli_set(path + ['ip', 'source-validation', 'loose'])
self.cli_commit()
for interface in self._interfaces:
- base_options = f'oifname "{interface}"'
- out = cmd('sudo nft list chain raw VYOS_TCP_MSS')
- for line in out.splitlines():
- if line.startswith(base_options):
- self.assertIn(f'tcp option maxseg size set {mss}', line)
+ if cli_defined(self._base_path + ['ip'], 'adjust-mss'):
+ base_options = f'oifname "{interface}"'
+ out = cmd('sudo nft list chain raw VYOS_TCP_MSS')
+ for line in out.splitlines():
+ if line.startswith(base_options):
+ self.assertIn(f'tcp option maxseg size set {mss}', line)
- tmp = read_file(f'/proc/sys/net/ipv4/neigh/{interface}/base_reachable_time_ms')
- self.assertEqual(tmp, str((int(arp_tmo) * 1000))) # tmo value is in milli seconds
+ if cli_defined(self._base_path + ['ip'], 'arp-cache-timeout'):
+ tmp = read_file(f'/proc/sys/net/ipv4/neigh/{interface}/base_reachable_time_ms')
+ self.assertEqual(tmp, str((int(arp_tmo) * 1000))) # tmo value is in milli seconds
proc_base = f'/proc/sys/net/ipv4/conf/{interface}'
- tmp = read_file(f'{proc_base}/arp_filter')
- self.assertEqual('0', tmp)
+ if cli_defined(self._base_path + ['ip'], 'disable-arp-filter'):
+ tmp = read_file(f'{proc_base}/arp_filter')
+ self.assertEqual('0', tmp)
- tmp = read_file(f'{proc_base}/arp_accept')
- self.assertEqual('1', tmp)
+ if cli_defined(self._base_path + ['ip'], 'enable-arp-accept'):
+ tmp = read_file(f'{proc_base}/arp_accept')
+ self.assertEqual('1', tmp)
- tmp = read_file(f'{proc_base}/arp_announce')
- self.assertEqual('1', tmp)
+ if cli_defined(self._base_path + ['ip'], 'enable-arp-announce'):
+ tmp = read_file(f'{proc_base}/arp_announce')
+ self.assertEqual('1', tmp)
- tmp = read_file(f'{proc_base}/arp_ignore')
- self.assertEqual('1', tmp)
+ if cli_defined(self._base_path + ['ip'], 'enable-arp-ignore'):
+ tmp = read_file(f'{proc_base}/arp_ignore')
+ self.assertEqual('1', tmp)
- tmp = read_file(f'{proc_base}/forwarding')
- self.assertEqual('0', tmp)
+ if cli_defined(self._base_path + ['ip'], 'disable-forwarding'):
+ tmp = read_file(f'{proc_base}/forwarding')
+ self.assertEqual('0', tmp)
- tmp = read_file(f'{proc_base}/bc_forwarding')
- self.assertEqual('1', tmp)
+ if cli_defined(self._base_path + ['ip'], 'enable-directed-broadcast'):
+ tmp = read_file(f'{proc_base}/bc_forwarding')
+ self.assertEqual('1', tmp)
- tmp = read_file(f'{proc_base}/proxy_arp')
- self.assertEqual('1', tmp)
+ if cli_defined(self._base_path + ['ip'], 'enable-proxy-arp'):
+ tmp = read_file(f'{proc_base}/proxy_arp')
+ self.assertEqual('1', tmp)
- tmp = read_file(f'{proc_base}/proxy_arp_pvlan')
- self.assertEqual('1', tmp)
+ if cli_defined(self._base_path + ['ip'], 'proxy-arp-pvlan'):
+ tmp = read_file(f'{proc_base}/proxy_arp_pvlan')
+ self.assertEqual('1', tmp)
- tmp = read_file(f'{proc_base}/rp_filter')
- self.assertEqual('2', tmp)
+ if cli_defined(self._base_path + ['ip'], 'source-validation'):
+ tmp = read_file(f'{proc_base}/rp_filter')
+ self.assertEqual('2', tmp)
def test_interface_ipv6_options(self):
if not self._test_ipv6:
@@ -706,26 +744,33 @@ class BasicInterfaceTest:
self.cli_set(path + option.split())
# Options
- self.cli_set(path + ['ipv6', 'adjust-mss', mss])
- self.cli_set(path + ['ipv6', 'disable-forwarding'])
- self.cli_set(path + ['ipv6', 'dup-addr-detect-transmits', dad_transmits])
+ if cli_defined(self._base_path + ['ipv6'], 'adjust-mss'):
+ self.cli_set(path + ['ipv6', 'adjust-mss', mss])
+
+ if cli_defined(self._base_path + ['ipv6'], 'dup-addr-detect-transmits'):
+ self.cli_set(path + ['ipv6', 'dup-addr-detect-transmits', dad_transmits])
+
+ if cli_defined(self._base_path + ['ipv6'], 'disable-forwarding'):
+ self.cli_set(path + ['ipv6', 'disable-forwarding'])
self.cli_commit()
for interface in self._interfaces:
- base_options = f'oifname "{interface}"'
- out = cmd('sudo nft list chain ip6 raw VYOS_TCP_MSS')
- for line in out.splitlines():
- if line.startswith(base_options):
- self.assertIn(f'tcp option maxseg size set {mss}', line)
-
proc_base = f'/proc/sys/net/ipv6/conf/{interface}'
-
- tmp = read_file(f'{proc_base}/forwarding')
- self.assertEqual('0', tmp)
-
- tmp = read_file(f'{proc_base}/dad_transmits')
- self.assertEqual(dad_transmits, tmp)
+ if cli_defined(self._base_path + ['ipv6'], 'adjust-mss'):
+ base_options = f'oifname "{interface}"'
+ out = cmd('sudo nft list chain ip6 raw VYOS_TCP_MSS')
+ for line in out.splitlines():
+ if line.startswith(base_options):
+ self.assertIn(f'tcp option maxseg size set {mss}', line)
+
+ if cli_defined(self._base_path + ['ipv6'], 'dup-addr-detect-transmits'):
+ tmp = read_file(f'{proc_base}/dad_transmits')
+ self.assertEqual(dad_transmits, tmp)
+
+ if cli_defined(self._base_path + ['ipv6'], 'disable-forwarding'):
+ tmp = read_file(f'{proc_base}/forwarding')
+ self.assertEqual('0', tmp)
def test_dhcpv6_client_options(self):
if not self._test_ipv6_dhcpc6: