From: Andrei Pavel Date: Tue, 22 Jun 2021 08:15:16 +0000 (+0300) Subject: [#1119] add server ID to perfdhcp DHCPRELEASEs X-Git-Tag: Kea-1.9.9~73 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5488536bfcbacabcf58b7d2e6516713184ff0bf3;p=thirdparty%2Fkea.git [#1119] add server ID to perfdhcp DHCPRELEASEs --- diff --git a/src/bin/perfdhcp/test_control.cc b/src/bin/perfdhcp/test_control.cc index 996508ad87..dd7c37a160 100644 --- a/src/bin/perfdhcp/test_control.cc +++ b/src/bin/perfdhcp/test_control.cc @@ -189,6 +189,34 @@ TestControl::createMessageFromAck(const uint16_t msg_type, msg->setCiaddr(ack->getYiaddr()); msg->setHWAddr(ack->getHWAddr()); msg->addOption(generateClientId(msg->getHWAddr())); + if (msg_type == DHCPRELEASE) { + // RFC 2132: DHCPRELEASE MUST include server ID. + if (options_.isUseFirst()) { + // Honor the '-1' flag if it exists. + if (first_packet_serverid_.empty()) { + isc_throw(isc::BadValue, + "Unable to create " + << msg_type_str + << "from the first packet which lacks the server " + "identifier option"); + } + msg->addOption(Option::factory(Option::V4, + DHO_DHCP_SERVER_IDENTIFIER, + first_packet_serverid_)); + } else { + // Otherwise take it from the DHCPACK message. + OptionPtr server_identifier( + ack->getOption(DHO_DHCP_SERVER_IDENTIFIER)); + if (!server_identifier) { + isc_throw(isc::BadValue, + "Unable to create " + << msg_type_str + << "from a DHCPACK message without the server " + "identifier option"); + } + msg->addOption(server_identifier); + } + } return (msg); }