]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1548] kea-dhcpX update outbound fqdn after ddnsX_update
authorThomas Markwalder <tmark@isc.org>
Thu, 7 Apr 2022 17:07:17 +0000 (13:07 -0400)
committerThomas Markwalder <tmark@isc.org>
Thu, 21 Apr 2022 14:19:20 +0000 (10:19 -0400)
Moved responsibility from hook lib to servers. This makes the hook
point more uniformly usable to custom hook developers

src/bin/dhcp4/dhcp4_srv.cc
    Dhcpv4Srv::processClientName() - update the FQDN option
    in response as part of ddns4_update hook point logic

src/bin/dhcp6/dhcp6_srv.cc
    Dhcpv6Srv::processClientFqdn() - update the FQDN option
    in response as part of ddns6_update hook point logic

src/bin/dhcp4/dhcp4_srv.cc
src/bin/dhcp6/dhcp6_srv.cc

index 8f74d06428b6cf7c8603fd57cfe02b9778d2b2eb..cc323112bc3b9286e0a08c9f96c2f0d313fb5c68 100644 (file)
@@ -2100,7 +2100,6 @@ Dhcpv4Srv::processClientName(Dhcpv4Exchange& ex) {
             }
         }
 
-
         // Optionally, call a hook that may possibly override the decisions made
         // earlier.
         if (HooksManager::calloutsPresent(Hooks.hook_index_ddns4_update_)) {
@@ -2138,6 +2137,14 @@ Dhcpv4Srv::processClientName(Dhcpv4Exchange& ex) {
                 hostname = hook_hostname;
                 fqdn_fwd = hook_fqdn_fwd;
                 fqdn_rev = hook_fqdn_rev;
+
+                // If there's an outbound FQDN option in the response we need
+                // to update it with the new host name.
+                Option4ClientFqdnPtr fqdn = boost::dynamic_pointer_cast<Option4ClientFqdn>
+                                            (resp->getOption(DHO_FQDN));
+                if (fqdn) {
+                    fqdn->setDomainName(hook_hostname, Option4ClientFqdn::FULL);
+                }
             }
         }
 
index 4145e7fbe043541498d79ffc626425912d3ffe97..8ca84109ca9c52b2825e336811f75bcc2fd1c36e 100644 (file)
@@ -1972,12 +1972,18 @@ Dhcpv6Srv::processClientFqdn(const Pkt6Ptr& question, const Pkt6Ptr& answer,
             LOG_DEBUG(hooks_logger, DBGLVL_PKT_HANDLING, DHCP6_HOOK_DDNS_UPDATE)
                       .arg(ctx.hostname_).arg(hook_hostname).arg(ctx.fwd_dns_update_).arg(hook_fwd_dns_update)
                       .arg(ctx.rev_dns_update_).arg(hook_rev_dns_update);
+
+            // Update the FQDN option in the response.
+            fqdn_resp = boost::dynamic_pointer_cast<Option6ClientFqdn>(question->getOption(D6O_CLIENT_FQDN));
+            if (fqdn) {
+                fqdn_resp->setDomainName(hook_hostname, Option6ClientFqdn::FULL);
+            }
+
             ctx.hostname_ = hook_hostname;
             ctx.fwd_dns_update_ = hook_fwd_dns_update;
             ctx.rev_dns_update_ = hook_rev_dns_update;
         }
     }
-
 }
 
 void