Renato Botelho do Couto | ead1e53 | 2019-10-31 13:31:07 -0500 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 2 | |
| 3 | import unittest |
| 4 | import socket |
Ole Troan | 12966a7 | 2019-10-18 14:33:54 +0200 | [diff] [blame] | 5 | import six |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 6 | |
Dave Wallace | 8800f73 | 2023-08-31 00:47:44 -0400 | [diff] [blame] | 7 | from framework import VppTestCase |
| 8 | from asfframework import VppTestRunner, tag_run_solo |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 9 | from vpp_neighbor import VppNeighbor |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 10 | from vpp_ip_route import find_route, VppIpTable |
Neale Ranns | 2a3ea49 | 2017-04-19 05:24:40 -0700 | [diff] [blame] | 11 | from util import mk_ll_addr |
Paul Vinciguerra | a7427ec | 2019-03-10 10:04:23 -0700 | [diff] [blame] | 12 | import scapy.compat |
Dave Wallace | 8800f73 | 2023-08-31 00:47:44 -0400 | [diff] [blame] | 13 | from scapy.layers.l2 import Ether, ARP, Dot1Q |
| 14 | from scapy.layers.inet import IP, UDP |
Neale Ranns | 2bc9402 | 2018-02-25 12:27:18 -0800 | [diff] [blame] | 15 | from scapy.layers.inet6 import IPv6, in6_getnsmac |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 16 | from scapy.layers.dhcp import DHCP, BOOTP, DHCPTypes |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 17 | from scapy.layers.dhcp6 import ( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 18 | DHCP6_Solicit, |
| 19 | DHCP6_RelayForward, |
| 20 | DHCP6_RelayReply, |
| 21 | DHCP6_Advertise, |
| 22 | DHCP6OptRelayMsg, |
| 23 | DHCP6OptIfaceId, |
| 24 | DHCP6OptStatusCode, |
| 25 | DHCP6OptVSS, |
| 26 | DHCP6OptClientLinkLayerAddr, |
| 27 | DHCP6_Request, |
| 28 | ) |
Dave Wallace | 8800f73 | 2023-08-31 00:47:44 -0400 | [diff] [blame] | 29 | from socket import AF_INET, AF_INET6, inet_pton |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 30 | from scapy.utils6 import in6_ptop |
Neale Ranns | 038e1df | 2019-07-19 14:01:02 +0000 | [diff] [blame] | 31 | from vpp_papi import mac_pton, VppEnum |
| 32 | from vpp_sub_interface import VppDot1QSubint |
| 33 | from vpp_qos import VppQosEgressMap, VppQosMark |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 34 | from vpp_dhcp import VppDHCPClient, VppDHCPProxy |
Dmitry Valter | 34fa0ce | 2024-03-11 10:38:46 +0000 | [diff] [blame] | 35 | from config import config |
Neale Ranns | 038e1df | 2019-07-19 14:01:02 +0000 | [diff] [blame] | 36 | |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 37 | |
| 38 | DHCP4_CLIENT_PORT = 68 |
| 39 | DHCP4_SERVER_PORT = 67 |
| 40 | DHCP6_CLIENT_PORT = 547 |
| 41 | DHCP6_SERVER_PORT = 546 |
| 42 | |
| 43 | |
Andrew Yourtchenko | 06f3281 | 2021-01-14 10:19:08 +0000 | [diff] [blame] | 44 | @tag_run_solo |
Dmitry Valter | 34fa0ce | 2024-03-11 10:38:46 +0000 | [diff] [blame] | 45 | @unittest.skipIf("dhcp" in config.excluded_plugins, "Exclude DHCP plugin tests") |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 46 | class TestDHCP(VppTestCase): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 47 | """DHCP Test Case""" |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 48 | |
Paul Vinciguerra | 7f9b7f9 | 2019-03-12 19:23:27 -0700 | [diff] [blame] | 49 | @classmethod |
| 50 | def setUpClass(cls): |
| 51 | super(TestDHCP, cls).setUpClass() |
| 52 | |
| 53 | @classmethod |
| 54 | def tearDownClass(cls): |
| 55 | super(TestDHCP, cls).tearDownClass() |
| 56 | |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 57 | def setUp(self): |
| 58 | super(TestDHCP, self).setUp() |
| 59 | |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 60 | # create 6 pg interfaces for pg0 to pg5 |
| 61 | self.create_pg_interfaces(range(6)) |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 62 | self.tables = [] |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 63 | |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 64 | # pg0 to 2 are IP configured in VRF 0, 1 and 2. |
| 65 | # pg3 to 5 are non IP-configured in VRF 0, 1 and 2. |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 66 | table_id = 0 |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 67 | for table_id in range(1, 4): |
| 68 | tbl4 = VppIpTable(self, table_id) |
| 69 | tbl4.add_vpp_config() |
| 70 | self.tables.append(tbl4) |
| 71 | tbl6 = VppIpTable(self, table_id, is_ip6=1) |
| 72 | tbl6.add_vpp_config() |
| 73 | self.tables.append(tbl6) |
| 74 | |
| 75 | table_id = 0 |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 76 | for i in self.pg_interfaces[:3]: |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 77 | i.admin_up() |
| 78 | i.set_table_ip4(table_id) |
| 79 | i.set_table_ip6(table_id) |
| 80 | i.config_ip4() |
| 81 | i.resolve_arp() |
| 82 | i.config_ip6() |
| 83 | i.resolve_ndp() |
| 84 | table_id += 1 |
| 85 | |
| 86 | table_id = 0 |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 87 | for i in self.pg_interfaces[3:]: |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 88 | i.admin_up() |
| 89 | i.set_table_ip4(table_id) |
| 90 | i.set_table_ip6(table_id) |
| 91 | table_id += 1 |
| 92 | |
Neale Ranns | 4008ac9 | 2017-02-13 23:20:04 -0800 | [diff] [blame] | 93 | def tearDown(self): |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 94 | for i in self.pg_interfaces[:3]: |
Neale Ranns | 4008ac9 | 2017-02-13 23:20:04 -0800 | [diff] [blame] | 95 | i.unconfig_ip4() |
| 96 | i.unconfig_ip6() |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 97 | |
| 98 | for i in self.pg_interfaces: |
| 99 | i.set_table_ip4(0) |
| 100 | i.set_table_ip6(0) |
Neale Ranns | 4008ac9 | 2017-02-13 23:20:04 -0800 | [diff] [blame] | 101 | i.admin_down() |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 102 | super(TestDHCP, self).tearDown() |
Neale Ranns | 4008ac9 | 2017-02-13 23:20:04 -0800 | [diff] [blame] | 103 | |
Neale Ranns | a2fbf6b | 2017-07-18 08:23:32 -0700 | [diff] [blame] | 104 | def verify_dhcp_has_option(self, pkt, option, value): |
| 105 | dhcp = pkt[DHCP] |
| 106 | found = False |
| 107 | |
| 108 | for i in dhcp.options: |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 109 | if isinstance(i, tuple): |
Neale Ranns | a2fbf6b | 2017-07-18 08:23:32 -0700 | [diff] [blame] | 110 | if i[0] == option: |
| 111 | self.assertEqual(i[1], value) |
| 112 | found = True |
| 113 | |
| 114 | self.assertTrue(found) |
| 115 | |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 116 | def validate_relay_options(self, pkt, intf, ip_addr, vpn_id, fib_id, oui): |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 117 | dhcp = pkt[DHCP] |
| 118 | found = 0 |
| 119 | data = [] |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 120 | id_len = len(vpn_id) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 121 | |
| 122 | for i in dhcp.options: |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 123 | if isinstance(i, tuple): |
Dave Wallace | cf9356d | 2024-07-23 01:28:19 -0400 | [diff] [blame^] | 124 | if i[0] == "relay_agent_information": |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 125 | # |
| 126 | # There are two sb-options present - each of length 6. |
| 127 | # |
| 128 | data = i[1] |
Neale Ranns | 20a175a | 2017-02-14 07:28:41 -0800 | [diff] [blame] | 129 | if oui != 0: |
| 130 | self.assertEqual(len(data), 24) |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 131 | elif len(vpn_id) > 0: |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 132 | self.assertEqual(len(data), len(vpn_id) + 17) |
Neale Ranns | 20a175a | 2017-02-14 07:28:41 -0800 | [diff] [blame] | 133 | else: |
| 134 | self.assertEqual(len(data), 12) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 135 | |
| 136 | # |
| 137 | # First sub-option is ID 1, len 4, then encoded |
| 138 | # sw_if_index. This test uses low valued indicies |
| 139 | # so [2:4] are 0. |
| 140 | # The ID space is VPP internal - so no matching value |
| 141 | # scapy |
| 142 | # |
Ole Troan | 12966a7 | 2019-10-18 14:33:54 +0200 | [diff] [blame] | 143 | self.assertEqual(six.byte2int(data[0:1]), 1) |
| 144 | self.assertEqual(six.byte2int(data[1:2]), 4) |
| 145 | self.assertEqual(six.byte2int(data[2:3]), 0) |
| 146 | self.assertEqual(six.byte2int(data[3:4]), 0) |
| 147 | self.assertEqual(six.byte2int(data[4:5]), 0) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 148 | self.assertEqual(six.byte2int(data[5:6]), intf._sw_if_index) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 149 | |
| 150 | # |
| 151 | # next sub-option is the IP address of the client side |
| 152 | # interface. |
| 153 | # sub-option ID=5, length (of a v4 address)=4 |
| 154 | # |
| 155 | claddr = socket.inet_pton(AF_INET, ip_addr) |
| 156 | |
Ole Troan | 12966a7 | 2019-10-18 14:33:54 +0200 | [diff] [blame] | 157 | self.assertEqual(six.byte2int(data[6:7]), 5) |
| 158 | self.assertEqual(six.byte2int(data[7:8]), 4) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 159 | self.assertEqual(data[8], claddr[0]) |
| 160 | self.assertEqual(data[9], claddr[1]) |
| 161 | self.assertEqual(data[10], claddr[2]) |
| 162 | self.assertEqual(data[11], claddr[3]) |
| 163 | |
Neale Ranns | 20a175a | 2017-02-14 07:28:41 -0800 | [diff] [blame] | 164 | if oui != 0: |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 165 | # sub-option 151 encodes vss_type 1, |
| 166 | # the 3 byte oui and the 4 byte fib_id |
| 167 | self.assertEqual(id_len, 0) |
Ole Troan | 12966a7 | 2019-10-18 14:33:54 +0200 | [diff] [blame] | 168 | self.assertEqual(six.byte2int(data[12:13]), 151) |
| 169 | self.assertEqual(six.byte2int(data[13:14]), 8) |
| 170 | self.assertEqual(six.byte2int(data[14:15]), 1) |
| 171 | self.assertEqual(six.byte2int(data[15:16]), 0) |
| 172 | self.assertEqual(six.byte2int(data[16:17]), 0) |
| 173 | self.assertEqual(six.byte2int(data[17:18]), oui) |
| 174 | self.assertEqual(six.byte2int(data[18:19]), 0) |
| 175 | self.assertEqual(six.byte2int(data[19:20]), 0) |
| 176 | self.assertEqual(six.byte2int(data[20:21]), 0) |
| 177 | self.assertEqual(six.byte2int(data[21:22]), fib_id) |
Neale Ranns | 20a175a | 2017-02-14 07:28:41 -0800 | [diff] [blame] | 178 | |
| 179 | # VSS control sub-option |
Ole Troan | 12966a7 | 2019-10-18 14:33:54 +0200 | [diff] [blame] | 180 | self.assertEqual(six.byte2int(data[22:23]), 152) |
| 181 | self.assertEqual(six.byte2int(data[23:24]), 0) |
Neale Ranns | 20a175a | 2017-02-14 07:28:41 -0800 | [diff] [blame] | 182 | |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 183 | if id_len > 0: |
| 184 | # sub-option 151 encode vss_type of 0 |
| 185 | # followerd by vpn_id in ascii |
| 186 | self.assertEqual(oui, 0) |
Ole Troan | 12966a7 | 2019-10-18 14:33:54 +0200 | [diff] [blame] | 187 | self.assertEqual(six.byte2int(data[12:13]), 151) |
| 188 | self.assertEqual(six.byte2int(data[13:14]), id_len + 1) |
| 189 | self.assertEqual(six.byte2int(data[14:15]), 0) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 190 | self.assertEqual(data[15 : 15 + id_len].decode("ascii"), vpn_id) |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 191 | |
| 192 | # VSS control sub-option |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 193 | self.assertEqual( |
| 194 | six.byte2int(data[15 + len(vpn_id) : 16 + len(vpn_id)]), 152 |
| 195 | ) |
| 196 | self.assertEqual( |
| 197 | six.byte2int(data[16 + len(vpn_id) : 17 + len(vpn_id)]), 0 |
| 198 | ) |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 199 | |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 200 | found = 1 |
| 201 | self.assertTrue(found) |
| 202 | |
| 203 | return data |
| 204 | |
Neale Ranns | a2fbf6b | 2017-07-18 08:23:32 -0700 | [diff] [blame] | 205 | def verify_dhcp_msg_type(self, pkt, name): |
| 206 | dhcp = pkt[DHCP] |
| 207 | found = False |
| 208 | for o in dhcp.options: |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 209 | if isinstance(o, tuple): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 210 | if o[0] == "message-type" and DHCPTypes[o[1]] == name: |
Neale Ranns | a2fbf6b | 2017-07-18 08:23:32 -0700 | [diff] [blame] | 211 | found = True |
| 212 | self.assertTrue(found) |
| 213 | |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 214 | def verify_dhcp_offer(self, pkt, intf, vpn_id="", fib_id=0, oui=0): |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 215 | ether = pkt[Ether] |
| 216 | self.assertEqual(ether.dst, "ff:ff:ff:ff:ff:ff") |
| 217 | self.assertEqual(ether.src, intf.local_mac) |
| 218 | |
| 219 | ip = pkt[IP] |
| 220 | self.assertEqual(ip.dst, "255.255.255.255") |
| 221 | self.assertEqual(ip.src, intf.local_ip4) |
| 222 | |
| 223 | udp = pkt[UDP] |
| 224 | self.assertEqual(udp.dport, DHCP4_CLIENT_PORT) |
| 225 | self.assertEqual(udp.sport, DHCP4_SERVER_PORT) |
| 226 | |
Neale Ranns | a2fbf6b | 2017-07-18 08:23:32 -0700 | [diff] [blame] | 227 | self.verify_dhcp_msg_type(pkt, "offer") |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 228 | data = self.validate_relay_options( |
| 229 | pkt, intf, intf.local_ip4, vpn_id, fib_id, oui |
| 230 | ) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 231 | |
Neale Ranns | 038e1df | 2019-07-19 14:01:02 +0000 | [diff] [blame] | 232 | def verify_orig_dhcp_pkt(self, pkt, intf, dscp, l2_bc=True): |
Neale Ranns | a2fbf6b | 2017-07-18 08:23:32 -0700 | [diff] [blame] | 233 | ether = pkt[Ether] |
Neale Ranns | 99536f4 | 2019-07-25 06:11:58 -0700 | [diff] [blame] | 234 | if l2_bc: |
| 235 | self.assertEqual(ether.dst, "ff:ff:ff:ff:ff:ff") |
| 236 | else: |
| 237 | self.assertEqual(ether.dst, intf.remote_mac) |
Neale Ranns | a2fbf6b | 2017-07-18 08:23:32 -0700 | [diff] [blame] | 238 | self.assertEqual(ether.src, intf.local_mac) |
| 239 | |
| 240 | ip = pkt[IP] |
Neale Ranns | 99536f4 | 2019-07-25 06:11:58 -0700 | [diff] [blame] | 241 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 242 | if l2_bc: |
Neale Ranns | 99536f4 | 2019-07-25 06:11:58 -0700 | [diff] [blame] | 243 | self.assertEqual(ip.dst, "255.255.255.255") |
| 244 | self.assertEqual(ip.src, "0.0.0.0") |
| 245 | else: |
| 246 | self.assertEqual(ip.dst, intf.remote_ip4) |
| 247 | self.assertEqual(ip.src, intf.local_ip4) |
Neale Ranns | 038e1df | 2019-07-19 14:01:02 +0000 | [diff] [blame] | 248 | self.assertEqual(ip.tos, dscp) |
Neale Ranns | a2fbf6b | 2017-07-18 08:23:32 -0700 | [diff] [blame] | 249 | |
| 250 | udp = pkt[UDP] |
| 251 | self.assertEqual(udp.dport, DHCP4_SERVER_PORT) |
| 252 | self.assertEqual(udp.sport, DHCP4_CLIENT_PORT) |
| 253 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 254 | def verify_orig_dhcp_discover( |
| 255 | self, pkt, intf, hostname, client_id=None, broadcast=True, dscp=0 |
| 256 | ): |
Neale Ranns | 038e1df | 2019-07-19 14:01:02 +0000 | [diff] [blame] | 257 | self.verify_orig_dhcp_pkt(pkt, intf, dscp) |
Neale Ranns | a2fbf6b | 2017-07-18 08:23:32 -0700 | [diff] [blame] | 258 | |
| 259 | self.verify_dhcp_msg_type(pkt, "discover") |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 260 | self.verify_dhcp_has_option(pkt, "hostname", hostname.encode("ascii")) |
Neale Ranns | 51822bf | 2017-07-18 09:26:53 -0700 | [diff] [blame] | 261 | if client_id: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 262 | client_id = "\x00" + client_id |
| 263 | self.verify_dhcp_has_option(pkt, "client_id", client_id.encode("ascii")) |
Neale Ranns | 808c5b2 | 2017-08-02 05:15:07 -0700 | [diff] [blame] | 264 | bootp = pkt[BOOTP] |
| 265 | self.assertEqual(bootp.ciaddr, "0.0.0.0") |
| 266 | self.assertEqual(bootp.giaddr, "0.0.0.0") |
Neale Ranns | 54c6dc4 | 2018-01-17 10:29:10 -0800 | [diff] [blame] | 267 | if broadcast: |
| 268 | self.assertEqual(bootp.flags, 0x8000) |
| 269 | else: |
| 270 | self.assertEqual(bootp.flags, 0x0000) |
Neale Ranns | a2fbf6b | 2017-07-18 08:23:32 -0700 | [diff] [blame] | 271 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 272 | def verify_orig_dhcp_request( |
| 273 | self, pkt, intf, hostname, ip, broadcast=True, l2_bc=True, dscp=0 |
| 274 | ): |
Neale Ranns | 038e1df | 2019-07-19 14:01:02 +0000 | [diff] [blame] | 275 | self.verify_orig_dhcp_pkt(pkt, intf, dscp, l2_bc=l2_bc) |
Neale Ranns | a2fbf6b | 2017-07-18 08:23:32 -0700 | [diff] [blame] | 276 | |
| 277 | self.verify_dhcp_msg_type(pkt, "request") |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 278 | self.verify_dhcp_has_option(pkt, "hostname", hostname.encode("ascii")) |
Neale Ranns | a2fbf6b | 2017-07-18 08:23:32 -0700 | [diff] [blame] | 279 | self.verify_dhcp_has_option(pkt, "requested_addr", ip) |
Neale Ranns | 808c5b2 | 2017-08-02 05:15:07 -0700 | [diff] [blame] | 280 | bootp = pkt[BOOTP] |
Neale Ranns | 99536f4 | 2019-07-25 06:11:58 -0700 | [diff] [blame] | 281 | |
| 282 | if l2_bc: |
| 283 | self.assertEqual(bootp.ciaddr, "0.0.0.0") |
| 284 | else: |
| 285 | self.assertEqual(bootp.ciaddr, intf.local_ip4) |
Neale Ranns | 808c5b2 | 2017-08-02 05:15:07 -0700 | [diff] [blame] | 286 | self.assertEqual(bootp.giaddr, "0.0.0.0") |
Neale Ranns | 99536f4 | 2019-07-25 06:11:58 -0700 | [diff] [blame] | 287 | |
Neale Ranns | 54c6dc4 | 2018-01-17 10:29:10 -0800 | [diff] [blame] | 288 | if broadcast: |
| 289 | self.assertEqual(bootp.flags, 0x8000) |
| 290 | else: |
| 291 | self.assertEqual(bootp.flags, 0x0000) |
Neale Ranns | a2fbf6b | 2017-07-18 08:23:32 -0700 | [diff] [blame] | 292 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 293 | def verify_relayed_dhcp_discover( |
| 294 | self, |
| 295 | pkt, |
| 296 | intf, |
| 297 | src_intf=None, |
| 298 | fib_id=0, |
| 299 | oui=0, |
| 300 | vpn_id="", |
| 301 | dst_mac=None, |
| 302 | dst_ip=None, |
| 303 | ): |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 304 | if not dst_mac: |
| 305 | dst_mac = intf.remote_mac |
| 306 | if not dst_ip: |
| 307 | dst_ip = intf.remote_ip4 |
| 308 | |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 309 | ether = pkt[Ether] |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 310 | self.assertEqual(ether.dst, dst_mac) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 311 | self.assertEqual(ether.src, intf.local_mac) |
| 312 | |
| 313 | ip = pkt[IP] |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 314 | self.assertEqual(ip.dst, dst_ip) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 315 | self.assertEqual(ip.src, intf.local_ip4) |
| 316 | |
| 317 | udp = pkt[UDP] |
| 318 | self.assertEqual(udp.dport, DHCP4_SERVER_PORT) |
| 319 | self.assertEqual(udp.sport, DHCP4_CLIENT_PORT) |
| 320 | |
| 321 | dhcp = pkt[DHCP] |
| 322 | |
| 323 | is_discover = False |
| 324 | for o in dhcp.options: |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 325 | if isinstance(o, tuple): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 326 | if o[0] == "message-type" and DHCPTypes[o[1]] == "discover": |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 327 | is_discover = True |
| 328 | self.assertTrue(is_discover) |
| 329 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 330 | data = self.validate_relay_options( |
| 331 | pkt, src_intf, src_intf.local_ip4, vpn_id, fib_id, oui |
| 332 | ) |
Neale Ranns | 20a175a | 2017-02-14 07:28:41 -0800 | [diff] [blame] | 333 | return data |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 334 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 335 | def verify_dhcp6_solicit( |
| 336 | self, |
| 337 | pkt, |
| 338 | intf, |
| 339 | peer_ip, |
| 340 | peer_mac, |
| 341 | vpn_id="", |
| 342 | fib_id=0, |
| 343 | oui=0, |
| 344 | dst_mac=None, |
| 345 | dst_ip=None, |
| 346 | ): |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 347 | if not dst_mac: |
| 348 | dst_mac = intf.remote_mac |
| 349 | if not dst_ip: |
| 350 | dst_ip = in6_ptop(intf.remote_ip6) |
| 351 | |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 352 | ether = pkt[Ether] |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 353 | self.assertEqual(ether.dst, dst_mac) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 354 | self.assertEqual(ether.src, intf.local_mac) |
| 355 | |
| 356 | ip = pkt[IPv6] |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 357 | self.assertEqual(in6_ptop(ip.dst), dst_ip) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 358 | self.assertEqual(in6_ptop(ip.src), in6_ptop(intf.local_ip6)) |
| 359 | |
| 360 | udp = pkt[UDP] |
| 361 | self.assertEqual(udp.dport, DHCP6_CLIENT_PORT) |
| 362 | self.assertEqual(udp.sport, DHCP6_SERVER_PORT) |
| 363 | |
| 364 | relay = pkt[DHCP6_RelayForward] |
| 365 | self.assertEqual(in6_ptop(relay.peeraddr), in6_ptop(peer_ip)) |
| 366 | oid = pkt[DHCP6OptIfaceId] |
| 367 | cll = pkt[DHCP6OptClientLinkLayerAddr] |
| 368 | self.assertEqual(cll.optlen, 8) |
| 369 | self.assertEqual(cll.lltype, 1) |
| 370 | self.assertEqual(cll.clladdr, peer_mac) |
| 371 | |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 372 | id_len = len(vpn_id) |
| 373 | |
Neale Ranns | 20a175a | 2017-02-14 07:28:41 -0800 | [diff] [blame] | 374 | if fib_id != 0: |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 375 | self.assertEqual(id_len, 0) |
Neale Ranns | 20a175a | 2017-02-14 07:28:41 -0800 | [diff] [blame] | 376 | vss = pkt[DHCP6OptVSS] |
| 377 | self.assertEqual(vss.optlen, 8) |
| 378 | self.assertEqual(vss.type, 1) |
| 379 | # the OUI and FIB-id are really 3 and 4 bytes resp. |
| 380 | # but the tested range is small |
Ole Troan | 12966a7 | 2019-10-18 14:33:54 +0200 | [diff] [blame] | 381 | self.assertEqual(six.byte2int(vss.data[0:1]), 0) |
| 382 | self.assertEqual(six.byte2int(vss.data[1:2]), 0) |
| 383 | self.assertEqual(six.byte2int(vss.data[2:3]), oui) |
| 384 | self.assertEqual(six.byte2int(vss.data[3:4]), 0) |
| 385 | self.assertEqual(six.byte2int(vss.data[4:5]), 0) |
| 386 | self.assertEqual(six.byte2int(vss.data[5:6]), 0) |
| 387 | self.assertEqual(six.byte2int(vss.data[6:7]), fib_id) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 388 | |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 389 | if id_len > 0: |
| 390 | self.assertEqual(oui, 0) |
| 391 | vss = pkt[DHCP6OptVSS] |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 392 | self.assertEqual(vss.optlen, id_len + 1) |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 393 | self.assertEqual(vss.type, 0) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 394 | self.assertEqual(vss.data[0:id_len].decode("ascii"), vpn_id) |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 395 | |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 396 | # the relay message should be an encoded Solicit |
| 397 | msg = pkt[DHCP6OptRelayMsg] |
| 398 | sol = DHCP6_Solicit() |
Ole Troan | 12966a7 | 2019-10-18 14:33:54 +0200 | [diff] [blame] | 399 | self.assertEqual(msg.optlen, len(sol)) |
| 400 | self.assertEqual(sol, msg[1]) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 401 | |
| 402 | def verify_dhcp6_advert(self, pkt, intf, peer): |
| 403 | ether = pkt[Ether] |
| 404 | self.assertEqual(ether.dst, "ff:ff:ff:ff:ff:ff") |
| 405 | self.assertEqual(ether.src, intf.local_mac) |
| 406 | |
| 407 | ip = pkt[IPv6] |
| 408 | self.assertEqual(in6_ptop(ip.dst), in6_ptop(peer)) |
| 409 | self.assertEqual(in6_ptop(ip.src), in6_ptop(intf.local_ip6)) |
| 410 | |
| 411 | udp = pkt[UDP] |
| 412 | self.assertEqual(udp.dport, DHCP6_SERVER_PORT) |
| 413 | self.assertEqual(udp.sport, DHCP6_CLIENT_PORT) |
| 414 | |
| 415 | # not sure why this is not decoding |
| 416 | # adv = pkt[DHCP6_Advertise] |
| 417 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 418 | def wait_for_no_route(self, address, length, n_tries=50, s_time=1): |
| 419 | while n_tries: |
Neale Ranns | f6e9b01 | 2019-01-25 06:37:15 -0800 | [diff] [blame] | 420 | if not find_route(self, address, length): |
| 421 | return True |
| 422 | n_tries = n_tries - 1 |
| 423 | self.sleep(s_time) |
| 424 | |
| 425 | return False |
| 426 | |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 427 | def test_dhcp_proxy(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 428 | """DHCPv4 Proxy""" |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 429 | |
| 430 | # |
| 431 | # Verify no response to DHCP request without DHCP config |
| 432 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 433 | p_disc_vrf0 = ( |
| 434 | Ether(dst="ff:ff:ff:ff:ff:ff", src=self.pg3.remote_mac) |
| 435 | / IP(src="0.0.0.0", dst="255.255.255.255") |
| 436 | / UDP(sport=DHCP4_CLIENT_PORT, dport=DHCP4_SERVER_PORT) |
| 437 | / BOOTP(op=1) |
| 438 | / DHCP(options=[("message-type", "discover"), ("end")]) |
| 439 | ) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 440 | pkts_disc_vrf0 = [p_disc_vrf0] |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 441 | p_disc_vrf1 = ( |
| 442 | Ether(dst="ff:ff:ff:ff:ff:ff", src=self.pg4.remote_mac) |
| 443 | / IP(src="0.0.0.0", dst="255.255.255.255") |
| 444 | / UDP(sport=DHCP4_CLIENT_PORT, dport=DHCP4_SERVER_PORT) |
| 445 | / BOOTP(op=1) |
| 446 | / DHCP(options=[("message-type", "discover"), ("end")]) |
| 447 | ) |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 448 | pkts_disc_vrf1 = [p_disc_vrf1] |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 449 | p_disc_vrf2 = ( |
| 450 | Ether(dst="ff:ff:ff:ff:ff:ff", src=self.pg5.remote_mac) |
| 451 | / IP(src="0.0.0.0", dst="255.255.255.255") |
| 452 | / UDP(sport=DHCP4_CLIENT_PORT, dport=DHCP4_SERVER_PORT) |
| 453 | / BOOTP(op=1) |
| 454 | / DHCP(options=[("message-type", "discover"), ("end")]) |
| 455 | ) |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 456 | pkts_disc_vrf2 = [p_disc_vrf2] |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 457 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 458 | self.send_and_assert_no_replies( |
| 459 | self.pg3, pkts_disc_vrf0, "DHCP with no configuration" |
| 460 | ) |
| 461 | self.send_and_assert_no_replies( |
| 462 | self.pg4, pkts_disc_vrf1, "DHCP with no configuration" |
| 463 | ) |
| 464 | self.send_and_assert_no_replies( |
| 465 | self.pg5, pkts_disc_vrf2, "DHCP with no configuration" |
| 466 | ) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 467 | |
| 468 | # |
| 469 | # Enable DHCP proxy in VRF 0 |
| 470 | # |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 471 | server_addr = self.pg0.remote_ip4 |
| 472 | src_addr = self.pg0.local_ip4 |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 473 | |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 474 | Proxy = VppDHCPProxy(self, server_addr, src_addr, rx_vrf_id=0) |
| 475 | Proxy.add_vpp_config() |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 476 | |
| 477 | # |
Neale Ranns | 20a175a | 2017-02-14 07:28:41 -0800 | [diff] [blame] | 478 | # Discover packets from the client are dropped because there is no |
| 479 | # IP address configured on the client facing interface |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 480 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 481 | self.send_and_assert_no_replies( |
| 482 | self.pg3, pkts_disc_vrf0, "Discover DHCP no relay address" |
| 483 | ) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 484 | |
| 485 | # |
| 486 | # Inject a response from the server |
Neale Ranns | 20a175a | 2017-02-14 07:28:41 -0800 | [diff] [blame] | 487 | # dropped, because there is no IP addrees on the |
Neale Ranns | 2dd6852 | 2017-02-16 03:38:59 -0800 | [diff] [blame] | 488 | # client interfce to fill in the option. |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 489 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 490 | p = ( |
| 491 | Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) |
| 492 | / IP(src=self.pg0.remote_ip4, dst=self.pg0.local_ip4) |
| 493 | / UDP(sport=DHCP4_SERVER_PORT, dport=DHCP4_SERVER_PORT) |
| 494 | / BOOTP(op=1) |
| 495 | / DHCP(options=[("message-type", "offer"), ("end")]) |
| 496 | ) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 497 | pkts = [p] |
| 498 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 499 | self.send_and_assert_no_replies(self.pg3, pkts, "Offer DHCP no relay address") |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 500 | |
| 501 | # |
| 502 | # configure an IP address on the client facing interface |
| 503 | # |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 504 | self.pg3.config_ip4() |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 505 | |
| 506 | # |
| 507 | # Try again with a discover packet |
| 508 | # Rx'd packet should be to the server address and from the configured |
| 509 | # source address |
| 510 | # UDP source ports are unchanged |
| 511 | # we've no option 82 config so that should be absent |
| 512 | # |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 513 | self.pg3.add_stream(pkts_disc_vrf0) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 514 | self.pg_enable_capture(self.pg_interfaces) |
| 515 | self.pg_start() |
| 516 | |
| 517 | rx = self.pg0.get_capture(1) |
| 518 | rx = rx[0] |
| 519 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 520 | option_82 = self.verify_relayed_dhcp_discover(rx, self.pg0, src_intf=self.pg3) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 521 | |
| 522 | # |
| 523 | # Create an DHCP offer reply from the server with a correctly formatted |
| 524 | # option 82. i.e. send back what we just captured |
| 525 | # The offer, sent mcast to the client, still has option 82. |
| 526 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 527 | p = ( |
| 528 | Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) |
| 529 | / IP(src=self.pg0.remote_ip4, dst=self.pg0.local_ip4) |
| 530 | / UDP(sport=DHCP4_SERVER_PORT, dport=DHCP4_SERVER_PORT) |
| 531 | / BOOTP(op=1) |
| 532 | / DHCP( |
| 533 | options=[ |
| 534 | ("message-type", "offer"), |
Dave Wallace | cf9356d | 2024-07-23 01:28:19 -0400 | [diff] [blame^] | 535 | ("relay_agent_information", option_82), |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 536 | ("end"), |
| 537 | ] |
| 538 | ) |
| 539 | ) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 540 | pkts = [p] |
| 541 | |
| 542 | self.pg0.add_stream(pkts) |
| 543 | self.pg_enable_capture(self.pg_interfaces) |
| 544 | self.pg_start() |
| 545 | |
Dave Wallace | cf9356d | 2024-07-23 01:28:19 -0400 | [diff] [blame^] | 546 | rx = self.pg3.get_capture(1, timeout=5) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 547 | rx = rx[0] |
| 548 | |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 549 | self.verify_dhcp_offer(rx, self.pg3) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 550 | |
| 551 | # |
| 552 | # Bogus Option 82: |
| 553 | # |
| 554 | # 1. not our IP address = not checked by VPP? so offer is replayed |
| 555 | # to client |
Paul Vinciguerra | a7427ec | 2019-03-10 10:04:23 -0700 | [diff] [blame] | 556 | bad_ip = option_82[0:8] + scapy.compat.chb(33) + option_82[9:] |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 557 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 558 | p = ( |
| 559 | Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) |
| 560 | / IP(src=self.pg0.remote_ip4, dst=self.pg0.local_ip4) |
| 561 | / UDP(sport=DHCP4_SERVER_PORT, dport=DHCP4_SERVER_PORT) |
| 562 | / BOOTP(op=1) |
| 563 | / DHCP( |
| 564 | options=[ |
| 565 | ("message-type", "offer"), |
Dave Wallace | cf9356d | 2024-07-23 01:28:19 -0400 | [diff] [blame^] | 566 | ("relay_agent_information", bad_ip), |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 567 | ("end"), |
| 568 | ] |
| 569 | ) |
| 570 | ) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 571 | pkts = [p] |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 572 | self.send_and_assert_no_replies( |
| 573 | self.pg0, pkts, "DHCP offer option 82 bad address" |
| 574 | ) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 575 | |
| 576 | # 2. Not a sw_if_index VPP knows |
Paul Vinciguerra | a7427ec | 2019-03-10 10:04:23 -0700 | [diff] [blame] | 577 | bad_if_index = option_82[0:2] + scapy.compat.chb(33) + option_82[3:] |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 578 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 579 | p = ( |
| 580 | Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) |
| 581 | / IP(src=self.pg0.remote_ip4, dst=self.pg0.local_ip4) |
| 582 | / UDP(sport=DHCP4_SERVER_PORT, dport=DHCP4_SERVER_PORT) |
| 583 | / BOOTP(op=1) |
| 584 | / DHCP( |
| 585 | options=[ |
| 586 | ("message-type", "offer"), |
Dave Wallace | cf9356d | 2024-07-23 01:28:19 -0400 | [diff] [blame^] | 587 | ("relay_agent_information", bad_if_index), |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 588 | ("end"), |
| 589 | ] |
| 590 | ) |
| 591 | ) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 592 | pkts = [p] |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 593 | self.send_and_assert_no_replies( |
| 594 | self.pg0, pkts, "DHCP offer option 82 bad if index" |
| 595 | ) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 596 | |
| 597 | # |
| 598 | # Send a DHCP request in VRF 1. should be dropped. |
| 599 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 600 | self.send_and_assert_no_replies( |
| 601 | self.pg4, pkts_disc_vrf1, "DHCP with no configuration VRF 1" |
| 602 | ) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 603 | |
| 604 | # |
| 605 | # Delete the DHCP config in VRF 0 |
| 606 | # Should now drop requests. |
| 607 | # |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 608 | Proxy.remove_vpp_config() |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 609 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 610 | self.send_and_assert_no_replies( |
| 611 | self.pg3, pkts_disc_vrf0, "DHCP config removed VRF 0" |
| 612 | ) |
| 613 | self.send_and_assert_no_replies( |
| 614 | self.pg4, pkts_disc_vrf1, "DHCP config removed VRF 1" |
| 615 | ) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 616 | |
| 617 | # |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 618 | # Add DHCP config for VRF 1 & 2 |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 619 | # |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 620 | server_addr1 = self.pg1.remote_ip4 |
| 621 | src_addr1 = self.pg1.local_ip4 |
| 622 | Proxy1 = VppDHCPProxy( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 623 | self, server_addr1, src_addr1, rx_vrf_id=1, server_vrf_id=1 |
| 624 | ) |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 625 | Proxy1.add_vpp_config() |
| 626 | |
| 627 | server_addr2 = self.pg2.remote_ip4 |
| 628 | src_addr2 = self.pg2.local_ip4 |
| 629 | Proxy2 = VppDHCPProxy( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 630 | self, server_addr2, src_addr2, rx_vrf_id=2, server_vrf_id=2 |
| 631 | ) |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 632 | Proxy2.add_vpp_config() |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 633 | |
| 634 | # |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 635 | # Confim DHCP requests ok in VRF 1 & 2. |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 636 | # - dropped on IP config on client interface |
| 637 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 638 | self.send_and_assert_no_replies( |
| 639 | self.pg4, pkts_disc_vrf1, "DHCP config removed VRF 1" |
| 640 | ) |
| 641 | self.send_and_assert_no_replies( |
| 642 | self.pg5, pkts_disc_vrf2, "DHCP config removed VRF 2" |
| 643 | ) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 644 | |
| 645 | # |
| 646 | # configure an IP address on the client facing interface |
| 647 | # |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 648 | self.pg4.config_ip4() |
| 649 | self.pg4.add_stream(pkts_disc_vrf1) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 650 | self.pg_enable_capture(self.pg_interfaces) |
| 651 | self.pg_start() |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 652 | rx = self.pg1.get_capture(1) |
| 653 | rx = rx[0] |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 654 | self.verify_relayed_dhcp_discover(rx, self.pg1, src_intf=self.pg4) |
| 655 | |
| 656 | self.pg5.config_ip4() |
| 657 | self.pg5.add_stream(pkts_disc_vrf2) |
| 658 | self.pg_enable_capture(self.pg_interfaces) |
| 659 | self.pg_start() |
| 660 | rx = self.pg2.get_capture(1) |
| 661 | rx = rx[0] |
| 662 | self.verify_relayed_dhcp_discover(rx, self.pg2, src_intf=self.pg5) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 663 | |
| 664 | # |
Neale Ranns | 20a175a | 2017-02-14 07:28:41 -0800 | [diff] [blame] | 665 | # Add VSS config |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 666 | # table=1, vss_type=1, vpn_index=1, oui=4 |
| 667 | # table=2, vss_type=0, vpn_id = "ip4-table-2" |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 668 | self.vapi.dhcp_proxy_set_vss(tbl_id=1, vss_type=1, vpn_index=1, oui=4, is_add=1) |
| 669 | self.vapi.dhcp_proxy_set_vss( |
| 670 | tbl_id=2, vss_type=0, vpn_ascii_id="ip4-table-2", is_add=1 |
| 671 | ) |
Neale Ranns | 20a175a | 2017-02-14 07:28:41 -0800 | [diff] [blame] | 672 | |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 673 | self.pg4.add_stream(pkts_disc_vrf1) |
Neale Ranns | 20a175a | 2017-02-14 07:28:41 -0800 | [diff] [blame] | 674 | self.pg_enable_capture(self.pg_interfaces) |
| 675 | self.pg_start() |
| 676 | |
| 677 | rx = self.pg1.get_capture(1) |
| 678 | rx = rx[0] |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 679 | self.verify_relayed_dhcp_discover( |
| 680 | rx, self.pg1, src_intf=self.pg4, fib_id=1, oui=4 |
| 681 | ) |
Neale Ranns | 20a175a | 2017-02-14 07:28:41 -0800 | [diff] [blame] | 682 | |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 683 | self.pg5.add_stream(pkts_disc_vrf2) |
| 684 | self.pg_enable_capture(self.pg_interfaces) |
| 685 | self.pg_start() |
| 686 | |
| 687 | rx = self.pg2.get_capture(1) |
| 688 | rx = rx[0] |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 689 | self.verify_relayed_dhcp_discover( |
| 690 | rx, self.pg2, src_intf=self.pg5, vpn_id="ip4-table-2" |
| 691 | ) |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 692 | |
Neale Ranns | 20a175a | 2017-02-14 07:28:41 -0800 | [diff] [blame] | 693 | # |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 694 | # Add a second DHCP server in VRF 1 |
| 695 | # expect clients messages to be relay to both configured servers |
| 696 | # |
| 697 | self.pg1.generate_remote_hosts(2) |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 698 | server_addr12 = self.pg1.remote_hosts[1].ip4 |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 699 | |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 700 | Proxy12 = VppDHCPProxy( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 701 | self, server_addr12, src_addr, rx_vrf_id=1, server_vrf_id=1 |
| 702 | ) |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 703 | Proxy12.add_vpp_config() |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 704 | |
| 705 | # |
| 706 | # We'll need an ARP entry for the server to send it packets |
| 707 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 708 | arp_entry = VppNeighbor( |
| 709 | self, |
| 710 | self.pg1.sw_if_index, |
| 711 | self.pg1.remote_hosts[1].mac, |
| 712 | self.pg1.remote_hosts[1].ip4, |
| 713 | ) |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 714 | arp_entry.add_vpp_config() |
| 715 | |
| 716 | # |
| 717 | # Send a discover from the client. expect two relayed messages |
| 718 | # The frist packet is sent to the second server |
| 719 | # We're not enforcing that here, it's just the way it is. |
| 720 | # |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 721 | self.pg4.add_stream(pkts_disc_vrf1) |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 722 | self.pg_enable_capture(self.pg_interfaces) |
| 723 | self.pg_start() |
| 724 | |
| 725 | rx = self.pg1.get_capture(2) |
| 726 | |
Neale Ranns | a2fbf6b | 2017-07-18 08:23:32 -0700 | [diff] [blame] | 727 | option_82 = self.verify_relayed_dhcp_discover( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 728 | rx[0], |
| 729 | self.pg1, |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 730 | src_intf=self.pg4, |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 731 | dst_mac=self.pg1.remote_hosts[1].mac, |
| 732 | dst_ip=self.pg1.remote_hosts[1].ip4, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 733 | fib_id=1, |
| 734 | oui=4, |
| 735 | ) |
| 736 | self.verify_relayed_dhcp_discover( |
| 737 | rx[1], self.pg1, src_intf=self.pg4, fib_id=1, oui=4 |
| 738 | ) |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 739 | |
| 740 | # |
| 741 | # Send both packets back. Client gets both. |
| 742 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 743 | p1 = ( |
| 744 | Ether(dst=self.pg1.local_mac, src=self.pg1.remote_mac) |
| 745 | / IP(src=self.pg1.remote_ip4, dst=self.pg1.local_ip4) |
| 746 | / UDP(sport=DHCP4_SERVER_PORT, dport=DHCP4_SERVER_PORT) |
| 747 | / BOOTP(op=1) |
| 748 | / DHCP( |
| 749 | options=[ |
| 750 | ("message-type", "offer"), |
Dave Wallace | cf9356d | 2024-07-23 01:28:19 -0400 | [diff] [blame^] | 751 | ("relay_agent_information", option_82), |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 752 | ("end"), |
| 753 | ] |
| 754 | ) |
| 755 | ) |
| 756 | p2 = ( |
| 757 | Ether(dst=self.pg1.local_mac, src=self.pg1.remote_mac) |
| 758 | / IP(src=self.pg1.remote_hosts[1].ip4, dst=self.pg1.local_ip4) |
| 759 | / UDP(sport=DHCP4_SERVER_PORT, dport=DHCP4_SERVER_PORT) |
| 760 | / BOOTP(op=1) |
| 761 | / DHCP( |
| 762 | options=[ |
| 763 | ("message-type", "offer"), |
Dave Wallace | cf9356d | 2024-07-23 01:28:19 -0400 | [diff] [blame^] | 764 | ("relay_agent_information", option_82), |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 765 | ("end"), |
| 766 | ] |
| 767 | ) |
| 768 | ) |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 769 | pkts = [p1, p2] |
| 770 | |
| 771 | self.pg1.add_stream(pkts) |
| 772 | self.pg_enable_capture(self.pg_interfaces) |
| 773 | self.pg_start() |
| 774 | |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 775 | rx = self.pg4.get_capture(2) |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 776 | |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 777 | self.verify_dhcp_offer(rx[0], self.pg4, fib_id=1, oui=4) |
| 778 | self.verify_dhcp_offer(rx[1], self.pg4, fib_id=1, oui=4) |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 779 | |
| 780 | # |
| 781 | # Ensure offers from non-servers are dropeed |
| 782 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 783 | p2 = ( |
| 784 | Ether(dst=self.pg1.local_mac, src=self.pg1.remote_mac) |
| 785 | / IP(src="8.8.8.8", dst=self.pg1.local_ip4) |
| 786 | / UDP(sport=DHCP4_SERVER_PORT, dport=DHCP4_SERVER_PORT) |
| 787 | / BOOTP(op=1) |
| 788 | / DHCP( |
| 789 | options=[ |
| 790 | ("message-type", "offer"), |
Dave Wallace | cf9356d | 2024-07-23 01:28:19 -0400 | [diff] [blame^] | 791 | ("relay_agent_information", option_82), |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 792 | ("end"), |
| 793 | ] |
| 794 | ) |
| 795 | ) |
| 796 | self.send_and_assert_no_replies(self.pg1, p2, "DHCP offer from non-server") |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 797 | |
| 798 | # |
| 799 | # Ensure only the discover is sent to multiple servers |
| 800 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 801 | p_req_vrf1 = ( |
| 802 | Ether(dst="ff:ff:ff:ff:ff:ff", src=self.pg4.remote_mac) |
| 803 | / IP(src="0.0.0.0", dst="255.255.255.255") |
| 804 | / UDP(sport=DHCP4_CLIENT_PORT, dport=DHCP4_SERVER_PORT) |
| 805 | / BOOTP(op=1) |
| 806 | / DHCP(options=[("message-type", "request"), ("end")]) |
| 807 | ) |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 808 | |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 809 | self.pg4.add_stream(p_req_vrf1) |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 810 | self.pg_enable_capture(self.pg_interfaces) |
| 811 | self.pg_start() |
| 812 | |
| 813 | rx = self.pg1.get_capture(1) |
| 814 | |
| 815 | # |
| 816 | # Remove the second DHCP server |
| 817 | # |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 818 | Proxy12.remove_vpp_config() |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 819 | |
| 820 | # |
| 821 | # Test we can still relay with the first |
| 822 | # |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 823 | self.pg4.add_stream(pkts_disc_vrf1) |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 824 | self.pg_enable_capture(self.pg_interfaces) |
| 825 | self.pg_start() |
| 826 | |
| 827 | rx = self.pg1.get_capture(1) |
| 828 | rx = rx[0] |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 829 | self.verify_relayed_dhcp_discover( |
| 830 | rx, self.pg1, src_intf=self.pg4, fib_id=1, oui=4 |
| 831 | ) |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 832 | |
| 833 | # |
Neale Ranns | 20a175a | 2017-02-14 07:28:41 -0800 | [diff] [blame] | 834 | # Remove the VSS config |
| 835 | # relayed DHCP has default vlaues in the option. |
| 836 | # |
Neale Ranns | 02bfd64 | 2019-10-07 00:39:28 -0700 | [diff] [blame] | 837 | self.vapi.dhcp_proxy_set_vss(tbl_id=1, is_add=0) |
| 838 | self.vapi.dhcp_proxy_set_vss(tbl_id=2, is_add=0) |
Neale Ranns | 20a175a | 2017-02-14 07:28:41 -0800 | [diff] [blame] | 839 | |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 840 | self.pg4.add_stream(pkts_disc_vrf1) |
Neale Ranns | 20a175a | 2017-02-14 07:28:41 -0800 | [diff] [blame] | 841 | self.pg_enable_capture(self.pg_interfaces) |
| 842 | self.pg_start() |
| 843 | |
| 844 | rx = self.pg1.get_capture(1) |
| 845 | rx = rx[0] |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 846 | self.verify_relayed_dhcp_discover(rx, self.pg1, src_intf=self.pg4) |
Neale Ranns | 20a175a | 2017-02-14 07:28:41 -0800 | [diff] [blame] | 847 | |
| 848 | # |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 849 | # remove DHCP config to cleanup |
| 850 | # |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 851 | Proxy1.remove_vpp_config() |
| 852 | Proxy2.remove_vpp_config() |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 853 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 854 | self.send_and_assert_no_replies(self.pg3, pkts_disc_vrf0, "DHCP cleanup VRF 0") |
| 855 | self.send_and_assert_no_replies(self.pg4, pkts_disc_vrf1, "DHCP cleanup VRF 1") |
| 856 | self.send_and_assert_no_replies(self.pg5, pkts_disc_vrf2, "DHCP cleanup VRF 2") |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 857 | |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 858 | self.pg3.unconfig_ip4() |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 859 | self.pg4.unconfig_ip4() |
| 860 | self.pg5.unconfig_ip4() |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 861 | |
| 862 | def test_dhcp6_proxy(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 863 | """DHCPv6 Proxy""" |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 864 | # |
| 865 | # Verify no response to DHCP request without DHCP config |
| 866 | # |
| 867 | dhcp_solicit_dst = "ff02::1:2" |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 868 | dhcp_solicit_src_vrf0 = mk_ll_addr(self.pg3.remote_mac) |
| 869 | dhcp_solicit_src_vrf1 = mk_ll_addr(self.pg4.remote_mac) |
| 870 | dhcp_solicit_src_vrf2 = mk_ll_addr(self.pg5.remote_mac) |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 871 | server_addr_vrf0 = self.pg0.remote_ip6 |
| 872 | src_addr_vrf0 = self.pg0.local_ip6 |
| 873 | server_addr_vrf1 = self.pg1.remote_ip6 |
| 874 | src_addr_vrf1 = self.pg1.local_ip6 |
| 875 | server_addr_vrf2 = self.pg2.remote_ip6 |
| 876 | src_addr_vrf2 = self.pg2.local_ip6 |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 877 | |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 878 | dmac = in6_getnsmac(inet_pton(socket.AF_INET6, dhcp_solicit_dst)) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 879 | p_solicit_vrf0 = ( |
| 880 | Ether(dst=dmac, src=self.pg3.remote_mac) |
| 881 | / IPv6(src=dhcp_solicit_src_vrf0, dst=dhcp_solicit_dst) |
| 882 | / UDP(sport=DHCP6_SERVER_PORT, dport=DHCP6_CLIENT_PORT) |
| 883 | / DHCP6_Solicit() |
| 884 | ) |
| 885 | p_solicit_vrf1 = ( |
| 886 | Ether(dst=dmac, src=self.pg4.remote_mac) |
| 887 | / IPv6(src=dhcp_solicit_src_vrf1, dst=dhcp_solicit_dst) |
| 888 | / UDP(sport=DHCP6_SERVER_PORT, dport=DHCP6_CLIENT_PORT) |
| 889 | / DHCP6_Solicit() |
| 890 | ) |
| 891 | p_solicit_vrf2 = ( |
| 892 | Ether(dst=dmac, src=self.pg5.remote_mac) |
| 893 | / IPv6(src=dhcp_solicit_src_vrf2, dst=dhcp_solicit_dst) |
| 894 | / UDP(sport=DHCP6_SERVER_PORT, dport=DHCP6_CLIENT_PORT) |
| 895 | / DHCP6_Solicit() |
| 896 | ) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 897 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 898 | self.send_and_assert_no_replies( |
| 899 | self.pg3, p_solicit_vrf0, "DHCP with no configuration" |
| 900 | ) |
| 901 | self.send_and_assert_no_replies( |
| 902 | self.pg4, p_solicit_vrf1, "DHCP with no configuration" |
| 903 | ) |
| 904 | self.send_and_assert_no_replies( |
| 905 | self.pg5, p_solicit_vrf2, "DHCP with no configuration" |
| 906 | ) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 907 | |
| 908 | # |
| 909 | # DHCPv6 config in VRF 0. |
| 910 | # Packets still dropped because the client facing interface has no |
| 911 | # IPv6 config |
| 912 | # |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 913 | Proxy = VppDHCPProxy( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 914 | self, server_addr_vrf0, src_addr_vrf0, rx_vrf_id=0, server_vrf_id=0 |
| 915 | ) |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 916 | Proxy.add_vpp_config() |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 917 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 918 | self.send_and_assert_no_replies( |
| 919 | self.pg3, p_solicit_vrf0, "DHCP with no configuration" |
| 920 | ) |
| 921 | self.send_and_assert_no_replies( |
| 922 | self.pg4, p_solicit_vrf1, "DHCP with no configuration" |
| 923 | ) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 924 | |
| 925 | # |
| 926 | # configure an IP address on the client facing interface |
| 927 | # |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 928 | self.pg3.config_ip6() |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 929 | |
| 930 | # |
| 931 | # Now the DHCP requests are relayed to the server |
| 932 | # |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 933 | self.pg3.add_stream(p_solicit_vrf0) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 934 | self.pg_enable_capture(self.pg_interfaces) |
| 935 | self.pg_start() |
| 936 | |
| 937 | rx = self.pg0.get_capture(1) |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 938 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 939 | self.verify_dhcp6_solicit( |
| 940 | rx[0], self.pg0, dhcp_solicit_src_vrf0, self.pg3.remote_mac |
| 941 | ) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 942 | |
| 943 | # |
| 944 | # Exception cases for rejected relay responses |
| 945 | # |
| 946 | |
| 947 | # 1 - not a relay reply |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 948 | p_adv_vrf0 = ( |
| 949 | Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) |
| 950 | / IPv6(dst=self.pg0.local_ip6, src=self.pg0.remote_ip6) |
| 951 | / UDP(sport=DHCP6_SERVER_PORT, dport=DHCP6_SERVER_PORT) |
| 952 | / DHCP6_Advertise() |
| 953 | ) |
| 954 | self.send_and_assert_no_replies(self.pg3, p_adv_vrf0, "DHCP6 not a relay reply") |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 955 | |
| 956 | # 2 - no relay message option |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 957 | p_adv_vrf0 = ( |
| 958 | Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) |
| 959 | / IPv6(dst=self.pg0.local_ip6, src=self.pg0.remote_ip6) |
| 960 | / UDP(sport=DHCP6_SERVER_PORT, dport=DHCP6_SERVER_PORT) |
| 961 | / DHCP6_RelayReply() |
| 962 | / DHCP6_Advertise() |
| 963 | ) |
| 964 | self.send_and_assert_no_replies( |
| 965 | self.pg3, p_adv_vrf0, "DHCP not a relay message" |
| 966 | ) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 967 | |
| 968 | # 3 - no circuit ID |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 969 | p_adv_vrf0 = ( |
| 970 | Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) |
| 971 | / IPv6(dst=self.pg0.local_ip6, src=self.pg0.remote_ip6) |
| 972 | / UDP(sport=DHCP6_SERVER_PORT, dport=DHCP6_SERVER_PORT) |
| 973 | / DHCP6_RelayReply() |
| 974 | / DHCP6OptRelayMsg(optlen=0) |
| 975 | / DHCP6_Advertise() |
| 976 | ) |
| 977 | self.send_and_assert_no_replies(self.pg3, p_adv_vrf0, "DHCP6 no circuit ID") |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 978 | # 4 - wrong circuit ID |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 979 | p_adv_vrf0 = ( |
| 980 | Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) |
| 981 | / IPv6(dst=self.pg0.local_ip6, src=self.pg0.remote_ip6) |
| 982 | / UDP(sport=DHCP6_SERVER_PORT, dport=DHCP6_SERVER_PORT) |
| 983 | / DHCP6_RelayReply() |
| 984 | / DHCP6OptIfaceId(optlen=4, ifaceid="\x00\x00\x00\x05") |
| 985 | / DHCP6OptRelayMsg(optlen=0) |
| 986 | / DHCP6_Advertise() |
| 987 | ) |
| 988 | self.send_and_assert_no_replies(self.pg3, p_adv_vrf0, "DHCP6 wrong circuit ID") |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 989 | |
| 990 | # |
| 991 | # Send the relay response (the advertisement) |
| 992 | # - no peer address |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 993 | p_adv_vrf0 = ( |
| 994 | Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) |
| 995 | / IPv6(dst=self.pg0.local_ip6, src=self.pg0.remote_ip6) |
| 996 | / UDP(sport=DHCP6_SERVER_PORT, dport=DHCP6_SERVER_PORT) |
| 997 | / DHCP6_RelayReply() |
| 998 | / DHCP6OptIfaceId(optlen=4, ifaceid="\x00\x00\x00\x04") |
| 999 | / DHCP6OptRelayMsg(optlen=0) |
| 1000 | / DHCP6_Advertise(trid=1) |
| 1001 | / DHCP6OptStatusCode(statuscode=0) |
| 1002 | ) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 1003 | pkts_adv_vrf0 = [p_adv_vrf0] |
| 1004 | |
| 1005 | self.pg0.add_stream(pkts_adv_vrf0) |
| 1006 | self.pg_enable_capture(self.pg_interfaces) |
| 1007 | self.pg_start() |
| 1008 | |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1009 | rx = self.pg3.get_capture(1) |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 1010 | |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1011 | self.verify_dhcp6_advert(rx[0], self.pg3, "::") |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 1012 | |
| 1013 | # |
| 1014 | # Send the relay response (the advertisement) |
| 1015 | # - with peer address |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1016 | p_adv_vrf0 = ( |
| 1017 | Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) |
| 1018 | / IPv6(dst=self.pg0.local_ip6, src=self.pg0.remote_ip6) |
| 1019 | / UDP(sport=DHCP6_SERVER_PORT, dport=DHCP6_SERVER_PORT) |
| 1020 | / DHCP6_RelayReply(peeraddr=dhcp_solicit_src_vrf0) |
| 1021 | / DHCP6OptIfaceId(optlen=4, ifaceid="\x00\x00\x00\x04") |
| 1022 | / DHCP6OptRelayMsg(optlen=0) |
| 1023 | / DHCP6_Advertise(trid=1) |
| 1024 | / DHCP6OptStatusCode(statuscode=0) |
| 1025 | ) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 1026 | pkts_adv_vrf0 = [p_adv_vrf0] |
| 1027 | |
| 1028 | self.pg0.add_stream(pkts_adv_vrf0) |
| 1029 | self.pg_enable_capture(self.pg_interfaces) |
| 1030 | self.pg_start() |
| 1031 | |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1032 | rx = self.pg3.get_capture(1) |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 1033 | |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1034 | self.verify_dhcp6_advert(rx[0], self.pg3, dhcp_solicit_src_vrf0) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 1035 | |
| 1036 | # |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1037 | # Add all the config for VRF 1 & 2 |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 1038 | # |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 1039 | Proxy1 = VppDHCPProxy( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1040 | self, server_addr_vrf1, src_addr_vrf1, rx_vrf_id=1, server_vrf_id=1 |
| 1041 | ) |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 1042 | Proxy1.add_vpp_config() |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1043 | self.pg4.config_ip6() |
| 1044 | |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 1045 | Proxy2 = VppDHCPProxy( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1046 | self, server_addr_vrf2, src_addr_vrf2, rx_vrf_id=2, server_vrf_id=2 |
| 1047 | ) |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 1048 | Proxy2.add_vpp_config() |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1049 | self.pg5.config_ip6() |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 1050 | |
| 1051 | # |
| 1052 | # VRF 1 solicit |
| 1053 | # |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1054 | self.pg4.add_stream(p_solicit_vrf1) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 1055 | self.pg_enable_capture(self.pg_interfaces) |
| 1056 | self.pg_start() |
| 1057 | |
| 1058 | rx = self.pg1.get_capture(1) |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 1059 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1060 | self.verify_dhcp6_solicit( |
| 1061 | rx[0], self.pg1, dhcp_solicit_src_vrf1, self.pg4.remote_mac |
| 1062 | ) |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1063 | |
| 1064 | # |
| 1065 | # VRF 2 solicit |
| 1066 | # |
| 1067 | self.pg5.add_stream(p_solicit_vrf2) |
| 1068 | self.pg_enable_capture(self.pg_interfaces) |
| 1069 | self.pg_start() |
| 1070 | |
| 1071 | rx = self.pg2.get_capture(1) |
| 1072 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1073 | self.verify_dhcp6_solicit( |
| 1074 | rx[0], self.pg2, dhcp_solicit_src_vrf2, self.pg5.remote_mac |
| 1075 | ) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 1076 | |
| 1077 | # |
| 1078 | # VRF 1 Advert |
| 1079 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1080 | p_adv_vrf1 = ( |
| 1081 | Ether(dst=self.pg1.local_mac, src=self.pg1.remote_mac) |
| 1082 | / IPv6(dst=self.pg1.local_ip6, src=self.pg1.remote_ip6) |
| 1083 | / UDP(sport=DHCP6_SERVER_PORT, dport=DHCP6_SERVER_PORT) |
| 1084 | / DHCP6_RelayReply(peeraddr=dhcp_solicit_src_vrf1) |
| 1085 | / DHCP6OptIfaceId(optlen=4, ifaceid="\x00\x00\x00\x05") |
| 1086 | / DHCP6OptRelayMsg(optlen=0) |
| 1087 | / DHCP6_Advertise(trid=1) |
| 1088 | / DHCP6OptStatusCode(statuscode=0) |
| 1089 | ) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 1090 | pkts_adv_vrf1 = [p_adv_vrf1] |
| 1091 | |
| 1092 | self.pg1.add_stream(pkts_adv_vrf1) |
| 1093 | self.pg_enable_capture(self.pg_interfaces) |
| 1094 | self.pg_start() |
| 1095 | |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1096 | rx = self.pg4.get_capture(1) |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 1097 | |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1098 | self.verify_dhcp6_advert(rx[0], self.pg4, dhcp_solicit_src_vrf1) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 1099 | |
| 1100 | # |
| 1101 | # Add VSS config |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 1102 | # |
| 1103 | self.vapi.dhcp_proxy_set_vss( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1104 | tbl_id=1, vss_type=1, oui=4, vpn_index=1, is_ipv6=1, is_add=1 |
| 1105 | ) |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 1106 | self.vapi.dhcp_proxy_set_vss( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1107 | tbl_id=2, vss_type=0, vpn_ascii_id="IPv6-table-2", is_ipv6=1, is_add=1 |
| 1108 | ) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 1109 | |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1110 | self.pg4.add_stream(p_solicit_vrf1) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 1111 | self.pg_enable_capture(self.pg_interfaces) |
| 1112 | self.pg_start() |
| 1113 | |
| 1114 | rx = self.pg1.get_capture(1) |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 1115 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1116 | self.verify_dhcp6_solicit( |
| 1117 | rx[0], self.pg1, dhcp_solicit_src_vrf1, self.pg4.remote_mac, fib_id=1, oui=4 |
| 1118 | ) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 1119 | |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1120 | self.pg5.add_stream(p_solicit_vrf2) |
| 1121 | self.pg_enable_capture(self.pg_interfaces) |
| 1122 | self.pg_start() |
| 1123 | |
| 1124 | rx = self.pg2.get_capture(1) |
| 1125 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1126 | self.verify_dhcp6_solicit( |
| 1127 | rx[0], |
| 1128 | self.pg2, |
| 1129 | dhcp_solicit_src_vrf2, |
| 1130 | self.pg5.remote_mac, |
| 1131 | vpn_id="IPv6-table-2", |
| 1132 | ) |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1133 | |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 1134 | # |
| 1135 | # Remove the VSS config |
| 1136 | # relayed DHCP has default vlaues in the option. |
| 1137 | # |
Neale Ranns | 02bfd64 | 2019-10-07 00:39:28 -0700 | [diff] [blame] | 1138 | self.vapi.dhcp_proxy_set_vss(tbl_id=1, is_ipv6=1, is_add=0) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 1139 | |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1140 | self.pg4.add_stream(p_solicit_vrf1) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 1141 | self.pg_enable_capture(self.pg_interfaces) |
| 1142 | self.pg_start() |
| 1143 | |
| 1144 | rx = self.pg1.get_capture(1) |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 1145 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1146 | self.verify_dhcp6_solicit( |
| 1147 | rx[0], self.pg1, dhcp_solicit_src_vrf1, self.pg4.remote_mac |
| 1148 | ) |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 1149 | |
| 1150 | # |
| 1151 | # Add a second DHCP server in VRF 1 |
| 1152 | # expect clients messages to be relay to both configured servers |
| 1153 | # |
| 1154 | self.pg1.generate_remote_hosts(2) |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 1155 | server_addr12 = self.pg1.remote_hosts[1].ip6 |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 1156 | |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 1157 | Proxy12 = VppDHCPProxy( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1158 | self, server_addr12, src_addr_vrf1, rx_vrf_id=1, server_vrf_id=1 |
| 1159 | ) |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 1160 | Proxy12.add_vpp_config() |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 1161 | |
| 1162 | # |
| 1163 | # We'll need an ND entry for the server to send it packets |
| 1164 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1165 | nd_entry = VppNeighbor( |
| 1166 | self, |
| 1167 | self.pg1.sw_if_index, |
| 1168 | self.pg1.remote_hosts[1].mac, |
| 1169 | self.pg1.remote_hosts[1].ip6, |
| 1170 | ) |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 1171 | nd_entry.add_vpp_config() |
| 1172 | |
| 1173 | # |
| 1174 | # Send a discover from the client. expect two relayed messages |
| 1175 | # The frist packet is sent to the second server |
| 1176 | # We're not enforcing that here, it's just the way it is. |
| 1177 | # |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1178 | self.pg4.add_stream(p_solicit_vrf1) |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 1179 | self.pg_enable_capture(self.pg_interfaces) |
| 1180 | self.pg_start() |
| 1181 | |
| 1182 | rx = self.pg1.get_capture(2) |
| 1183 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1184 | self.verify_dhcp6_solicit( |
| 1185 | rx[0], self.pg1, dhcp_solicit_src_vrf1, self.pg4.remote_mac |
| 1186 | ) |
| 1187 | self.verify_dhcp6_solicit( |
| 1188 | rx[1], |
| 1189 | self.pg1, |
| 1190 | dhcp_solicit_src_vrf1, |
| 1191 | self.pg4.remote_mac, |
| 1192 | dst_mac=self.pg1.remote_hosts[1].mac, |
| 1193 | dst_ip=self.pg1.remote_hosts[1].ip6, |
| 1194 | ) |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 1195 | |
| 1196 | # |
| 1197 | # Send both packets back. Client gets both. |
| 1198 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1199 | p1 = ( |
| 1200 | Ether(dst=self.pg1.local_mac, src=self.pg1.remote_mac) |
| 1201 | / IPv6(dst=self.pg1.local_ip6, src=self.pg1.remote_ip6) |
| 1202 | / UDP(sport=DHCP6_SERVER_PORT, dport=DHCP6_SERVER_PORT) |
| 1203 | / DHCP6_RelayReply(peeraddr=dhcp_solicit_src_vrf1) |
| 1204 | / DHCP6OptIfaceId(optlen=4, ifaceid="\x00\x00\x00\x05") |
| 1205 | / DHCP6OptRelayMsg(optlen=0) |
| 1206 | / DHCP6_Advertise(trid=1) |
| 1207 | / DHCP6OptStatusCode(statuscode=0) |
| 1208 | ) |
| 1209 | p2 = ( |
| 1210 | Ether(dst=self.pg1.local_mac, src=self.pg1.remote_hosts[1].mac) |
| 1211 | / IPv6(dst=self.pg1.local_ip6, src=self.pg1._remote_hosts[1].ip6) |
| 1212 | / UDP(sport=DHCP6_SERVER_PORT, dport=DHCP6_SERVER_PORT) |
| 1213 | / DHCP6_RelayReply(peeraddr=dhcp_solicit_src_vrf1) |
| 1214 | / DHCP6OptIfaceId(optlen=4, ifaceid="\x00\x00\x00\x05") |
| 1215 | / DHCP6OptRelayMsg(optlen=0) |
| 1216 | / DHCP6_Advertise(trid=1) |
| 1217 | / DHCP6OptStatusCode(statuscode=0) |
| 1218 | ) |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 1219 | |
| 1220 | pkts = [p1, p2] |
| 1221 | |
| 1222 | self.pg1.add_stream(pkts) |
| 1223 | self.pg_enable_capture(self.pg_interfaces) |
| 1224 | self.pg_start() |
| 1225 | |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1226 | rx = self.pg4.get_capture(2) |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 1227 | |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1228 | self.verify_dhcp6_advert(rx[0], self.pg4, dhcp_solicit_src_vrf1) |
| 1229 | self.verify_dhcp6_advert(rx[1], self.pg4, dhcp_solicit_src_vrf1) |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 1230 | |
| 1231 | # |
| 1232 | # Ensure only solicit messages are duplicated |
| 1233 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1234 | p_request_vrf1 = ( |
| 1235 | Ether(dst=dmac, src=self.pg4.remote_mac) |
| 1236 | / IPv6(src=dhcp_solicit_src_vrf1, dst=dhcp_solicit_dst) |
| 1237 | / UDP(sport=DHCP6_SERVER_PORT, dport=DHCP6_CLIENT_PORT) |
| 1238 | / DHCP6_Request() |
| 1239 | ) |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 1240 | |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1241 | self.pg4.add_stream(p_request_vrf1) |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 1242 | self.pg_enable_capture(self.pg_interfaces) |
| 1243 | self.pg_start() |
| 1244 | |
| 1245 | rx = self.pg1.get_capture(1) |
| 1246 | |
| 1247 | # |
| 1248 | # Test we drop DHCP packets from addresses that are not configured as |
| 1249 | # DHCP servers |
| 1250 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1251 | p2 = ( |
| 1252 | Ether(dst=self.pg1.local_mac, src=self.pg1.remote_hosts[1].mac) |
| 1253 | / IPv6(dst=self.pg1.local_ip6, src="3001::1") |
| 1254 | / UDP(sport=DHCP6_SERVER_PORT, dport=DHCP6_SERVER_PORT) |
| 1255 | / DHCP6_RelayReply(peeraddr=dhcp_solicit_src_vrf1) |
| 1256 | / DHCP6OptIfaceId(optlen=4, ifaceid="\x00\x00\x00\x05") |
| 1257 | / DHCP6OptRelayMsg(optlen=0) |
| 1258 | / DHCP6_Advertise(trid=1) |
| 1259 | / DHCP6OptStatusCode(statuscode=0) |
| 1260 | ) |
| 1261 | self.send_and_assert_no_replies(self.pg1, p2, "DHCP6 not from server") |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 1262 | |
| 1263 | # |
| 1264 | # Remove the second DHCP server |
| 1265 | # |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 1266 | Proxy12.remove_vpp_config() |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 1267 | |
| 1268 | # |
| 1269 | # Test we can still relay with the first |
| 1270 | # |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1271 | self.pg4.add_stream(p_solicit_vrf1) |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 1272 | self.pg_enable_capture(self.pg_interfaces) |
| 1273 | self.pg_start() |
| 1274 | |
| 1275 | rx = self.pg1.get_capture(1) |
| 1276 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1277 | self.verify_dhcp6_solicit( |
| 1278 | rx[0], self.pg1, dhcp_solicit_src_vrf1, self.pg4.remote_mac |
| 1279 | ) |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 1280 | |
| 1281 | # |
| 1282 | # Cleanup |
| 1283 | # |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 1284 | Proxy.remove_vpp_config() |
| 1285 | Proxy1.remove_vpp_config() |
| 1286 | Proxy2.remove_vpp_config() |
Neale Ranns | 3466c30 | 2017-02-16 07:45:03 -0800 | [diff] [blame] | 1287 | |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 1288 | self.pg3.unconfig_ip6() |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1289 | self.pg4.unconfig_ip6() |
| 1290 | self.pg5.unconfig_ip6() |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 1291 | |
Neale Ranns | a2fbf6b | 2017-07-18 08:23:32 -0700 | [diff] [blame] | 1292 | def test_dhcp_client(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1293 | """DHCP Client""" |
Neale Ranns | a2fbf6b | 2017-07-18 08:23:32 -0700 | [diff] [blame] | 1294 | |
Neale Ranns | 038e1df | 2019-07-19 14:01:02 +0000 | [diff] [blame] | 1295 | vdscp = VppEnum.vl_api_ip_dscp_t |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1296 | hostname = "universal-dp" |
Neale Ranns | a2fbf6b | 2017-07-18 08:23:32 -0700 | [diff] [blame] | 1297 | |
| 1298 | self.pg_enable_capture(self.pg_interfaces) |
| 1299 | |
| 1300 | # |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1301 | # Configure DHCP client on PG3 and capture the discover sent |
Neale Ranns | a2fbf6b | 2017-07-18 08:23:32 -0700 | [diff] [blame] | 1302 | # |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 1303 | Client = VppDHCPClient(self, self.pg3.sw_if_index, hostname) |
| 1304 | Client.add_vpp_config() |
| 1305 | self.assertTrue(Client.query_vpp_config()) |
Neale Ranns | a2fbf6b | 2017-07-18 08:23:32 -0700 | [diff] [blame] | 1306 | |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1307 | rx = self.pg3.get_capture(1) |
Neale Ranns | a2fbf6b | 2017-07-18 08:23:32 -0700 | [diff] [blame] | 1308 | |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1309 | self.verify_orig_dhcp_discover(rx[0], self.pg3, hostname) |
Neale Ranns | a2fbf6b | 2017-07-18 08:23:32 -0700 | [diff] [blame] | 1310 | |
| 1311 | # |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1312 | # Send back on offer, expect the request |
Neale Ranns | a2fbf6b | 2017-07-18 08:23:32 -0700 | [diff] [blame] | 1313 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1314 | p_offer = ( |
| 1315 | Ether(dst=self.pg3.local_mac, src=self.pg3.remote_mac) |
| 1316 | / IP(src=self.pg3.remote_ip4, dst="255.255.255.255") |
| 1317 | / UDP(sport=DHCP4_SERVER_PORT, dport=DHCP4_CLIENT_PORT) |
| 1318 | / BOOTP( |
| 1319 | op=1, yiaddr=self.pg3.local_ip4, chaddr=mac_pton(self.pg3.local_mac) |
| 1320 | ) |
| 1321 | / DHCP( |
| 1322 | options=[ |
| 1323 | ("message-type", "offer"), |
| 1324 | ("server_id", self.pg3.remote_ip4), |
| 1325 | "end", |
| 1326 | ] |
| 1327 | ) |
| 1328 | ) |
Neale Ranns | a2fbf6b | 2017-07-18 08:23:32 -0700 | [diff] [blame] | 1329 | |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1330 | self.pg3.add_stream(p_offer) |
Neale Ranns | a2fbf6b | 2017-07-18 08:23:32 -0700 | [diff] [blame] | 1331 | self.pg_enable_capture(self.pg_interfaces) |
| 1332 | self.pg_start() |
| 1333 | |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1334 | rx = self.pg3.get_capture(1) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1335 | self.verify_orig_dhcp_request(rx[0], self.pg3, hostname, self.pg3.local_ip4) |
Neale Ranns | a2fbf6b | 2017-07-18 08:23:32 -0700 | [diff] [blame] | 1336 | |
| 1337 | # |
Jan Gelety | 2a3fb1a | 2018-06-27 10:56:17 +0200 | [diff] [blame] | 1338 | # Send an acknowledgment |
Neale Ranns | a2fbf6b | 2017-07-18 08:23:32 -0700 | [diff] [blame] | 1339 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1340 | p_ack = ( |
| 1341 | Ether(dst=self.pg3.local_mac, src=self.pg3.remote_mac) |
| 1342 | / IP(src=self.pg3.remote_ip4, dst="255.255.255.255") |
| 1343 | / UDP(sport=DHCP4_SERVER_PORT, dport=DHCP4_CLIENT_PORT) |
| 1344 | / BOOTP( |
| 1345 | op=1, yiaddr=self.pg3.local_ip4, chaddr=mac_pton(self.pg3.local_mac) |
| 1346 | ) |
| 1347 | / DHCP( |
| 1348 | options=[ |
| 1349 | ("message-type", "ack"), |
| 1350 | ("subnet_mask", "255.255.255.0"), |
| 1351 | ("router", self.pg3.remote_ip4), |
| 1352 | ("server_id", self.pg3.remote_ip4), |
| 1353 | ("lease_time", 43200), |
| 1354 | "end", |
| 1355 | ] |
| 1356 | ) |
| 1357 | ) |
Neale Ranns | a2fbf6b | 2017-07-18 08:23:32 -0700 | [diff] [blame] | 1358 | |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1359 | self.pg3.add_stream(p_ack) |
Neale Ranns | a2fbf6b | 2017-07-18 08:23:32 -0700 | [diff] [blame] | 1360 | self.pg_enable_capture(self.pg_interfaces) |
| 1361 | self.pg_start() |
| 1362 | |
| 1363 | # |
Neale Ranns | 51822bf | 2017-07-18 09:26:53 -0700 | [diff] [blame] | 1364 | # We'll get an ARP request for the router address |
| 1365 | # |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1366 | rx = self.pg3.get_capture(1) |
Neale Ranns | 51822bf | 2017-07-18 09:26:53 -0700 | [diff] [blame] | 1367 | |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1368 | self.assertEqual(rx[0][ARP].pdst, self.pg3.remote_ip4) |
Neale Ranns | 51822bf | 2017-07-18 09:26:53 -0700 | [diff] [blame] | 1369 | self.pg_enable_capture(self.pg_interfaces) |
| 1370 | |
| 1371 | # |
Neale Ranns | a2fbf6b | 2017-07-18 08:23:32 -0700 | [diff] [blame] | 1372 | # At the end of this procedure there should be a connected route |
| 1373 | # in the FIB |
| 1374 | # |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1375 | self.assertTrue(find_route(self, self.pg3.local_ip4, 24)) |
| 1376 | self.assertTrue(find_route(self, self.pg3.local_ip4, 32)) |
Neale Ranns | a2fbf6b | 2017-07-18 08:23:32 -0700 | [diff] [blame] | 1377 | |
| 1378 | # |
| 1379 | # remove the DHCP config |
| 1380 | # |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 1381 | Client.remove_vpp_config() |
Neale Ranns | a2fbf6b | 2017-07-18 08:23:32 -0700 | [diff] [blame] | 1382 | |
| 1383 | # |
| 1384 | # and now the route should be gone |
| 1385 | # |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1386 | self.assertFalse(find_route(self, self.pg3.local_ip4, 32)) |
| 1387 | self.assertFalse(find_route(self, self.pg3.local_ip4, 24)) |
Neale Ranns | a2fbf6b | 2017-07-18 08:23:32 -0700 | [diff] [blame] | 1388 | |
Neale Ranns | 51822bf | 2017-07-18 09:26:53 -0700 | [diff] [blame] | 1389 | # |
Neale Ranns | 808c5b2 | 2017-08-02 05:15:07 -0700 | [diff] [blame] | 1390 | # Start the procedure again. this time have VPP send the client-ID |
Neale Ranns | 038e1df | 2019-07-19 14:01:02 +0000 | [diff] [blame] | 1391 | # and set the DSCP value |
Neale Ranns | 51822bf | 2017-07-18 09:26:53 -0700 | [diff] [blame] | 1392 | # |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1393 | self.pg3.admin_down() |
Neale Ranns | 808c5b2 | 2017-08-02 05:15:07 -0700 | [diff] [blame] | 1394 | self.sleep(1) |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1395 | self.pg3.admin_up() |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1396 | Client.set_client( |
| 1397 | self.pg3.sw_if_index, |
| 1398 | hostname, |
| 1399 | id=self.pg3.local_mac, |
| 1400 | dscp=vdscp.IP_API_DSCP_EF, |
| 1401 | ) |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 1402 | Client.add_vpp_config() |
Neale Ranns | 51822bf | 2017-07-18 09:26:53 -0700 | [diff] [blame] | 1403 | |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1404 | rx = self.pg3.get_capture(1) |
Neale Ranns | 51822bf | 2017-07-18 09:26:53 -0700 | [diff] [blame] | 1405 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1406 | self.verify_orig_dhcp_discover( |
| 1407 | rx[0], self.pg3, hostname, self.pg3.local_mac, dscp=vdscp.IP_API_DSCP_EF |
| 1408 | ) |
Neale Ranns | 51822bf | 2017-07-18 09:26:53 -0700 | [diff] [blame] | 1409 | |
Jan Gelety | 2a3fb1a | 2018-06-27 10:56:17 +0200 | [diff] [blame] | 1410 | # TODO: VPP DHCP client should not accept DHCP OFFER message with |
| 1411 | # the XID (Transaction ID) not matching the XID of the most recent |
| 1412 | # DHCP DISCOVERY message. |
| 1413 | # Such DHCP OFFER message must be silently discarded - RFC2131. |
| 1414 | # Reported in Jira ticket: VPP-99 |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1415 | self.pg3.add_stream(p_offer) |
Neale Ranns | 808c5b2 | 2017-08-02 05:15:07 -0700 | [diff] [blame] | 1416 | self.pg_enable_capture(self.pg_interfaces) |
| 1417 | self.pg_start() |
| 1418 | |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1419 | rx = self.pg3.get_capture(1) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1420 | self.verify_orig_dhcp_request( |
| 1421 | rx[0], self.pg3, hostname, self.pg3.local_ip4, dscp=vdscp.IP_API_DSCP_EF |
| 1422 | ) |
Neale Ranns | 808c5b2 | 2017-08-02 05:15:07 -0700 | [diff] [blame] | 1423 | |
| 1424 | # |
| 1425 | # unicast the ack to the offered address |
| 1426 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1427 | p_ack = ( |
| 1428 | Ether(dst=self.pg3.local_mac, src=self.pg3.remote_mac) |
| 1429 | / IP(src=self.pg3.remote_ip4, dst=self.pg3.local_ip4) |
| 1430 | / UDP(sport=DHCP4_SERVER_PORT, dport=DHCP4_CLIENT_PORT) |
| 1431 | / BOOTP( |
| 1432 | op=1, yiaddr=self.pg3.local_ip4, chaddr=mac_pton(self.pg3.local_mac) |
| 1433 | ) |
| 1434 | / DHCP( |
| 1435 | options=[ |
| 1436 | ("message-type", "ack"), |
| 1437 | ("subnet_mask", "255.255.255.0"), |
| 1438 | ("router", self.pg3.remote_ip4), |
| 1439 | ("server_id", self.pg3.remote_ip4), |
| 1440 | ("lease_time", 43200), |
| 1441 | "end", |
| 1442 | ] |
| 1443 | ) |
| 1444 | ) |
Neale Ranns | 808c5b2 | 2017-08-02 05:15:07 -0700 | [diff] [blame] | 1445 | |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1446 | self.pg3.add_stream(p_ack) |
Neale Ranns | 808c5b2 | 2017-08-02 05:15:07 -0700 | [diff] [blame] | 1447 | self.pg_enable_capture(self.pg_interfaces) |
| 1448 | self.pg_start() |
| 1449 | |
| 1450 | # |
Neale Ranns | 54c6dc4 | 2018-01-17 10:29:10 -0800 | [diff] [blame] | 1451 | # We'll get an ARP request for the router address |
| 1452 | # |
| 1453 | rx = self.pg3.get_capture(1) |
| 1454 | |
| 1455 | self.assertEqual(rx[0][ARP].pdst, self.pg3.remote_ip4) |
| 1456 | self.pg_enable_capture(self.pg_interfaces) |
| 1457 | |
| 1458 | # |
Neale Ranns | 808c5b2 | 2017-08-02 05:15:07 -0700 | [diff] [blame] | 1459 | # At the end of this procedure there should be a connected route |
| 1460 | # in the FIB |
| 1461 | # |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1462 | self.assertTrue(find_route(self, self.pg3.local_ip4, 32)) |
| 1463 | self.assertTrue(find_route(self, self.pg3.local_ip4, 24)) |
Neale Ranns | 808c5b2 | 2017-08-02 05:15:07 -0700 | [diff] [blame] | 1464 | |
Neale Ranns | 51822bf | 2017-07-18 09:26:53 -0700 | [diff] [blame] | 1465 | # |
| 1466 | # remove the DHCP config |
| 1467 | # |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 1468 | Client.remove_vpp_config() |
Neale Ranns | a2fbf6b | 2017-07-18 08:23:32 -0700 | [diff] [blame] | 1469 | |
John Lo | 70bfcaf | 2017-11-14 13:19:26 -0500 | [diff] [blame] | 1470 | self.assertFalse(find_route(self, self.pg3.local_ip4, 32)) |
| 1471 | self.assertFalse(find_route(self, self.pg3.local_ip4, 24)) |
Neale Ranns | 808c5b2 | 2017-08-02 05:15:07 -0700 | [diff] [blame] | 1472 | |
Neale Ranns | 54c6dc4 | 2018-01-17 10:29:10 -0800 | [diff] [blame] | 1473 | # |
| 1474 | # Rince and repeat, this time with VPP configured not to set |
| 1475 | # the braodcast flag in the discover and request messages, |
| 1476 | # and for the server to unicast the responses. |
| 1477 | # |
| 1478 | # Configure DHCP client on PG3 and capture the discover sent |
| 1479 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1480 | Client.set_client(self.pg3.sw_if_index, hostname, set_broadcast_flag=False) |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 1481 | Client.add_vpp_config() |
Neale Ranns | 54c6dc4 | 2018-01-17 10:29:10 -0800 | [diff] [blame] | 1482 | |
| 1483 | rx = self.pg3.get_capture(1) |
| 1484 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1485 | self.verify_orig_dhcp_discover(rx[0], self.pg3, hostname, broadcast=False) |
Neale Ranns | 54c6dc4 | 2018-01-17 10:29:10 -0800 | [diff] [blame] | 1486 | |
| 1487 | # |
| 1488 | # Send back on offer, unicasted to the offered address. |
| 1489 | # Expect the request. |
| 1490 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1491 | p_offer = ( |
| 1492 | Ether(dst=self.pg3.local_mac, src=self.pg3.remote_mac) |
| 1493 | / IP(src=self.pg3.remote_ip4, dst=self.pg3.local_ip4) |
| 1494 | / UDP(sport=DHCP4_SERVER_PORT, dport=DHCP4_CLIENT_PORT) |
| 1495 | / BOOTP( |
| 1496 | op=1, yiaddr=self.pg3.local_ip4, chaddr=mac_pton(self.pg3.local_mac) |
| 1497 | ) |
| 1498 | / DHCP( |
| 1499 | options=[ |
| 1500 | ("message-type", "offer"), |
| 1501 | ("server_id", self.pg3.remote_ip4), |
| 1502 | "end", |
| 1503 | ] |
| 1504 | ) |
| 1505 | ) |
Neale Ranns | 54c6dc4 | 2018-01-17 10:29:10 -0800 | [diff] [blame] | 1506 | |
| 1507 | self.pg3.add_stream(p_offer) |
| 1508 | self.pg_enable_capture(self.pg_interfaces) |
| 1509 | self.pg_start() |
| 1510 | |
| 1511 | rx = self.pg3.get_capture(1) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1512 | self.verify_orig_dhcp_request( |
| 1513 | rx[0], self.pg3, hostname, self.pg3.local_ip4, broadcast=False |
| 1514 | ) |
Neale Ranns | 54c6dc4 | 2018-01-17 10:29:10 -0800 | [diff] [blame] | 1515 | |
| 1516 | # |
Neale Ranns | 99536f4 | 2019-07-25 06:11:58 -0700 | [diff] [blame] | 1517 | # Send an acknowledgment, the lease renewal time is 2 seconds |
| 1518 | # so we should expect the renew straight after |
Neale Ranns | 54c6dc4 | 2018-01-17 10:29:10 -0800 | [diff] [blame] | 1519 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1520 | p_ack = ( |
| 1521 | Ether(dst=self.pg3.local_mac, src=self.pg3.remote_mac) |
| 1522 | / IP(src=self.pg3.remote_ip4, dst=self.pg3.local_ip4) |
| 1523 | / UDP(sport=DHCP4_SERVER_PORT, dport=DHCP4_CLIENT_PORT) |
| 1524 | / BOOTP( |
| 1525 | op=1, yiaddr=self.pg3.local_ip4, chaddr=mac_pton(self.pg3.local_mac) |
| 1526 | ) |
| 1527 | / DHCP( |
| 1528 | options=[ |
| 1529 | ("message-type", "ack"), |
| 1530 | ("subnet_mask", "255.255.255.0"), |
| 1531 | ("router", self.pg3.remote_ip4), |
| 1532 | ("server_id", self.pg3.remote_ip4), |
| 1533 | ("lease_time", 43200), |
| 1534 | ("renewal_time", 2), |
| 1535 | "end", |
| 1536 | ] |
| 1537 | ) |
| 1538 | ) |
Neale Ranns | 54c6dc4 | 2018-01-17 10:29:10 -0800 | [diff] [blame] | 1539 | |
| 1540 | self.pg3.add_stream(p_ack) |
| 1541 | self.pg_enable_capture(self.pg_interfaces) |
| 1542 | self.pg_start() |
| 1543 | |
| 1544 | # |
| 1545 | # We'll get an ARP request for the router address |
| 1546 | # |
| 1547 | rx = self.pg3.get_capture(1) |
| 1548 | |
| 1549 | self.assertEqual(rx[0][ARP].pdst, self.pg3.remote_ip4) |
| 1550 | self.pg_enable_capture(self.pg_interfaces) |
| 1551 | |
| 1552 | # |
| 1553 | # At the end of this procedure there should be a connected route |
| 1554 | # in the FIB |
| 1555 | # |
| 1556 | self.assertTrue(find_route(self, self.pg3.local_ip4, 24)) |
| 1557 | self.assertTrue(find_route(self, self.pg3.local_ip4, 32)) |
| 1558 | |
Neale Ranns | 99536f4 | 2019-07-25 06:11:58 -0700 | [diff] [blame] | 1559 | # |
Neale Ranns | 6bcc6a4 | 2019-10-15 15:47:55 +0000 | [diff] [blame] | 1560 | # read the DHCP client details from a dump |
| 1561 | # |
| 1562 | clients = self.vapi.dhcp_client_dump() |
| 1563 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1564 | self.assertEqual(clients[0].client.sw_if_index, self.pg3.sw_if_index) |
| 1565 | self.assertEqual(clients[0].lease.sw_if_index, self.pg3.sw_if_index) |
Neale Ranns | 6bcc6a4 | 2019-10-15 15:47:55 +0000 | [diff] [blame] | 1566 | self.assertEqual(clients[0].client.hostname, hostname) |
| 1567 | self.assertEqual(clients[0].lease.hostname, hostname) |
| 1568 | # 0 = DISCOVER, 1 = REQUEST, 2 = BOUND |
| 1569 | self.assertEqual(clients[0].lease.state, 2) |
| 1570 | self.assertEqual(clients[0].lease.mask_width, 24) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1571 | self.assertEqual(str(clients[0].lease.router_address), self.pg3.remote_ip4) |
| 1572 | self.assertEqual(str(clients[0].lease.host_address), self.pg3.local_ip4) |
Neale Ranns | 6bcc6a4 | 2019-10-15 15:47:55 +0000 | [diff] [blame] | 1573 | |
| 1574 | # |
Neale Ranns | 99536f4 | 2019-07-25 06:11:58 -0700 | [diff] [blame] | 1575 | # wait for the unicasted renewal |
| 1576 | # the first attempt will be an ARP packet, since we have not yet |
| 1577 | # responded to VPP's request |
| 1578 | # |
| 1579 | self.logger.info(self.vapi.cli("sh dhcp client intfc pg3 verbose")) |
| 1580 | rx = self.pg3.get_capture(1, timeout=10) |
| 1581 | |
| 1582 | self.assertEqual(rx[0][ARP].pdst, self.pg3.remote_ip4) |
| 1583 | |
| 1584 | # respond to the arp |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1585 | p_arp = Ether(dst=self.pg3.local_mac, src=self.pg3.remote_mac) / ARP( |
| 1586 | op="is-at", |
| 1587 | hwdst=self.pg3.local_mac, |
| 1588 | hwsrc=self.pg3.remote_mac, |
| 1589 | pdst=self.pg3.local_ip4, |
| 1590 | psrc=self.pg3.remote_ip4, |
| 1591 | ) |
Neale Ranns | 99536f4 | 2019-07-25 06:11:58 -0700 | [diff] [blame] | 1592 | self.pg3.add_stream(p_arp) |
| 1593 | self.pg_enable_capture(self.pg_interfaces) |
| 1594 | self.pg_start() |
| 1595 | |
| 1596 | # the next packet is the unicasted renewal |
| 1597 | rx = self.pg3.get_capture(1, timeout=10) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1598 | self.verify_orig_dhcp_request( |
| 1599 | rx[0], self.pg3, hostname, self.pg3.local_ip4, l2_bc=False, broadcast=False |
| 1600 | ) |
Neale Ranns | daff178 | 2018-05-16 04:12:18 -0700 | [diff] [blame] | 1601 | |
Neale Ranns | 6bcc6a4 | 2019-10-15 15:47:55 +0000 | [diff] [blame] | 1602 | # send an ACK with different data from the original offer * |
| 1603 | self.pg3.generate_remote_hosts(4) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1604 | p_ack = ( |
| 1605 | Ether(dst=self.pg3.local_mac, src=self.pg3.remote_mac) |
| 1606 | / IP(src=self.pg3.remote_ip4, dst=self.pg3.local_ip4) |
| 1607 | / UDP(sport=DHCP4_SERVER_PORT, dport=DHCP4_CLIENT_PORT) |
| 1608 | / BOOTP( |
| 1609 | op=1, |
| 1610 | yiaddr=self.pg3.remote_hosts[3].ip4, |
| 1611 | chaddr=mac_pton(self.pg3.local_mac), |
| 1612 | ) |
| 1613 | / DHCP( |
| 1614 | options=[ |
| 1615 | ("message-type", "ack"), |
| 1616 | ("subnet_mask", "255.255.255.0"), |
| 1617 | ("router", self.pg3.remote_hosts[1].ip4), |
| 1618 | ("server_id", self.pg3.remote_hosts[2].ip4), |
| 1619 | ("lease_time", 43200), |
| 1620 | ("renewal_time", 2), |
| 1621 | "end", |
| 1622 | ] |
| 1623 | ) |
| 1624 | ) |
Neale Ranns | 6bcc6a4 | 2019-10-15 15:47:55 +0000 | [diff] [blame] | 1625 | |
| 1626 | self.pg3.add_stream(p_ack) |
| 1627 | self.pg_enable_capture(self.pg_interfaces) |
| 1628 | self.pg_start() |
| 1629 | |
Neale Ranns | daff178 | 2018-05-16 04:12:18 -0700 | [diff] [blame] | 1630 | # |
| 1631 | # read the DHCP client details from a dump |
| 1632 | # |
| 1633 | clients = self.vapi.dhcp_client_dump() |
| 1634 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1635 | self.assertEqual(clients[0].client.sw_if_index, self.pg3.sw_if_index) |
| 1636 | self.assertEqual(clients[0].lease.sw_if_index, self.pg3.sw_if_index) |
Neale Ranns | 6bcc6a4 | 2019-10-15 15:47:55 +0000 | [diff] [blame] | 1637 | self.assertEqual(clients[0].client.hostname, hostname) |
| 1638 | self.assertEqual(clients[0].lease.hostname, hostname) |
Neale Ranns | daff178 | 2018-05-16 04:12:18 -0700 | [diff] [blame] | 1639 | # 0 = DISCOVER, 1 = REQUEST, 2 = BOUND |
| 1640 | self.assertEqual(clients[0].lease.state, 2) |
| 1641 | self.assertEqual(clients[0].lease.mask_width, 24) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1642 | self.assertEqual( |
| 1643 | str(clients[0].lease.router_address), self.pg3.remote_hosts[1].ip4 |
| 1644 | ) |
| 1645 | self.assertEqual( |
| 1646 | str(clients[0].lease.host_address), self.pg3.remote_hosts[3].ip4 |
| 1647 | ) |
Neale Ranns | 99536f4 | 2019-07-25 06:11:58 -0700 | [diff] [blame] | 1648 | |
Neale Ranns | 54c6dc4 | 2018-01-17 10:29:10 -0800 | [diff] [blame] | 1649 | # |
| 1650 | # remove the DHCP config |
| 1651 | # |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 1652 | Client.remove_vpp_config() |
Neale Ranns | 54c6dc4 | 2018-01-17 10:29:10 -0800 | [diff] [blame] | 1653 | |
| 1654 | # |
| 1655 | # and now the route should be gone |
| 1656 | # |
| 1657 | self.assertFalse(find_route(self, self.pg3.local_ip4, 32)) |
| 1658 | self.assertFalse(find_route(self, self.pg3.local_ip4, 24)) |
| 1659 | |
Jan Gelety | 2a3fb1a | 2018-06-27 10:56:17 +0200 | [diff] [blame] | 1660 | # |
| 1661 | # Start the procedure again. Use requested lease time option. |
Neale Ranns | 6bcc6a4 | 2019-10-15 15:47:55 +0000 | [diff] [blame] | 1662 | # this time wait for the lease to expire and the client to |
| 1663 | # self-destruct |
Jan Gelety | 2a3fb1a | 2018-06-27 10:56:17 +0200 | [diff] [blame] | 1664 | # |
Neale Ranns | 99536f4 | 2019-07-25 06:11:58 -0700 | [diff] [blame] | 1665 | hostname += "-2" |
Jan Gelety | 2a3fb1a | 2018-06-27 10:56:17 +0200 | [diff] [blame] | 1666 | self.pg3.admin_down() |
| 1667 | self.sleep(1) |
| 1668 | self.pg3.admin_up() |
Neale Ranns | 99536f4 | 2019-07-25 06:11:58 -0700 | [diff] [blame] | 1669 | self.pg_enable_capture(self.pg_interfaces) |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 1670 | Client.set_client(self.pg3.sw_if_index, hostname) |
| 1671 | Client.add_vpp_config() |
Jan Gelety | 2a3fb1a | 2018-06-27 10:56:17 +0200 | [diff] [blame] | 1672 | |
| 1673 | rx = self.pg3.get_capture(1) |
| 1674 | |
| 1675 | self.verify_orig_dhcp_discover(rx[0], self.pg3, hostname) |
| 1676 | |
| 1677 | # |
| 1678 | # Send back on offer with requested lease time, expect the request |
| 1679 | # |
| 1680 | lease_time = 1 |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1681 | p_offer = ( |
| 1682 | Ether(dst=self.pg3.local_mac, src=self.pg3.remote_mac) |
| 1683 | / IP(src=self.pg3.remote_ip4, dst="255.255.255.255") |
| 1684 | / UDP(sport=DHCP4_SERVER_PORT, dport=DHCP4_CLIENT_PORT) |
| 1685 | / BOOTP( |
| 1686 | op=1, yiaddr=self.pg3.local_ip4, chaddr=mac_pton(self.pg3.local_mac) |
| 1687 | ) |
| 1688 | / DHCP( |
| 1689 | options=[ |
| 1690 | ("message-type", "offer"), |
| 1691 | ("server_id", self.pg3.remote_ip4), |
| 1692 | ("lease_time", lease_time), |
| 1693 | "end", |
| 1694 | ] |
| 1695 | ) |
| 1696 | ) |
Jan Gelety | 2a3fb1a | 2018-06-27 10:56:17 +0200 | [diff] [blame] | 1697 | |
| 1698 | self.pg3.add_stream(p_offer) |
| 1699 | self.pg_enable_capture(self.pg_interfaces) |
| 1700 | self.pg_start() |
| 1701 | |
| 1702 | rx = self.pg3.get_capture(1) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1703 | self.verify_orig_dhcp_request(rx[0], self.pg3, hostname, self.pg3.local_ip4) |
Jan Gelety | 2a3fb1a | 2018-06-27 10:56:17 +0200 | [diff] [blame] | 1704 | |
| 1705 | # |
| 1706 | # Send an acknowledgment |
| 1707 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1708 | p_ack = ( |
| 1709 | Ether(dst=self.pg3.local_mac, src=self.pg3.remote_mac) |
| 1710 | / IP(src=self.pg3.remote_ip4, dst="255.255.255.255") |
| 1711 | / UDP(sport=DHCP4_SERVER_PORT, dport=DHCP4_CLIENT_PORT) |
| 1712 | / BOOTP( |
| 1713 | op=1, yiaddr=self.pg3.local_ip4, chaddr=mac_pton(self.pg3.local_mac) |
| 1714 | ) |
| 1715 | / DHCP( |
| 1716 | options=[ |
| 1717 | ("message-type", "ack"), |
| 1718 | ("subnet_mask", "255.255.255.0"), |
| 1719 | ("router", self.pg3.remote_ip4), |
| 1720 | ("server_id", self.pg3.remote_ip4), |
| 1721 | ("lease_time", lease_time), |
| 1722 | "end", |
| 1723 | ] |
| 1724 | ) |
| 1725 | ) |
Jan Gelety | 2a3fb1a | 2018-06-27 10:56:17 +0200 | [diff] [blame] | 1726 | |
| 1727 | self.pg3.add_stream(p_ack) |
| 1728 | self.pg_enable_capture(self.pg_interfaces) |
| 1729 | self.pg_start() |
| 1730 | |
| 1731 | # |
| 1732 | # We'll get an ARP request for the router address |
| 1733 | # |
| 1734 | rx = self.pg3.get_capture(1) |
| 1735 | |
| 1736 | self.assertEqual(rx[0][ARP].pdst, self.pg3.remote_ip4) |
| 1737 | |
| 1738 | # |
| 1739 | # At the end of this procedure there should be a connected route |
| 1740 | # in the FIB |
| 1741 | # |
| 1742 | self.assertTrue(find_route(self, self.pg3.local_ip4, 32)) |
| 1743 | self.assertTrue(find_route(self, self.pg3.local_ip4, 24)) |
| 1744 | |
Jan Gelety | 2a3fb1a | 2018-06-27 10:56:17 +0200 | [diff] [blame] | 1745 | # |
Neale Ranns | f6e9b01 | 2019-01-25 06:37:15 -0800 | [diff] [blame] | 1746 | # the route should be gone after the lease expires |
Jan Gelety | 2a3fb1a | 2018-06-27 10:56:17 +0200 | [diff] [blame] | 1747 | # |
Neale Ranns | f6e9b01 | 2019-01-25 06:37:15 -0800 | [diff] [blame] | 1748 | self.assertTrue(self.wait_for_no_route(self.pg3.local_ip4, 32)) |
| 1749 | self.assertTrue(self.wait_for_no_route(self.pg3.local_ip4, 24)) |
Jan Gelety | 2a3fb1a | 2018-06-27 10:56:17 +0200 | [diff] [blame] | 1750 | |
| 1751 | # |
| 1752 | # remove the DHCP config |
| 1753 | # |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 1754 | Client.remove_vpp_config() |
Jan Gelety | 2a3fb1a | 2018-06-27 10:56:17 +0200 | [diff] [blame] | 1755 | |
Neale Ranns | 038e1df | 2019-07-19 14:01:02 +0000 | [diff] [blame] | 1756 | def test_dhcp_client_vlan(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1757 | """DHCP Client w/ VLAN""" |
Neale Ranns | 038e1df | 2019-07-19 14:01:02 +0000 | [diff] [blame] | 1758 | |
| 1759 | vdscp = VppEnum.vl_api_ip_dscp_t |
| 1760 | vqos = VppEnum.vl_api_qos_source_t |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1761 | hostname = "universal-dp" |
Neale Ranns | 038e1df | 2019-07-19 14:01:02 +0000 | [diff] [blame] | 1762 | |
| 1763 | self.pg_enable_capture(self.pg_interfaces) |
| 1764 | |
| 1765 | vlan_100 = VppDot1QSubint(self, self.pg3, 100) |
| 1766 | vlan_100.admin_up() |
| 1767 | |
| 1768 | output = [scapy.compat.chb(4)] * 256 |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1769 | os = b"".join(output) |
| 1770 | rows = [{"outputs": os}, {"outputs": os}, {"outputs": os}, {"outputs": os}] |
Neale Ranns | 038e1df | 2019-07-19 14:01:02 +0000 | [diff] [blame] | 1771 | |
| 1772 | qem1 = VppQosEgressMap(self, 1, rows).add_vpp_config() |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1773 | qm1 = VppQosMark( |
| 1774 | self, vlan_100, qem1, vqos.QOS_API_SOURCE_VLAN |
| 1775 | ).add_vpp_config() |
Neale Ranns | 038e1df | 2019-07-19 14:01:02 +0000 | [diff] [blame] | 1776 | |
| 1777 | # |
| 1778 | # Configure DHCP client on PG3 and capture the discover sent |
| 1779 | # |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 1780 | Client = VppDHCPClient( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1781 | self, vlan_100.sw_if_index, hostname, dscp=vdscp.IP_API_DSCP_EF |
| 1782 | ) |
Jakub Grajciar | 103ba6b | 2019-10-01 11:30:56 +0200 | [diff] [blame] | 1783 | Client.add_vpp_config() |
Neale Ranns | 038e1df | 2019-07-19 14:01:02 +0000 | [diff] [blame] | 1784 | |
| 1785 | rx = self.pg3.get_capture(1) |
| 1786 | |
| 1787 | self.assertEqual(rx[0][Dot1Q].vlan, 100) |
Prashant Maheshwari | 3bcf1a9 | 2019-07-31 21:37:33 +0530 | [diff] [blame] | 1788 | self.assertEqual(rx[0][Dot1Q].prio, 2) |
Neale Ranns | 038e1df | 2019-07-19 14:01:02 +0000 | [diff] [blame] | 1789 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1790 | self.verify_orig_dhcp_discover( |
| 1791 | rx[0], self.pg3, hostname, dscp=vdscp.IP_API_DSCP_EF |
| 1792 | ) |
Neale Ranns | 038e1df | 2019-07-19 14:01:02 +0000 | [diff] [blame] | 1793 | |
Neale Ranns | 808c5b2 | 2017-08-02 05:15:07 -0700 | [diff] [blame] | 1794 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1795 | if __name__ == "__main__": |
Neale Ranns | fca0c24 | 2017-01-13 07:57:46 -0800 | [diff] [blame] | 1796 | unittest.main(testRunner=VppTestRunner) |