1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-23 21:35:11 +03:00

test-network: add more testcases for *Allow/DenyList=

This commit is contained in:
Yu Watanabe 2021-08-23 20:37:36 +09:00
parent c995fa02b1
commit ab47f96041
4 changed files with 37 additions and 5 deletions

View File

@ -0,0 +1,11 @@
[Match]
Name=veth99
[Network]
DHCP=ipv4
IPv6AcceptRA=false
[DHCPv4]
# DenyList= will be ignored
AllowList=192.168.5.0/24 192.168.6.0/24
DenyList=192.168.5.0/24

View File

@ -6,9 +6,8 @@ DHCP=no
IPv6AcceptRA=yes
[IPv6AcceptRA]
# PrefixDenyList= and RouteDenyList= will be ignored.
PrefixAllowList=2001:db8:0:1:: 2001:db8:0:1::
PrefixDenyList=2001:db8:0:1:: 2001:db8:0:1::
RouteAllowList=2001:db0:fff:: 2001:db0:fff::
RouteDenyList=2001:db0:fff:: 2001:db0:fff::
# PrefixDenyList= will be ignored.
PrefixAllowList=2001:db8:0:1:: 2001:db8:0:1:: 2001:db8:0:1::/64
PrefixDenyList=2001:db8:0:1::/64 2001:db8:0:1:: 2001:db8:0:3::/64
RouteDenyList=2001:db1:fff::/64 2001:db1:fff:: 2001:db2:fff::/64
UseDomains=yes

View File

@ -15,6 +15,9 @@ Prefix=2001:db8:0:1::/64
Prefix=2001:db8:0:2::/64
Assign=yes
[IPv6Prefix]
Prefix=2001:db8:0:3::/64
[IPv6RoutePrefix]
Route=2001:db0:fff::/64
LifetimeSec=1000
@ -22,3 +25,7 @@ LifetimeSec=1000
[IPv6RoutePrefix]
Route=2001:db1:fff::/64
LifetimeSec=1000
[IPv6RoutePrefix]
Route=2001:db2:fff::/64
LifetimeSec=1000

View File

@ -3931,6 +3931,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
'25-veth.netdev',
'25-vrf.netdev',
'25-vrf.network',
'dhcp-client-allow-list.network',
'dhcp-client-anonymize.network',
'dhcp-client-decline.network',
'dhcp-client-gateway-ipv4.network',
@ -4764,6 +4765,16 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
print(output)
self.assertRegex(output, 'inet 192.168.5.[0-9]*/24 metric 1024 brd 192.168.5.255 scope global dynamic veth99')
def test_dhcp_client_allow_list(self):
copy_unit_to_networkd_unit_path('25-veth.netdev', 'dhcp-server-decline.network', 'dhcp-client-allow-list.network')
start_networkd()
self.wait_online(['veth99:routable', 'veth-peer:routable'])
output = check_output('ip -4 address show dev veth99 scope global dynamic')
print(output)
self.assertRegex(output, 'inet 192.168.5.[0-9]*/24 metric 1024 brd 192.168.5.255 scope global dynamic veth99')
class NetworkdIPv6PrefixTests(unittest.TestCase, Utilities):
links = [
'dummy98',
@ -4800,18 +4811,22 @@ class NetworkdIPv6PrefixTests(unittest.TestCase, Utilities):
print(output)
self.assertIn('inet6 2001:db8:0:1:', output)
self.assertNotIn('inet6 2001:db8:0:2:', output)
self.assertNotIn('inet6 2001:db8:0:3:', output)
output = check_output('ip -6 route show dev veth-peer')
print(output)
self.assertIn('2001:db8:0:1::/64 proto ra', output)
self.assertNotIn('2001:db8:0:2::/64 proto ra', output)
self.assertNotIn('2001:db8:0:3::/64 proto ra', output)
self.assertIn('2001:db0:fff::/64 via ', output)
self.assertNotIn('2001:db1:fff::/64 via ', output)
self.assertNotIn('2001:db2:fff::/64 via ', output)
output = check_output('ip address show dev veth99')
print(output)
self.assertNotIn('inet6 2001:db8:0:1:', output)
self.assertIn('inet6 2001:db8:0:2:', output)
self.assertNotIn('inet6 2001:db8:0:3:', output)
output = check_output(*resolvectl_cmd, 'dns', 'veth-peer', env=env)
print(output)