diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-07-24 17:06:25 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2020-07-24 17:06:28 +0200 |
commit | ded9d1b9372cdee3066fc62fa59c4fd2a0ea3ad5 (patch) | |
tree | a6ddbe4f8f0e4d9cb80daa7b650a3efa9862f933 | |
parent | ed4369ca1ed6a5504cbf181722df11c444dd8555 (diff) | |
download | vyos-1x-ded9d1b9372cdee3066fc62fa59c4fd2a0ea3ad5.tar.gz vyos-1x-ded9d1b9372cdee3066fc62fa59c4fd2a0ea3ad5.zip |
ethernet: test "ip" subtree of interface for e.g. ARP settings
-rw-r--r-- | scripts/cli/base_interfaces_test.py | 50 | ||||
-rwxr-xr-x | scripts/cli/test_interfaces_ethernet.py | 1 |
2 files changed, 51 insertions, 0 deletions
diff --git a/scripts/cli/base_interfaces_test.py b/scripts/cli/base_interfaces_test.py index 72696f780..fa3e8a0c1 100644 --- a/scripts/cli/base_interfaces_test.py +++ b/scripts/cli/base_interfaces_test.py @@ -19,9 +19,11 @@ from vyos.configsession import ConfigSession from netifaces import ifaddresses, AF_INET, AF_INET6 from vyos.validate import is_intf_addr_assigned, is_ipv6_link_local from vyos.ifconfig import Interface +from vyos.util import read_file class BasicInterfaceTest: class BaseTest(unittest.TestCase): + _test_ip = False _test_mtu = False _test_vlan = False _test_qinq = False @@ -177,3 +179,51 @@ class BasicInterfaceTest: for address in self._test_addr: self.assertTrue(is_intf_addr_assigned(vif, address)) self._mtu_test(vif) + + def test_ip_options(self): + """ test IP options like arp """ + if not self._test_ip: + return None + + for interface in self._interfaces: + arp_tmo = '300' + path = self._base_path + [interface] + for option in self._options.get(interface, []): + self.session.set(path + option.split()) + + # Options + self.session.set(path + ['ip', 'arp-cache-timeout', arp_tmo]) + self.session.set(path + ['ip', 'disable-arp-filter']) + self.session.set(path + ['ip', 'enable-arp-accept']) + self.session.set(path + ['ip', 'enable-arp-announce']) + self.session.set(path + ['ip', 'enable-arp-ignore']) + self.session.set(path + ['ip', 'enable-proxy-arp']) + self.session.set(path + ['ip', 'proxy-arp-pvlan']) + self.session.set(path + ['ip', 'source-validation', 'loose']) + + self.session.commit() + + for interface in self._interfaces: + 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 + + tmp = read_file(f'/proc/sys/net/ipv4/conf/{interface}/arp_filter') + self.assertEqual('0', tmp) + + tmp = read_file(f'/proc/sys/net/ipv4/conf/{interface}/arp_accept') + self.assertEqual('1', tmp) + + tmp = read_file(f'/proc/sys/net/ipv4/conf/{interface}/arp_announce') + self.assertEqual('1', tmp) + + tmp = read_file(f'/proc/sys/net/ipv4/conf/{interface}/arp_ignore') + self.assertEqual('1', tmp) + + tmp = read_file(f'/proc/sys/net/ipv4/conf/{interface}/proxy_arp') + self.assertEqual('1', tmp) + + tmp = read_file(f'/proc/sys/net/ipv4/conf/{interface}/proxy_arp_pvlan') + self.assertEqual('1', tmp) + + tmp = read_file(f'/proc/sys/net/ipv4/conf/{interface}/rp_filter') + self.assertEqual('2', tmp) diff --git a/scripts/cli/test_interfaces_ethernet.py b/scripts/cli/test_interfaces_ethernet.py index 7f706aabb..ccc4238e2 100755 --- a/scripts/cli/test_interfaces_ethernet.py +++ b/scripts/cli/test_interfaces_ethernet.py @@ -25,6 +25,7 @@ class EthernetInterfaceTest(BasicInterfaceTest.BaseTest): super().setUp() self._base_path = ['interfaces', 'ethernet'] + self._test_ip = True self._test_mtu = True self._test_vlan = True self._test_qinq = True |