2019-12-13 23:39:35 +00:00
|
|
|
from socket import AF_INET6, inet_ntop, inet_pton
|
2019-02-28 15:34:00 -08:00
|
|
|
|
2022-04-26 19:02:15 +02:00
|
|
|
from scapy.layers.dhcp6 import (
|
|
|
|
DHCP6_Advertise,
|
|
|
|
DHCP6OptClientId,
|
|
|
|
DHCP6OptStatusCode,
|
|
|
|
DHCP6OptPref,
|
|
|
|
DHCP6OptIA_PD,
|
|
|
|
DHCP6OptIAPrefix,
|
|
|
|
DHCP6OptServerId,
|
|
|
|
DHCP6_Solicit,
|
|
|
|
DHCP6_Reply,
|
|
|
|
DHCP6_Request,
|
|
|
|
DHCP6_Renew,
|
|
|
|
DHCP6_Rebind,
|
|
|
|
DUID_LL,
|
|
|
|
DHCP6_Release,
|
|
|
|
DHCP6OptElapsedTime,
|
|
|
|
DHCP6OptIA_NA,
|
|
|
|
DHCP6OptIAAddress,
|
|
|
|
)
|
2018-05-25 14:02:20 +02:00
|
|
|
from scapy.layers.inet6 import IPv6, Ether, UDP
|
2019-02-28 15:34:00 -08:00
|
|
|
|
2018-05-25 14:02:20 +02:00
|
|
|
from framework import VppTestCase
|
2023-08-31 00:47:44 -04:00
|
|
|
from asfframework import tag_fixme_vpp_workers, tag_run_solo
|
2019-10-01 11:30:56 +02:00
|
|
|
from vpp_papi import VppEnum
|
2019-02-28 15:34:00 -08:00
|
|
|
import util
|
2019-10-07 00:39:28 -07:00
|
|
|
import os
|
2018-05-25 14:02:20 +02:00
|
|
|
|
|
|
|
|
|
|
|
def ip6_normalize(ip6):
|
|
|
|
return inet_ntop(AF_INET6, inet_pton(AF_INET6, ip6))
|
|
|
|
|
|
|
|
|
2018-05-04 14:20:06 +02:00
|
|
|
class TestDHCPv6DataPlane(VppTestCase):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""DHCPv6 Data Plane Test Case"""
|
2018-05-25 14:02:20 +02:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def setUpClass(cls):
|
2018-05-04 14:20:06 +02:00
|
|
|
super(TestDHCPv6DataPlane, cls).setUpClass()
|
2018-05-25 14:02:20 +02:00
|
|
|
|
2019-03-12 19:23:27 -07:00
|
|
|
@classmethod
|
|
|
|
def tearDownClass(cls):
|
|
|
|
super(TestDHCPv6DataPlane, cls).tearDownClass()
|
|
|
|
|
2018-05-25 14:02:20 +02:00
|
|
|
def setUp(self):
|
2018-05-04 14:20:06 +02:00
|
|
|
super(TestDHCPv6DataPlane, self).setUp()
|
2018-05-25 14:02:20 +02:00
|
|
|
|
|
|
|
self.create_pg_interfaces(range(1))
|
|
|
|
self.interfaces = list(self.pg_interfaces)
|
|
|
|
for i in self.interfaces:
|
|
|
|
i.admin_up()
|
|
|
|
i.config_ip6()
|
|
|
|
|
2018-06-12 10:21:05 +02:00
|
|
|
self.server_duid = DUID_LL(lladdr=self.pg0.remote_mac)
|
2018-05-25 14:02:20 +02:00
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
for i in self.interfaces:
|
|
|
|
i.unconfig_ip6()
|
|
|
|
i.admin_down()
|
2018-05-04 14:20:06 +02:00
|
|
|
super(TestDHCPv6DataPlane, self).tearDown()
|
2018-05-25 14:02:20 +02:00
|
|
|
|
2018-05-04 14:20:06 +02:00
|
|
|
def test_dhcp_ia_na_send_solicit_receive_advertise(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""Verify DHCPv6 IA NA Solicit packet and Advertise event"""
|
2018-05-04 14:20:06 +02:00
|
|
|
|
2019-10-07 00:39:28 -07:00
|
|
|
self.vapi.dhcp6_clients_enable_disable(enable=1)
|
2018-05-04 14:20:06 +02:00
|
|
|
|
|
|
|
self.pg_enable_capture(self.pg_interfaces)
|
|
|
|
self.pg_start()
|
2022-04-26 19:02:15 +02:00
|
|
|
address = {"address": "1:2:3::5", "preferred_time": 60, "valid_time": 120}
|
2019-10-01 11:30:56 +02:00
|
|
|
self.vapi.dhcp6_send_client_message(
|
2022-04-26 19:02:15 +02:00
|
|
|
server_index=0xFFFFFFFF,
|
2019-10-07 00:39:28 -07:00
|
|
|
mrc=1,
|
2019-10-01 11:30:56 +02:00
|
|
|
msg_type=VppEnum.vl_api_dhcpv6_msg_type_t.DHCPV6_MSG_API_SOLICIT,
|
|
|
|
sw_if_index=self.pg0.sw_if_index,
|
|
|
|
T1=20,
|
|
|
|
T2=40,
|
|
|
|
addresses=[address],
|
2022-04-26 19:02:15 +02:00
|
|
|
n_addresses=len([address]),
|
|
|
|
)
|
2018-05-04 14:20:06 +02:00
|
|
|
rx_list = self.pg0.get_capture(1)
|
|
|
|
self.assertEqual(len(rx_list), 1)
|
|
|
|
packet = rx_list[0]
|
|
|
|
|
2018-11-24 22:19:12 -08:00
|
|
|
self.assertEqual(packet.haslayer(IPv6), 1)
|
|
|
|
self.assertEqual(packet[IPv6].haslayer(DHCP6_Solicit), 1)
|
2018-05-04 14:20:06 +02:00
|
|
|
|
|
|
|
client_duid = packet[DHCP6OptClientId].duid
|
|
|
|
trid = packet[DHCP6_Solicit].trid
|
|
|
|
|
|
|
|
dst = ip6_normalize(packet[IPv6].dst)
|
|
|
|
dst2 = ip6_normalize("ff02::1:2")
|
|
|
|
self.assert_equal(dst, dst2)
|
|
|
|
src = ip6_normalize(packet[IPv6].src)
|
|
|
|
src2 = ip6_normalize(self.pg0.local_ip6_ll)
|
|
|
|
self.assert_equal(src, src2)
|
|
|
|
ia_na = packet[DHCP6OptIA_NA]
|
|
|
|
self.assert_equal(ia_na.T1, 20)
|
|
|
|
self.assert_equal(ia_na.T2, 40)
|
|
|
|
self.assert_equal(len(ia_na.ianaopts), 1)
|
|
|
|
address = ia_na.ianaopts[0]
|
2022-04-26 19:02:15 +02:00
|
|
|
self.assert_equal(address.addr, "1:2:3::5")
|
2018-05-04 14:20:06 +02:00
|
|
|
self.assert_equal(address.preflft, 60)
|
|
|
|
self.assert_equal(address.validlft, 120)
|
|
|
|
|
2022-04-26 19:02:15 +02:00
|
|
|
self.vapi.want_dhcp6_reply_events(enable_disable=1, pid=os.getpid())
|
2018-05-04 14:20:06 +02:00
|
|
|
|
|
|
|
try:
|
2022-04-26 19:02:15 +02:00
|
|
|
ia_na_opts = DHCP6OptIAAddress(addr="7:8::2", preflft=60, validlft=120)
|
|
|
|
p = (
|
|
|
|
Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
|
|
|
|
/ IPv6(
|
|
|
|
src=util.mk_ll_addr(self.pg0.remote_mac), dst=self.pg0.local_ip6_ll
|
|
|
|
)
|
|
|
|
/ UDP(sport=547, dport=546)
|
|
|
|
/ DHCP6_Advertise(trid=trid)
|
|
|
|
/ DHCP6OptServerId(duid=self.server_duid)
|
|
|
|
/ DHCP6OptClientId(duid=client_duid)
|
|
|
|
/ DHCP6OptPref(prefval=7)
|
|
|
|
/ DHCP6OptStatusCode(statuscode=1)
|
|
|
|
/ DHCP6OptIA_NA(iaid=1, T1=20, T2=40, ianaopts=ia_na_opts)
|
|
|
|
)
|
2018-05-04 14:20:06 +02:00
|
|
|
self.pg0.add_stream([p])
|
|
|
|
self.pg_start()
|
|
|
|
|
|
|
|
ev = self.vapi.wait_for_event(1, "dhcp6_reply_event")
|
|
|
|
|
|
|
|
self.assert_equal(ev.preference, 7)
|
|
|
|
self.assert_equal(ev.status_code, 1)
|
|
|
|
self.assert_equal(ev.T1, 20)
|
|
|
|
self.assert_equal(ev.T2, 40)
|
|
|
|
|
|
|
|
reported_address = ev.addresses[0]
|
2019-10-01 11:30:56 +02:00
|
|
|
address = ia_na_opts.getfieldval("addr")
|
|
|
|
self.assert_equal(str(reported_address.address), address)
|
2022-04-26 19:02:15 +02:00
|
|
|
self.assert_equal(
|
|
|
|
reported_address.preferred_time, ia_na_opts.getfieldval("preflft")
|
|
|
|
)
|
|
|
|
self.assert_equal(
|
|
|
|
reported_address.valid_time, ia_na_opts.getfieldval("validlft")
|
|
|
|
)
|
2018-05-04 14:20:06 +02:00
|
|
|
|
|
|
|
finally:
|
|
|
|
self.vapi.want_dhcp6_reply_events(enable_disable=0)
|
2019-10-07 00:39:28 -07:00
|
|
|
self.vapi.dhcp6_clients_enable_disable(enable=0)
|
2018-05-04 14:20:06 +02:00
|
|
|
|
|
|
|
def test_dhcp_pd_send_solicit_receive_advertise(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""Verify DHCPv6 PD Solicit packet and Advertise event"""
|
2018-05-25 14:02:20 +02:00
|
|
|
|
2019-10-07 00:39:28 -07:00
|
|
|
self.vapi.dhcp6_clients_enable_disable(enable=1)
|
2018-06-12 10:21:05 +02:00
|
|
|
|
2018-05-25 14:02:20 +02:00
|
|
|
self.pg_enable_capture(self.pg_interfaces)
|
|
|
|
self.pg_start()
|
2019-10-01 11:30:56 +02:00
|
|
|
|
2022-04-26 19:02:15 +02:00
|
|
|
prefix = {
|
|
|
|
"prefix": {"address": "1:2:3::", "len": 50},
|
|
|
|
"preferred_time": 60,
|
|
|
|
"valid_time": 120,
|
|
|
|
}
|
2019-10-01 11:30:56 +02:00
|
|
|
prefixes = [prefix]
|
|
|
|
self.vapi.dhcp6_pd_send_client_message(
|
2022-04-26 19:02:15 +02:00
|
|
|
server_index=0xFFFFFFFF,
|
2019-10-07 00:39:28 -07:00
|
|
|
mrc=1,
|
2019-10-01 11:30:56 +02:00
|
|
|
msg_type=VppEnum.vl_api_dhcpv6_msg_type_t.DHCPV6_MSG_API_SOLICIT,
|
|
|
|
sw_if_index=self.pg0.sw_if_index,
|
|
|
|
T1=20,
|
|
|
|
T2=40,
|
|
|
|
prefixes=prefixes,
|
2022-04-26 19:02:15 +02:00
|
|
|
n_prefixes=len(prefixes),
|
|
|
|
)
|
2018-05-25 14:02:20 +02:00
|
|
|
rx_list = self.pg0.get_capture(1)
|
|
|
|
self.assertEqual(len(rx_list), 1)
|
|
|
|
packet = rx_list[0]
|
|
|
|
|
2018-11-24 22:19:12 -08:00
|
|
|
self.assertEqual(packet.haslayer(IPv6), 1)
|
|
|
|
self.assertEqual(packet[IPv6].haslayer(DHCP6_Solicit), 1)
|
2018-05-25 14:02:20 +02:00
|
|
|
|
|
|
|
client_duid = packet[DHCP6OptClientId].duid
|
|
|
|
trid = packet[DHCP6_Solicit].trid
|
|
|
|
|
|
|
|
dst = ip6_normalize(packet[IPv6].dst)
|
|
|
|
dst2 = ip6_normalize("ff02::1:2")
|
|
|
|
self.assert_equal(dst, dst2)
|
|
|
|
src = ip6_normalize(packet[IPv6].src)
|
|
|
|
src2 = ip6_normalize(self.pg0.local_ip6_ll)
|
|
|
|
self.assert_equal(src, src2)
|
|
|
|
ia_pd = packet[DHCP6OptIA_PD]
|
|
|
|
self.assert_equal(ia_pd.T1, 20)
|
|
|
|
self.assert_equal(ia_pd.T2, 40)
|
|
|
|
self.assert_equal(len(ia_pd.iapdopt), 1)
|
|
|
|
prefix = ia_pd.iapdopt[0]
|
2022-04-26 19:02:15 +02:00
|
|
|
self.assert_equal(prefix.prefix, "1:2:3::")
|
2018-05-25 14:02:20 +02:00
|
|
|
self.assert_equal(prefix.plen, 50)
|
|
|
|
self.assert_equal(prefix.preflft, 60)
|
|
|
|
self.assert_equal(prefix.validlft, 120)
|
|
|
|
|
2022-04-26 19:02:15 +02:00
|
|
|
self.vapi.want_dhcp6_pd_reply_events(enable_disable=1, pid=os.getpid())
|
2018-05-25 14:02:20 +02:00
|
|
|
|
2018-05-04 14:20:06 +02:00
|
|
|
try:
|
2022-04-26 19:02:15 +02:00
|
|
|
ia_pd_opts = DHCP6OptIAPrefix(
|
|
|
|
prefix="7:8::", plen=56, preflft=60, validlft=120
|
|
|
|
)
|
|
|
|
p = (
|
|
|
|
Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
|
|
|
|
/ IPv6(
|
|
|
|
src=util.mk_ll_addr(self.pg0.remote_mac), dst=self.pg0.local_ip6_ll
|
|
|
|
)
|
|
|
|
/ UDP(sport=547, dport=546)
|
|
|
|
/ DHCP6_Advertise(trid=trid)
|
|
|
|
/ DHCP6OptServerId(duid=self.server_duid)
|
|
|
|
/ DHCP6OptClientId(duid=client_duid)
|
|
|
|
/ DHCP6OptPref(prefval=7)
|
|
|
|
/ DHCP6OptStatusCode(statuscode=1)
|
|
|
|
/ DHCP6OptIA_PD(iaid=1, T1=20, T2=40, iapdopt=ia_pd_opts)
|
|
|
|
)
|
2018-05-04 14:20:06 +02:00
|
|
|
self.pg0.add_stream([p])
|
|
|
|
self.pg_start()
|
|
|
|
|
|
|
|
ev = self.vapi.wait_for_event(1, "dhcp6_pd_reply_event")
|
|
|
|
|
|
|
|
self.assert_equal(ev.preference, 7)
|
|
|
|
self.assert_equal(ev.status_code, 1)
|
|
|
|
self.assert_equal(ev.T1, 20)
|
|
|
|
self.assert_equal(ev.T2, 40)
|
|
|
|
|
|
|
|
reported_prefix = ev.prefixes[0]
|
2019-10-01 11:30:56 +02:00
|
|
|
prefix = ia_pd_opts.getfieldval("prefix")
|
2022-04-26 19:02:15 +02:00
|
|
|
self.assert_equal(str(reported_prefix.prefix).split("/")[0], prefix)
|
|
|
|
self.assert_equal(
|
|
|
|
int(str(reported_prefix.prefix).split("/")[1]),
|
|
|
|
ia_pd_opts.getfieldval("plen"),
|
|
|
|
)
|
2019-10-01 11:30:56 +02:00
|
|
|
self.assert_equal(
|
2022-04-26 19:02:15 +02:00
|
|
|
reported_prefix.preferred_time, ia_pd_opts.getfieldval("preflft")
|
|
|
|
)
|
|
|
|
self.assert_equal(
|
|
|
|
reported_prefix.valid_time, ia_pd_opts.getfieldval("validlft")
|
|
|
|
)
|
2018-05-04 14:20:06 +02:00
|
|
|
|
|
|
|
finally:
|
|
|
|
self.vapi.want_dhcp6_pd_reply_events(enable_disable=0)
|
2019-10-07 00:39:28 -07:00
|
|
|
self.vapi.dhcp6_clients_enable_disable(enable=0)
|
2018-05-04 14:20:06 +02:00
|
|
|
|
|
|
|
|
2021-01-14 10:19:08 +00:00
|
|
|
@tag_run_solo
|
2018-05-04 14:20:06 +02:00
|
|
|
class TestDHCPv6IANAControlPlane(VppTestCase):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""DHCPv6 IA NA Control Plane Test Case"""
|
2018-05-04 14:20:06 +02:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def setUpClass(cls):
|
|
|
|
super(TestDHCPv6IANAControlPlane, cls).setUpClass()
|
|
|
|
|
2019-03-12 19:23:27 -07:00
|
|
|
@classmethod
|
|
|
|
def tearDownClass(cls):
|
|
|
|
super(TestDHCPv6IANAControlPlane, cls).tearDownClass()
|
|
|
|
|
2018-05-04 14:20:06 +02:00
|
|
|
def setUp(self):
|
|
|
|
super(TestDHCPv6IANAControlPlane, self).setUp()
|
|
|
|
|
|
|
|
self.create_pg_interfaces(range(1))
|
|
|
|
self.interfaces = list(self.pg_interfaces)
|
|
|
|
for i in self.interfaces:
|
|
|
|
i.admin_up()
|
|
|
|
|
|
|
|
self.server_duid = DUID_LL(lladdr=self.pg0.remote_mac)
|
|
|
|
self.client_duid = None
|
|
|
|
self.T1 = 1
|
|
|
|
self.T2 = 2
|
|
|
|
|
2018-05-01 05:17:55 -07:00
|
|
|
fib = self.vapi.ip_route_dump(0, True)
|
2022-04-26 19:02:15 +02:00
|
|
|
self.initial_addresses = set(self.get_interface_addresses(fib, self.pg0))
|
2018-05-04 14:20:06 +02:00
|
|
|
|
|
|
|
self.pg_enable_capture(self.pg_interfaces)
|
|
|
|
self.pg_start()
|
|
|
|
|
2022-04-26 19:02:15 +02:00
|
|
|
self.vapi.dhcp6_client_enable_disable(
|
|
|
|
sw_if_index=self.pg0.sw_if_index, enable=1
|
|
|
|
)
|
2018-05-04 14:20:06 +02:00
|
|
|
|
|
|
|
def tearDown(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
self.vapi.dhcp6_client_enable_disable(
|
|
|
|
sw_if_index=self.pg0.sw_if_index, enable=0
|
|
|
|
)
|
2018-05-04 14:20:06 +02:00
|
|
|
|
|
|
|
for i in self.interfaces:
|
|
|
|
i.admin_down()
|
|
|
|
|
|
|
|
super(TestDHCPv6IANAControlPlane, self).tearDown()
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def get_interface_addresses(fib, pg):
|
|
|
|
lst = []
|
|
|
|
for entry in fib:
|
2018-05-01 05:17:55 -07:00
|
|
|
if entry.route.prefix.prefixlen == 128:
|
|
|
|
path = entry.route.paths[0]
|
2018-05-04 14:20:06 +02:00
|
|
|
if path.sw_if_index == pg.sw_if_index:
|
2018-05-01 05:17:55 -07:00
|
|
|
lst.append(str(entry.route.prefix.network_address))
|
2018-05-04 14:20:06 +02:00
|
|
|
return lst
|
|
|
|
|
|
|
|
def get_addresses(self):
|
2018-05-01 05:17:55 -07:00
|
|
|
fib = self.vapi.ip_route_dump(0, True)
|
2018-05-04 14:20:06 +02:00
|
|
|
addresses = set(self.get_interface_addresses(fib, self.pg0))
|
|
|
|
return addresses.difference(self.initial_addresses)
|
|
|
|
|
|
|
|
def validate_duid_ll(self, duid):
|
|
|
|
DUID_LL(duid)
|
|
|
|
|
|
|
|
def validate_packet(self, packet, msg_type, is_resend=False):
|
|
|
|
try:
|
2018-11-24 22:19:12 -08:00
|
|
|
self.assertEqual(packet.haslayer(msg_type), 1)
|
2018-05-04 14:20:06 +02:00
|
|
|
client_duid = packet[DHCP6OptClientId].duid
|
|
|
|
if self.client_duid is None:
|
|
|
|
self.client_duid = client_duid
|
|
|
|
self.validate_duid_ll(client_duid)
|
|
|
|
else:
|
|
|
|
self.assertEqual(self.client_duid, client_duid)
|
|
|
|
if msg_type != DHCP6_Solicit and msg_type != DHCP6_Rebind:
|
|
|
|
server_duid = packet[DHCP6OptServerId].duid
|
|
|
|
self.assertEqual(server_duid, self.server_duid)
|
|
|
|
if is_resend:
|
|
|
|
self.assertEqual(self.trid, packet[msg_type].trid)
|
|
|
|
else:
|
|
|
|
self.trid = packet[msg_type].trid
|
|
|
|
ip = packet[IPv6]
|
|
|
|
udp = packet[UDP]
|
2022-04-26 19:02:15 +02:00
|
|
|
self.assertEqual(ip.dst, "ff02::1:2")
|
2018-05-04 14:20:06 +02:00
|
|
|
self.assertEqual(udp.sport, 546)
|
|
|
|
self.assertEqual(udp.dport, 547)
|
|
|
|
dhcpv6 = packet[msg_type]
|
|
|
|
elapsed_time = dhcpv6[DHCP6OptElapsedTime]
|
2022-04-26 19:02:15 +02:00
|
|
|
if is_resend:
|
2018-05-04 14:20:06 +02:00
|
|
|
self.assertNotEqual(elapsed_time.elapsedtime, 0)
|
|
|
|
else:
|
|
|
|
self.assertEqual(elapsed_time.elapsedtime, 0)
|
2019-10-01 11:30:56 +02:00
|
|
|
except BaseException:
|
2018-05-04 14:20:06 +02:00
|
|
|
packet.show()
|
|
|
|
raise
|
|
|
|
|
|
|
|
def wait_for_packet(self, msg_type, timeout=None, is_resend=False):
|
|
|
|
if timeout is None:
|
|
|
|
timeout = 3
|
|
|
|
rx_list = self.pg0.get_capture(1, timeout=timeout)
|
|
|
|
packet = rx_list[0]
|
|
|
|
self.validate_packet(packet, msg_type, is_resend=is_resend)
|
|
|
|
|
|
|
|
def wait_for_solicit(self, timeout=None, is_resend=False):
|
|
|
|
self.wait_for_packet(DHCP6_Solicit, timeout, is_resend=is_resend)
|
|
|
|
|
|
|
|
def wait_for_request(self, timeout=None, is_resend=False):
|
|
|
|
self.wait_for_packet(DHCP6_Request, timeout, is_resend=is_resend)
|
|
|
|
|
|
|
|
def wait_for_renew(self, timeout=None, is_resend=False):
|
|
|
|
self.wait_for_packet(DHCP6_Renew, timeout, is_resend=is_resend)
|
|
|
|
|
|
|
|
def wait_for_rebind(self, timeout=None, is_resend=False):
|
|
|
|
self.wait_for_packet(DHCP6_Rebind, timeout, is_resend=is_resend)
|
|
|
|
|
|
|
|
def wait_for_release(self, timeout=None, is_resend=False):
|
|
|
|
self.wait_for_packet(DHCP6_Release, timeout, is_resend=is_resend)
|
|
|
|
|
|
|
|
def send_packet(self, msg_type, t1=None, t2=None, ianaopts=None):
|
|
|
|
if t1 is None:
|
|
|
|
t1 = self.T1
|
|
|
|
if t2 is None:
|
|
|
|
t2 = self.T2
|
|
|
|
if ianaopts is None:
|
|
|
|
opt_ia_na = DHCP6OptIA_NA(iaid=1, T1=t1, T2=t2)
|
|
|
|
else:
|
|
|
|
opt_ia_na = DHCP6OptIA_NA(iaid=1, T1=t1, T2=t2, ianaopts=ianaopts)
|
2022-04-26 19:02:15 +02:00
|
|
|
p = (
|
|
|
|
Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
|
|
|
|
/ IPv6(src=util.mk_ll_addr(self.pg0.remote_mac), dst=self.pg0.local_ip6_ll)
|
|
|
|
/ UDP(sport=547, dport=546)
|
|
|
|
/ msg_type(trid=self.trid)
|
|
|
|
/ DHCP6OptServerId(duid=self.server_duid)
|
|
|
|
/ DHCP6OptClientId(duid=self.client_duid)
|
|
|
|
/ opt_ia_na
|
|
|
|
)
|
2018-05-25 14:02:20 +02:00
|
|
|
self.pg0.add_stream([p])
|
2018-05-04 14:20:06 +02:00
|
|
|
self.pg_enable_capture(self.pg_interfaces)
|
2018-05-25 14:02:20 +02:00
|
|
|
self.pg_start()
|
|
|
|
|
2018-05-04 14:20:06 +02:00
|
|
|
def send_advertise(self, t1=None, t2=None, ianaopts=None):
|
|
|
|
self.send_packet(DHCP6_Advertise, t1, t2, ianaopts)
|
|
|
|
|
|
|
|
def send_reply(self, t1=None, t2=None, ianaopts=None):
|
|
|
|
self.send_packet(DHCP6_Reply, t1, t2, ianaopts)
|
|
|
|
|
|
|
|
def test_T1_and_T2_timeouts(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""Test T1 and T2 timeouts"""
|
2018-05-04 14:20:06 +02:00
|
|
|
|
|
|
|
self.wait_for_solicit()
|
|
|
|
self.send_advertise()
|
|
|
|
self.wait_for_request()
|
|
|
|
self.send_reply()
|
|
|
|
|
|
|
|
self.sleep(1)
|
|
|
|
|
|
|
|
self.wait_for_renew()
|
|
|
|
|
|
|
|
self.pg_enable_capture(self.pg_interfaces)
|
|
|
|
|
|
|
|
self.sleep(1)
|
|
|
|
|
|
|
|
self.wait_for_rebind()
|
|
|
|
|
|
|
|
def test_addresses(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""Test handling of addresses"""
|
2018-05-04 14:20:06 +02:00
|
|
|
|
2022-04-26 19:02:15 +02:00
|
|
|
ia_na_opts = DHCP6OptIAAddress(addr="7:8::2", preflft=1, validlft=2)
|
2018-05-04 14:20:06 +02:00
|
|
|
|
|
|
|
self.wait_for_solicit()
|
|
|
|
self.send_advertise(t1=20, t2=40, ianaopts=ia_na_opts)
|
|
|
|
self.wait_for_request()
|
|
|
|
self.send_reply(t1=20, t2=40, ianaopts=ia_na_opts)
|
|
|
|
self.sleep(0.1)
|
|
|
|
|
|
|
|
# check FIB for new address
|
|
|
|
new_addresses = self.get_addresses()
|
|
|
|
self.assertEqual(len(new_addresses), 1)
|
|
|
|
addr = list(new_addresses)[0]
|
2022-04-26 19:02:15 +02:00
|
|
|
self.assertEqual(addr, "7:8::2")
|
2018-05-04 14:20:06 +02:00
|
|
|
|
|
|
|
self.sleep(2)
|
|
|
|
|
|
|
|
# check that the address is deleted
|
2018-05-01 05:17:55 -07:00
|
|
|
fib = self.vapi.ip_route_dump(0, True)
|
2018-05-04 14:20:06 +02:00
|
|
|
addresses = set(self.get_interface_addresses(fib, self.pg0))
|
|
|
|
new_addresses = addresses.difference(self.initial_addresses)
|
|
|
|
self.assertEqual(len(new_addresses), 0)
|
|
|
|
|
|
|
|
def test_sending_client_messages_solicit(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""VPP receives messages from DHCPv6 client"""
|
2018-05-04 14:20:06 +02:00
|
|
|
|
|
|
|
self.wait_for_solicit()
|
|
|
|
self.send_packet(DHCP6_Solicit)
|
|
|
|
self.send_packet(DHCP6_Request)
|
|
|
|
self.send_packet(DHCP6_Renew)
|
|
|
|
self.send_packet(DHCP6_Rebind)
|
|
|
|
self.sleep(1)
|
|
|
|
self.wait_for_solicit(is_resend=True)
|
|
|
|
|
|
|
|
def test_sending_inappropriate_packets(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""Server sends messages with inappropriate message types"""
|
2018-05-04 14:20:06 +02:00
|
|
|
|
|
|
|
self.wait_for_solicit()
|
|
|
|
self.send_reply()
|
|
|
|
self.wait_for_solicit(is_resend=True)
|
|
|
|
self.send_advertise()
|
|
|
|
self.wait_for_request()
|
|
|
|
self.send_advertise()
|
|
|
|
self.wait_for_request(is_resend=True)
|
|
|
|
self.send_reply()
|
|
|
|
self.wait_for_renew()
|
|
|
|
|
|
|
|
def test_no_address_available_in_advertise(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""Advertise message contains NoAddrsAvail status code"""
|
2018-05-04 14:20:06 +02:00
|
|
|
|
|
|
|
self.wait_for_solicit()
|
|
|
|
noavail = DHCP6OptStatusCode(statuscode=2) # NoAddrsAvail
|
|
|
|
self.send_advertise(ianaopts=noavail)
|
|
|
|
self.wait_for_solicit(is_resend=True)
|
|
|
|
|
2019-03-27 11:25:48 -07:00
|
|
|
def test_preferred_greater_than_valid_lifetime(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""Preferred lifetime is greater than valid lifetime"""
|
2018-05-04 14:20:06 +02:00
|
|
|
|
|
|
|
self.wait_for_solicit()
|
|
|
|
self.send_advertise()
|
|
|
|
self.wait_for_request()
|
2022-04-26 19:02:15 +02:00
|
|
|
ia_na_opts = DHCP6OptIAAddress(addr="7:8::2", preflft=4, validlft=3)
|
2018-05-04 14:20:06 +02:00
|
|
|
self.send_reply(ianaopts=ia_na_opts)
|
2018-05-25 14:02:20 +02:00
|
|
|
|
2018-05-04 14:20:06 +02:00
|
|
|
self.sleep(0.5)
|
2018-05-25 14:02:20 +02:00
|
|
|
|
2018-05-04 14:20:06 +02:00
|
|
|
# check FIB contains no addresses
|
2018-05-01 05:17:55 -07:00
|
|
|
fib = self.vapi.ip_route_dump(0, True)
|
2018-05-04 14:20:06 +02:00
|
|
|
addresses = set(self.get_interface_addresses(fib, self.pg0))
|
|
|
|
new_addresses = addresses.difference(self.initial_addresses)
|
|
|
|
self.assertEqual(len(new_addresses), 0)
|
|
|
|
|
|
|
|
def test_T1_greater_than_T2(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""T1 is greater than T2"""
|
2018-05-04 14:20:06 +02:00
|
|
|
|
|
|
|
self.wait_for_solicit()
|
|
|
|
self.send_advertise()
|
|
|
|
self.wait_for_request()
|
2022-04-26 19:02:15 +02:00
|
|
|
ia_na_opts = DHCP6OptIAAddress(addr="7:8::2", preflft=4, validlft=8)
|
2018-05-04 14:20:06 +02:00
|
|
|
self.send_reply(t1=80, t2=40, ianaopts=ia_na_opts)
|
|
|
|
|
|
|
|
self.sleep(0.5)
|
|
|
|
|
|
|
|
# check FIB contains no addresses
|
2018-05-01 05:17:55 -07:00
|
|
|
fib = self.vapi.ip_route_dump(0, True)
|
2018-05-04 14:20:06 +02:00
|
|
|
addresses = set(self.get_interface_addresses(fib, self.pg0))
|
|
|
|
new_addresses = addresses.difference(self.initial_addresses)
|
|
|
|
self.assertEqual(len(new_addresses), 0)
|
2018-05-25 14:02:20 +02:00
|
|
|
|
|
|
|
|
2021-01-29 13:17:19 +00:00
|
|
|
@tag_fixme_vpp_workers
|
2018-05-25 14:02:20 +02:00
|
|
|
class TestDHCPv6PDControlPlane(VppTestCase):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""DHCPv6 PD Control Plane Test Case"""
|
2018-05-25 14:02:20 +02:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def setUpClass(cls):
|
|
|
|
super(TestDHCPv6PDControlPlane, cls).setUpClass()
|
|
|
|
|
2019-03-12 19:23:27 -07:00
|
|
|
@classmethod
|
|
|
|
def tearDownClass(cls):
|
|
|
|
super(TestDHCPv6PDControlPlane, cls).tearDownClass()
|
|
|
|
|
2018-05-25 14:02:20 +02:00
|
|
|
def setUp(self):
|
|
|
|
super(TestDHCPv6PDControlPlane, self).setUp()
|
|
|
|
|
|
|
|
self.create_pg_interfaces(range(2))
|
|
|
|
self.interfaces = list(self.pg_interfaces)
|
|
|
|
for i in self.interfaces:
|
|
|
|
i.admin_up()
|
|
|
|
|
2018-06-12 10:21:05 +02:00
|
|
|
self.server_duid = DUID_LL(lladdr=self.pg0.remote_mac)
|
2018-05-25 14:02:20 +02:00
|
|
|
self.client_duid = None
|
|
|
|
self.T1 = 1
|
|
|
|
self.T2 = 2
|
|
|
|
|
2018-05-01 05:17:55 -07:00
|
|
|
fib = self.vapi.ip_route_dump(0, True)
|
2022-04-26 19:02:15 +02:00
|
|
|
self.initial_addresses = set(self.get_interface_addresses(fib, self.pg1))
|
2018-05-25 14:02:20 +02:00
|
|
|
|
|
|
|
self.pg_enable_capture(self.pg_interfaces)
|
|
|
|
self.pg_start()
|
|
|
|
|
2022-04-26 19:02:15 +02:00
|
|
|
self.prefix_group = "my-pd-prefix-group"
|
2018-05-25 14:02:20 +02:00
|
|
|
|
|
|
|
self.vapi.dhcp6_pd_client_enable_disable(
|
2022-04-26 19:02:15 +02:00
|
|
|
enable=1, sw_if_index=self.pg0.sw_if_index, prefix_group=self.prefix_group
|
|
|
|
)
|
2018-05-25 14:02:20 +02:00
|
|
|
|
|
|
|
def tearDown(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
self.vapi.dhcp6_pd_client_enable_disable(self.pg0.sw_if_index, enable=0)
|
2018-05-25 14:02:20 +02:00
|
|
|
|
|
|
|
for i in self.interfaces:
|
|
|
|
i.admin_down()
|
|
|
|
|
|
|
|
super(TestDHCPv6PDControlPlane, self).tearDown()
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def get_interface_addresses(fib, pg):
|
|
|
|
lst = []
|
|
|
|
for entry in fib:
|
2018-05-01 05:17:55 -07:00
|
|
|
if entry.route.prefix.prefixlen == 128:
|
|
|
|
path = entry.route.paths[0]
|
2018-05-25 14:02:20 +02:00
|
|
|
if path.sw_if_index == pg.sw_if_index:
|
2018-05-01 05:17:55 -07:00
|
|
|
lst.append(str(entry.route.prefix.network_address))
|
2018-05-25 14:02:20 +02:00
|
|
|
return lst
|
|
|
|
|
|
|
|
def get_addresses(self):
|
2018-05-01 05:17:55 -07:00
|
|
|
fib = self.vapi.ip_route_dump(0, True)
|
2018-05-25 14:02:20 +02:00
|
|
|
addresses = set(self.get_interface_addresses(fib, self.pg1))
|
|
|
|
return addresses.difference(self.initial_addresses)
|
|
|
|
|
2018-06-12 10:21:05 +02:00
|
|
|
def validate_duid_ll(self, duid):
|
|
|
|
DUID_LL(duid)
|
2018-05-25 14:02:20 +02:00
|
|
|
|
|
|
|
def validate_packet(self, packet, msg_type, is_resend=False):
|
|
|
|
try:
|
2018-11-24 22:19:12 -08:00
|
|
|
self.assertEqual(packet.haslayer(msg_type), 1)
|
2018-05-25 14:02:20 +02:00
|
|
|
client_duid = packet[DHCP6OptClientId].duid
|
|
|
|
if self.client_duid is None:
|
|
|
|
self.client_duid = client_duid
|
2018-06-12 10:21:05 +02:00
|
|
|
self.validate_duid_ll(client_duid)
|
2018-05-25 14:02:20 +02:00
|
|
|
else:
|
|
|
|
self.assertEqual(self.client_duid, client_duid)
|
|
|
|
if msg_type != DHCP6_Solicit and msg_type != DHCP6_Rebind:
|
|
|
|
server_duid = packet[DHCP6OptServerId].duid
|
|
|
|
self.assertEqual(server_duid, self.server_duid)
|
|
|
|
if is_resend:
|
|
|
|
self.assertEqual(self.trid, packet[msg_type].trid)
|
|
|
|
else:
|
|
|
|
self.trid = packet[msg_type].trid
|
|
|
|
ip = packet[IPv6]
|
|
|
|
udp = packet[UDP]
|
2022-04-26 19:02:15 +02:00
|
|
|
self.assertEqual(ip.dst, "ff02::1:2")
|
2018-05-25 14:02:20 +02:00
|
|
|
self.assertEqual(udp.sport, 546)
|
|
|
|
self.assertEqual(udp.dport, 547)
|
|
|
|
dhcpv6 = packet[msg_type]
|
|
|
|
elapsed_time = dhcpv6[DHCP6OptElapsedTime]
|
2022-04-26 19:02:15 +02:00
|
|
|
if is_resend:
|
2018-05-25 14:02:20 +02:00
|
|
|
self.assertNotEqual(elapsed_time.elapsedtime, 0)
|
|
|
|
else:
|
|
|
|
self.assertEqual(elapsed_time.elapsedtime, 0)
|
2019-10-01 11:30:56 +02:00
|
|
|
except BaseException:
|
2018-05-25 14:02:20 +02:00
|
|
|
packet.show()
|
|
|
|
raise
|
|
|
|
|
|
|
|
def wait_for_packet(self, msg_type, timeout=None, is_resend=False):
|
|
|
|
if timeout is None:
|
|
|
|
timeout = 3
|
|
|
|
rx_list = self.pg0.get_capture(1, timeout=timeout)
|
|
|
|
packet = rx_list[0]
|
|
|
|
self.validate_packet(packet, msg_type, is_resend=is_resend)
|
|
|
|
|
|
|
|
def wait_for_solicit(self, timeout=None, is_resend=False):
|
|
|
|
self.wait_for_packet(DHCP6_Solicit, timeout, is_resend=is_resend)
|
|
|
|
|
|
|
|
def wait_for_request(self, timeout=None, is_resend=False):
|
|
|
|
self.wait_for_packet(DHCP6_Request, timeout, is_resend=is_resend)
|
|
|
|
|
|
|
|
def wait_for_renew(self, timeout=None, is_resend=False):
|
|
|
|
self.wait_for_packet(DHCP6_Renew, timeout, is_resend=is_resend)
|
|
|
|
|
|
|
|
def wait_for_rebind(self, timeout=None, is_resend=False):
|
|
|
|
self.wait_for_packet(DHCP6_Rebind, timeout, is_resend=is_resend)
|
|
|
|
|
|
|
|
def wait_for_release(self, timeout=None, is_resend=False):
|
|
|
|
self.wait_for_packet(DHCP6_Release, timeout, is_resend=is_resend)
|
|
|
|
|
|
|
|
def send_packet(self, msg_type, t1=None, t2=None, iapdopt=None):
|
|
|
|
if t1 is None:
|
|
|
|
t1 = self.T1
|
|
|
|
if t2 is None:
|
|
|
|
t2 = self.T2
|
|
|
|
if iapdopt is None:
|
|
|
|
opt_ia_pd = DHCP6OptIA_PD(iaid=1, T1=t1, T2=t2)
|
|
|
|
else:
|
|
|
|
opt_ia_pd = DHCP6OptIA_PD(iaid=1, T1=t1, T2=t2, iapdopt=iapdopt)
|
2022-04-26 19:02:15 +02:00
|
|
|
p = (
|
|
|
|
Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
|
|
|
|
/ IPv6(src=util.mk_ll_addr(self.pg0.remote_mac), dst=self.pg0.local_ip6_ll)
|
|
|
|
/ UDP(sport=547, dport=546)
|
|
|
|
/ msg_type(trid=self.trid)
|
|
|
|
/ DHCP6OptServerId(duid=self.server_duid)
|
|
|
|
/ DHCP6OptClientId(duid=self.client_duid)
|
|
|
|
/ opt_ia_pd
|
|
|
|
)
|
2018-05-25 14:02:20 +02:00
|
|
|
self.pg0.add_stream([p])
|
|
|
|
self.pg_enable_capture(self.pg_interfaces)
|
|
|
|
self.pg_start()
|
|
|
|
|
|
|
|
def send_advertise(self, t1=None, t2=None, iapdopt=None):
|
|
|
|
self.send_packet(DHCP6_Advertise, t1, t2, iapdopt)
|
|
|
|
|
|
|
|
def send_reply(self, t1=None, t2=None, iapdopt=None):
|
|
|
|
self.send_packet(DHCP6_Reply, t1, t2, iapdopt)
|
|
|
|
|
|
|
|
def test_T1_and_T2_timeouts(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""Test T1 and T2 timeouts"""
|
2018-05-25 14:02:20 +02:00
|
|
|
|
|
|
|
self.wait_for_solicit()
|
|
|
|
self.send_advertise()
|
|
|
|
self.wait_for_request()
|
|
|
|
self.send_reply()
|
|
|
|
|
|
|
|
self.sleep(1)
|
|
|
|
|
|
|
|
self.wait_for_renew()
|
|
|
|
|
|
|
|
self.pg_enable_capture(self.pg_interfaces)
|
|
|
|
|
|
|
|
self.sleep(1)
|
|
|
|
|
|
|
|
self.wait_for_rebind()
|
|
|
|
|
|
|
|
def test_prefixes(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""Test handling of prefixes"""
|
2018-05-04 14:20:06 +02:00
|
|
|
|
2022-04-26 19:02:15 +02:00
|
|
|
address1 = "::2:0:0:0:405/60"
|
|
|
|
address2 = "::76:0:0:0:406/62"
|
2018-05-25 14:02:20 +02:00
|
|
|
try:
|
2019-09-30 13:06:48 +02:00
|
|
|
self.vapi.ip6_add_del_address_using_prefix(
|
|
|
|
sw_if_index=self.pg1.sw_if_index,
|
|
|
|
address_with_prefix=address1,
|
2022-04-26 19:02:15 +02:00
|
|
|
prefix_group=self.prefix_group,
|
|
|
|
)
|
2018-05-25 14:02:20 +02:00
|
|
|
|
2022-04-26 19:02:15 +02:00
|
|
|
ia_pd_opts = DHCP6OptIAPrefix(
|
|
|
|
prefix="7:8::", plen=56, preflft=2, validlft=3
|
|
|
|
)
|
2018-05-25 14:02:20 +02:00
|
|
|
|
|
|
|
self.wait_for_solicit()
|
|
|
|
self.send_advertise(t1=20, t2=40, iapdopt=ia_pd_opts)
|
|
|
|
self.wait_for_request()
|
|
|
|
self.send_reply(t1=20, t2=40, iapdopt=ia_pd_opts)
|
|
|
|
self.sleep(0.1)
|
|
|
|
|
|
|
|
# check FIB for new address
|
|
|
|
new_addresses = self.get_addresses()
|
|
|
|
self.assertEqual(len(new_addresses), 1)
|
|
|
|
addr = list(new_addresses)[0]
|
2022-04-26 19:02:15 +02:00
|
|
|
self.assertEqual(addr, "7:8:0:2::405")
|
2018-05-25 14:02:20 +02:00
|
|
|
|
|
|
|
self.sleep(1)
|
|
|
|
|
2019-09-30 13:06:48 +02:00
|
|
|
self.vapi.ip6_add_del_address_using_prefix(
|
|
|
|
sw_if_index=self.pg1.sw_if_index,
|
|
|
|
address_with_prefix=address2,
|
2022-04-26 19:02:15 +02:00
|
|
|
prefix_group=self.prefix_group,
|
|
|
|
)
|
2018-05-25 14:02:20 +02:00
|
|
|
|
|
|
|
self.sleep(1)
|
|
|
|
|
|
|
|
# check FIB contains 2 addresses
|
2018-05-01 05:17:55 -07:00
|
|
|
fib = self.vapi.ip_route_dump(0, True)
|
2018-05-25 14:02:20 +02:00
|
|
|
addresses = set(self.get_interface_addresses(fib, self.pg1))
|
|
|
|
new_addresses = addresses.difference(self.initial_addresses)
|
|
|
|
self.assertEqual(len(new_addresses), 2)
|
|
|
|
addr1 = list(new_addresses)[0]
|
|
|
|
addr2 = list(new_addresses)[1]
|
2022-04-26 19:02:15 +02:00
|
|
|
if addr1 == "7:8:0:76::406":
|
2018-05-25 14:02:20 +02:00
|
|
|
addr1, addr2 = addr2, addr1
|
2022-04-26 19:02:15 +02:00
|
|
|
self.assertEqual(addr1, "7:8:0:2::405")
|
|
|
|
self.assertEqual(addr2, "7:8:0:76::406")
|
2018-05-25 14:02:20 +02:00
|
|
|
|
|
|
|
self.sleep(1)
|
|
|
|
|
|
|
|
# check that the addresses are deleted
|
2018-05-01 05:17:55 -07:00
|
|
|
fib = self.vapi.ip_route_dump(0, True)
|
2018-05-25 14:02:20 +02:00
|
|
|
addresses = set(self.get_interface_addresses(fib, self.pg1))
|
|
|
|
new_addresses = addresses.difference(self.initial_addresses)
|
|
|
|
self.assertEqual(len(new_addresses), 0)
|
|
|
|
|
|
|
|
finally:
|
2019-09-30 13:06:48 +02:00
|
|
|
if address1 is not None:
|
2018-05-25 14:02:20 +02:00
|
|
|
self.vapi.ip6_add_del_address_using_prefix(
|
2019-09-30 13:06:48 +02:00
|
|
|
sw_if_index=self.pg1.sw_if_index,
|
|
|
|
address_with_prefix=address1,
|
2022-04-26 19:02:15 +02:00
|
|
|
prefix_group=self.prefix_group,
|
|
|
|
is_add=0,
|
|
|
|
)
|
2019-09-30 13:06:48 +02:00
|
|
|
if address2 is not None:
|
2018-05-25 14:02:20 +02:00
|
|
|
self.vapi.ip6_add_del_address_using_prefix(
|
2019-09-30 13:06:48 +02:00
|
|
|
sw_if_index=self.pg1.sw_if_index,
|
|
|
|
address_with_prefix=address2,
|
2022-04-26 19:02:15 +02:00
|
|
|
prefix_group=self.prefix_group,
|
|
|
|
is_add=0,
|
|
|
|
)
|
2018-05-25 14:02:20 +02:00
|
|
|
|
|
|
|
def test_sending_client_messages_solicit(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""VPP receives messages from DHCPv6 client"""
|
2018-05-25 14:02:20 +02:00
|
|
|
|
|
|
|
self.wait_for_solicit()
|
|
|
|
self.send_packet(DHCP6_Solicit)
|
|
|
|
self.send_packet(DHCP6_Request)
|
|
|
|
self.send_packet(DHCP6_Renew)
|
|
|
|
self.send_packet(DHCP6_Rebind)
|
|
|
|
self.sleep(1)
|
|
|
|
self.wait_for_solicit(is_resend=True)
|
|
|
|
|
2018-05-04 14:20:06 +02:00
|
|
|
def test_sending_inappropriate_packets(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""Server sends messages with inappropriate message types"""
|
2018-05-25 14:02:20 +02:00
|
|
|
|
|
|
|
self.wait_for_solicit()
|
|
|
|
self.send_reply()
|
|
|
|
self.wait_for_solicit(is_resend=True)
|
|
|
|
self.send_advertise()
|
|
|
|
self.wait_for_request()
|
|
|
|
self.send_advertise()
|
|
|
|
self.wait_for_request(is_resend=True)
|
|
|
|
self.send_reply()
|
|
|
|
self.wait_for_renew()
|
|
|
|
|
|
|
|
def test_no_prefix_available_in_advertise(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""Advertise message contains NoPrefixAvail status code"""
|
2018-05-25 14:02:20 +02:00
|
|
|
|
|
|
|
self.wait_for_solicit()
|
|
|
|
noavail = DHCP6OptStatusCode(statuscode=6) # NoPrefixAvail
|
|
|
|
self.send_advertise(iapdopt=noavail)
|
|
|
|
self.wait_for_solicit(is_resend=True)
|
|
|
|
|
2019-03-27 11:25:48 -07:00
|
|
|
def test_preferred_greater_than_valid_lifetime(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""Preferred lifetime is greater than valid lifetime"""
|
2018-05-25 14:02:20 +02:00
|
|
|
|
2022-04-26 19:02:15 +02:00
|
|
|
address1 = "::2:0:0:0:405/60"
|
2018-05-25 14:02:20 +02:00
|
|
|
try:
|
2019-09-30 13:06:48 +02:00
|
|
|
self.vapi.ip6_add_del_address_using_prefix(
|
|
|
|
sw_if_index=self.pg1.sw_if_index,
|
|
|
|
address_with_prefix=address1,
|
2022-04-26 19:02:15 +02:00
|
|
|
prefix_group=self.prefix_group,
|
|
|
|
)
|
2018-05-25 14:02:20 +02:00
|
|
|
|
|
|
|
self.wait_for_solicit()
|
|
|
|
self.send_advertise()
|
|
|
|
self.wait_for_request()
|
2022-04-26 19:02:15 +02:00
|
|
|
ia_pd_opts = DHCP6OptIAPrefix(
|
|
|
|
prefix="7:8::", plen=56, preflft=4, validlft=3
|
|
|
|
)
|
2018-05-25 14:02:20 +02:00
|
|
|
self.send_reply(iapdopt=ia_pd_opts)
|
|
|
|
|
|
|
|
self.sleep(0.5)
|
|
|
|
|
|
|
|
# check FIB contains no addresses
|
2018-05-01 05:17:55 -07:00
|
|
|
fib = self.vapi.ip_route_dump(0, True)
|
2018-05-25 14:02:20 +02:00
|
|
|
addresses = set(self.get_interface_addresses(fib, self.pg1))
|
|
|
|
new_addresses = addresses.difference(self.initial_addresses)
|
|
|
|
self.assertEqual(len(new_addresses), 0)
|
|
|
|
|
|
|
|
finally:
|
2019-09-30 13:06:48 +02:00
|
|
|
self.vapi.ip6_add_del_address_using_prefix(
|
|
|
|
sw_if_index=self.pg1.sw_if_index,
|
|
|
|
address_with_prefix=address1,
|
|
|
|
prefix_group=self.prefix_group,
|
2022-04-26 19:02:15 +02:00
|
|
|
is_add=0,
|
|
|
|
)
|
2018-05-25 14:02:20 +02:00
|
|
|
|
|
|
|
def test_T1_greater_than_T2(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""T1 is greater than T2"""
|
2018-05-25 14:02:20 +02:00
|
|
|
|
2022-04-26 19:02:15 +02:00
|
|
|
address1 = "::2:0:0:0:405/60"
|
2018-05-25 14:02:20 +02:00
|
|
|
try:
|
2019-09-30 13:06:48 +02:00
|
|
|
self.vapi.ip6_add_del_address_using_prefix(
|
|
|
|
sw_if_index=self.pg1.sw_if_index,
|
|
|
|
address_with_prefix=address1,
|
2022-04-26 19:02:15 +02:00
|
|
|
prefix_group=self.prefix_group,
|
|
|
|
)
|
2018-05-25 14:02:20 +02:00
|
|
|
|
|
|
|
self.wait_for_solicit()
|
|
|
|
self.send_advertise()
|
|
|
|
self.wait_for_request()
|
2022-04-26 19:02:15 +02:00
|
|
|
ia_pd_opts = DHCP6OptIAPrefix(
|
|
|
|
prefix="7:8::", plen=56, preflft=4, validlft=8
|
|
|
|
)
|
2018-05-25 14:02:20 +02:00
|
|
|
self.send_reply(t1=80, t2=40, iapdopt=ia_pd_opts)
|
|
|
|
|
|
|
|
self.sleep(0.5)
|
|
|
|
|
|
|
|
# check FIB contains no addresses
|
2018-05-01 05:17:55 -07:00
|
|
|
fib = self.vapi.ip_route_dump(0, True)
|
2018-05-25 14:02:20 +02:00
|
|
|
addresses = set(self.get_interface_addresses(fib, self.pg1))
|
|
|
|
new_addresses = addresses.difference(self.initial_addresses)
|
|
|
|
self.assertEqual(len(new_addresses), 0)
|
|
|
|
|
|
|
|
finally:
|
2019-09-30 13:06:48 +02:00
|
|
|
self.vapi.ip6_add_del_address_using_prefix(
|
|
|
|
sw_if_index=self.pg1.sw_if_index,
|
|
|
|
prefix_group=self.prefix_group,
|
|
|
|
address_with_prefix=address1,
|
2022-04-26 19:02:15 +02:00
|
|
|
is_add=False,
|
|
|
|
)
|