test-network: Add test for PREF64

This commit is contained in:
Susant Sahani 2023-09-05 15:40:22 +05:30 committed by Yu Watanabe
parent 5546506650
commit 681007ac20
3 changed files with 18 additions and 0 deletions

View file

@ -12,3 +12,4 @@ 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
UsePREF64=yes

View file

@ -32,3 +32,7 @@ LifetimeSec=1000
[IPv6RoutePrefix]
Route=2001:db2:fff::/64
LifetimeSec=1000
[IPv6PREF64Prefix]
Prefix=64:ff9b::/96
LifetimeSec=30m

View file

@ -14,6 +14,7 @@ import pathlib
import re
import shutil
import signal
import socket
import subprocess
import sys
import time
@ -6328,6 +6329,18 @@ class NetworkdIPv6PrefixTests(unittest.TestCase, Utilities):
output = check_output(*networkctl_cmd, '--json=short', 'status', env=env)
check_json(output)
output = check_output(*networkctl_cmd, '--json=short', 'status', 'veth-peer', env=env)
check_json(output)
# PREF64 or NAT64
pref64 = json.loads(output)['NDisc']['PREF64'][0]
prefix = socket.inet_ntop(socket.AF_INET6, bytearray(pref64['Prefix']))
self.assertEqual(prefix, '64:ff9b::')
prefix_length = pref64['PrefixLength']
self.assertEqual(prefix_length, 96)
def test_ipv6_route_prefix_deny_list(self):
copy_network_unit('25-veth.netdev', '25-ipv6ra-prefix-client-deny-list.network', '25-ipv6ra-prefix.network',
'12-dummy.netdev', '25-ipv6ra-uplink.network')