Skip to content

Commit

Permalink
tests: ethernets: Add ipv6-address-generation integration tests
Browse files Browse the repository at this point in the history
These tests validate the Stable Privacy and Modified EUI-64 IPv6 address
generation methods under both NetworkManager and systemd-networkd.
  • Loading branch information
tatokis committed Aug 22, 2024
1 parent e5d82f5 commit 2eb0866
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions tests/integration/ethernets.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import sys
import subprocess
import unittest
import ipaddress

from base import IntegrationTestsBase, nm_uses_dnsmasq, resolved_in_use, test_backends

Expand Down Expand Up @@ -221,6 +222,48 @@ def test_ip6_token(self):
self.generate_and_settle([self.state(self.dev_e_client, '::42')])
self.assert_iface_up(self.dev_e_client, ['inet6 2600::42/64'])

def test_ip6_stable_privacy(self):
self.setup_eth('ra-only')
with open(self.config, 'w') as f:
f.write('''network:
version: 2
renderer: %(r)s
ethernets:
%(ec)s:
dhcp6: yes
accept-ra: yes
ipv6-address-generation: stable-privacy''' % {'r': self.backend, 'ec': self.dev_e_client})
self.generate_and_settle([self.state_dhcp6(self.dev_e_client)])
mac_addr = [int(h, base=16) for h in self.dev_e_client_mac.split(':')]
mac_addr[0] ^= 2
mac_addr[3:3] = [0xff, 0xfe]
eui_addr_int = 0x26000000000000000000000000000000
for i, h in enumerate(reversed(mac_addr)):
eui_addr_int |= h << 8 * i
eui_addr = ipaddress.IPv6Address(eui_addr_int)
self.assert_iface_up(self.dev_e_client, ['inet6 2600::'], [f'inet6 {eui_addr.compressed}/64'])

def test_ip6_eui64(self):
self.setup_eth('ra-only')
with open(self.config, 'w') as f:
f.write('''network:
version: 2
renderer: %(r)s
ethernets:
%(ec)s:
dhcp6: yes
accept-ra: yes
ipv6-address-generation: eui64''' % {'r': self.backend, 'ec': self.dev_e_client})
self.generate_and_settle([self.state_dhcp6(self.dev_e_client)])
mac_addr = [int(h, base=16) for h in self.dev_e_client_mac.split(':')]
mac_addr[0] ^= 2
mac_addr[3:3] = [0xff, 0xfe]
eui_addr_int = 0x26000000000000000000000000000000
for i, h in enumerate(reversed(mac_addr)):
eui_addr_int |= h << 8 * i
eui_addr = ipaddress.IPv6Address(eui_addr_int)
self.assert_iface_up(self.dev_e_client, [f'inet6 {eui_addr.compressed}/64'])

def test_link_local_all(self):
self.setup_eth(None)
with open(self.config, 'w') as f:
Expand Down

0 comments on commit 2eb0866

Please sign in to comment.