From: Tomek Mrugalski Date: Sat, 15 Mar 2025 14:56:04 +0000 (+0100) Subject: [#3802] IA_NA/IAAddr => IAAddr fix in add-reg-inform X-Git-Tag: Kea-2.7.7~16 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=03b8d44dfaa8b7dc3617755d75a6b76c56c19b65;p=thirdparty%2Fkea.git [#3802] IA_NA/IAAddr => IAAddr fix in add-reg-inform --- diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc index 7a9274b1a1..a6d587c995 100644 --- a/src/bin/dhcp6/dhcp6_srv.cc +++ b/src/bin/dhcp6/dhcp6_srv.cc @@ -4497,40 +4497,28 @@ Dhcpv6Srv::processAddrRegInform(AllocEngine::ClientContext6& ctx) { addr = addr_reg_inf->getRelay6LinkAddress(relay_level - 1); } - Option6IAPtr ia; Option6IAAddrPtr iaaddr; Lease6Ptr old_lease; + const uint32_t no_iaid = 0; /* there's no IAID in the ADDR-REG-INFORM */ // Check if the message is bad and shout be dropped. try { // Get IA_NA from the Address registration inform. // There must be one. - OptionCollection ias = addr_reg_inf->getOptions(D6O_IA_NA); - if (ias.size() != 1) { - isc_throw(RFCViolation, "Exactly 1 IA_NA option expected, but " - << ias.size() << " received"); + OptionCollection addrs = addr_reg_inf->getOptions(D6O_IAADDR); + if (addrs.size() != 1) { + isc_throw(RFCViolation, "Exactly 1 IAADDRESS option expected, but " + << addrs.size() << " received"); } - ia = boost::dynamic_pointer_cast(ias.begin()->second); - if (!ia) { - isc_throw(Unexpected, "can't convert the IA_NA option"); + iaaddr = boost::dynamic_pointer_cast(addrs.begin()->second); + if (!iaaddr) { + isc_throw(Unexpected, "can't convert the IAAddress option"); } // Set per-IA context values. ctx.createIAContext(); ctx.currentIA().type_ = Lease::TYPE_NA; - ctx.currentIA().iaid_ = ia->getIAID(); - ctx.currentIA().ia_rsp_ = ia; - - // Get IAADDR from the IA_NA. There must be the only option. - OptionCollection iaaddrs = ia->getOptions(); - if (iaaddrs.size() != 1) { - isc_throw(RFCViolation, "Exactly 1 IA_NA sub-option expected, but " - << iaaddrs.size() << " received"); - } - iaaddr = boost::dynamic_pointer_cast(iaaddrs.begin()->second); - if (!iaaddr) { - isc_throw(RFCViolation, "Can't get the IAADDR sub-option"); - } + ctx.currentIA().iaid_ = no_iaid; // Client and IADDR addresses must match. if (addr != iaaddr->getAddress()) { @@ -4580,13 +4568,13 @@ Dhcpv6Srv::processAddrRegInform(AllocEngine::ClientContext6& ctx) { // Build response. Pkt6Ptr addr_reg_rep(new Pkt6(DHCPV6_ADDR_REG_REPLY, addr_reg_inf->getTransid())); - addr_reg_rep->addOption(ia); + addr_reg_rep->addOption(iaaddr); // Process FQDN. processClientFqdn(addr_reg_inf, addr_reg_rep, ctx); Lease6Ptr lease(new Lease6(Lease::TYPE_NA, addr, ctx.duid_, - ia->getIAID(), iaaddr->getPreferred(), + no_iaid, iaaddr->getPreferred(), iaaddr->getValid(), subnet->getID(), ctx.hwaddr_)); lease->state_ = Lease6::STATE_REGISTERED;