summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2023-07-10 05:16:51 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2023-07-30 17:40:03 +0200
commit2ede3559082dff66c01e9efe04da299a9a0ae04c (patch)
tree4e838a156ce66f51603bf49d497fc254351abbb2 /test
parentnetwork/neighbor: do not add Neighbor object to Link on requesting (diff)
downloadsystemd-2ede3559082dff66c01e9efe04da299a9a0ae04c.tar.xz
systemd-2ede3559082dff66c01e9efe04da299a9a0ae04c.zip
test-network: add tests for several invalid neighbor settings, and overriding settings
This also makes the checks stricter.
Diffstat (limited to 'test')
-rw-r--r--test/test-network/conf/25-neighbor-ip.network5
-rw-r--r--test/test-network/conf/25-neighbor-ipv6.network5
-rw-r--r--test/test-network/conf/25-neighbor-section.network13
-rw-r--r--test/test-network/conf/25-neighbor-section.network.d/override.conf9
-rwxr-xr-xtest/test-network/systemd-networkd-tests.py44
5 files changed, 63 insertions, 13 deletions
diff --git a/test/test-network/conf/25-neighbor-ip.network b/test/test-network/conf/25-neighbor-ip.network
index 8ef6e3f28b..5469333b92 100644
--- a/test/test-network/conf/25-neighbor-ip.network
+++ b/test/test-network/conf/25-neighbor-ip.network
@@ -9,3 +9,8 @@ Address=10.0.0.21
[Neighbor]
Address=10.0.0.22
LinkLayerAddress=10.65.223.239
+
+[Neighbor]
+# unmatching link layer address length
+Address=10.0.0.23
+LinkLayerAddress=11:22:33:44:55:66
diff --git a/test/test-network/conf/25-neighbor-ipv6.network b/test/test-network/conf/25-neighbor-ipv6.network
index f7480fa6a2..80f989d1cd 100644
--- a/test/test-network/conf/25-neighbor-ipv6.network
+++ b/test/test-network/conf/25-neighbor-ipv6.network
@@ -10,3 +10,8 @@ LinkLocalAddressing=no
[Neighbor]
Address=2001:db8:0:f102::17
LinkLayerAddress=2a00:ffde:4567:edde::4988
+
+[Neighbor]
+# unmatching link layer address length
+Address=2001:db8:0:f102::18
+LinkLayerAddress=11:22:33:44:55:66
diff --git a/test/test-network/conf/25-neighbor-section.network b/test/test-network/conf/25-neighbor-section.network
index 38f6b02516..59e21ebf1b 100644
--- a/test/test-network/conf/25-neighbor-section.network
+++ b/test/test-network/conf/25-neighbor-section.network
@@ -12,3 +12,16 @@ LinkLayerAddress=00:00:5e:00:02:65
[Neighbor]
Address=2004:da8:1:0::1
LinkLayerAddress=00:00:5e:00:02:66
+
+[Neighbor]
+# unmatching link layer address length
+Address=2004:da8:1:0::2
+LinkLayerAddress=192.168.0.1
+
+[Neighbor]
+# invalid setting (without LinkLayerAddress=)
+Address=192.168.10.2
+
+[Neighbor]
+# invalid setting (without Address=)
+LinkLayerAddress=00:00:5e:00:02:67
diff --git a/test/test-network/conf/25-neighbor-section.network.d/override.conf b/test/test-network/conf/25-neighbor-section.network.d/override.conf
new file mode 100644
index 0000000000..01027e35c3
--- /dev/null
+++ b/test/test-network/conf/25-neighbor-section.network.d/override.conf
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+[Neighbor]
+Address=192.168.10.1
+LinkLayerAddress=00:00:5e:00:03:65
+
+[Neighbor]
+Address=2004:da8:1:0::1
+LinkLayerAddress=00:00:5e:00:03:66
diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py
index 8fd9422a88..c1a017d16b 100755
--- a/test/test-network/systemd-networkd-tests.py
+++ b/test/test-network/systemd-networkd-tests.py
@@ -3125,40 +3125,56 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
self.assertRegex(output, f'2607:5300:203:5215:{i}::1 *proxy')
def test_neighbor_section(self):
- copy_network_unit('25-neighbor-section.network', '12-dummy.netdev')
+ copy_network_unit('25-neighbor-section.network', '12-dummy.netdev', copy_dropins=False)
start_networkd()
- self.wait_online(['dummy98:degraded'], timeout='40s')
+ self.wait_online(['dummy98:degraded'])
print('### ip neigh list dev dummy98')
output = check_output('ip neigh list dev dummy98')
print(output)
- self.assertRegex(output, '192.168.10.1.*00:00:5e:00:02:65.*PERMANENT')
- self.assertRegex(output, '2004:da8:1::1.*00:00:5e:00:02:66.*PERMANENT')
+ self.assertIn('192.168.10.1 lladdr 00:00:5e:00:02:65 PERMANENT', output)
+ self.assertIn('2004:da8:1::1 lladdr 00:00:5e:00:02:66 PERMANENT', output)
+ self.assertNotIn('2004:da8:1:0::2', output)
+ self.assertNotIn('192.168.10.2', output)
+ self.assertNotIn('00:00:5e:00:02:67', output)
output = check_output(*networkctl_cmd, '--json=short', 'status', env=env)
check_json(output)
+ copy_network_unit('25-neighbor-section.network.d/override.conf')
+ networkctl_reload()
+ self.wait_online(['dummy98:degraded'])
+
+ print('### ip neigh list dev dummy98 (after reloading)')
+ output = check_output('ip neigh list dev dummy98')
+ print(output)
+ self.assertIn('192.168.10.1 lladdr 00:00:5e:00:03:65 PERMANENT', output)
+ self.assertIn('2004:da8:1::1 lladdr 00:00:5e:00:03:66 PERMANENT', output)
+ self.assertNotIn('2004:da8:1:0::2', output)
+ self.assertNotIn('192.168.10.2', output)
+ self.assertNotIn('00:00:5e:00:02', output)
+
def test_neighbor_reconfigure(self):
- copy_network_unit('25-neighbor-section.network', '12-dummy.netdev')
+ copy_network_unit('25-neighbor-section.network', '12-dummy.netdev', copy_dropins=False)
start_networkd()
- self.wait_online(['dummy98:degraded'], timeout='40s')
+ self.wait_online(['dummy98:degraded'])
print('### ip neigh list dev dummy98')
output = check_output('ip neigh list dev dummy98')
print(output)
- self.assertRegex(output, '192.168.10.1.*00:00:5e:00:02:65.*PERMANENT')
- self.assertRegex(output, '2004:da8:1::1.*00:00:5e:00:02:66.*PERMANENT')
+ self.assertIn('192.168.10.1 lladdr 00:00:5e:00:02:65 PERMANENT', output)
+ self.assertIn('2004:da8:1::1 lladdr 00:00:5e:00:02:66 PERMANENT', output)
remove_network_unit('25-neighbor-section.network')
copy_network_unit('25-neighbor-next.network')
networkctl_reload()
- self.wait_online(['dummy98:degraded'], timeout='40s')
+ self.wait_online(['dummy98:degraded'])
print('### ip neigh list dev dummy98')
output = check_output('ip neigh list dev dummy98')
print(output)
- self.assertNotRegex(output, '192.168.10.1.*00:00:5e:00:02:65.*PERMANENT')
- self.assertRegex(output, '192.168.10.1.*00:00:5e:00:02:66.*PERMANENT')
- self.assertNotRegex(output, '2004:da8:1::1.*PERMANENT')
+ self.assertNotIn('00:00:5e:00:02:65', output)
+ self.assertIn('192.168.10.1 lladdr 00:00:5e:00:02:66 PERMANENT', output)
+ self.assertNotIn('2004:da8:1::1', output)
def test_neighbor_gre(self):
copy_network_unit('25-neighbor-ip.network', '25-neighbor-ipv6.network', '25-neighbor-ip-dummy.network',
@@ -3168,11 +3184,13 @@ class NetworkdNetworkTests(unittest.TestCase, Utilities):
output = check_output('ip neigh list dev gretun97')
print(output)
- self.assertRegex(output, '10.0.0.22 lladdr 10.65.223.239 PERMANENT')
+ self.assertIn('10.0.0.22 lladdr 10.65.223.239 PERMANENT', output)
+ self.assertNotIn('10.0.0.23', output)
output = check_output('ip neigh list dev ip6gretun97')
print(output)
self.assertRegex(output, '2001:db8:0:f102::17 lladdr 2a:?00:ff:?de:45:?67:ed:?de:[0:]*:49:?88 PERMANENT')
+ self.assertNotIn('2001:db8:0:f102::18', output)
output = check_output(*networkctl_cmd, '--json=short', 'status', env=env)
check_json(output)