mirror of
https://github.com/systemd/systemd.git
synced 2025-01-23 02:04:32 +03:00
test-network: add tests for several invalid neighbor settings, and overriding settings
This also makes the checks stricter.
This commit is contained in:
parent
5d098f5d36
commit
2ede355908
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user