From 02e7cb272bfe90f59e25b28ec14e7938dbfac47e Mon Sep 17 00:00:00 2001 From: Francis Dupont Date: Fri, 19 Jan 2024 14:44:26 +0100 Subject: [PATCH] [#2022] Added PARK status handle --- src/bin/dhcp6/dhcp6_messages.cc | 2 ++ src/bin/dhcp6/dhcp6_messages.h | 1 + src/bin/dhcp6/dhcp6_messages.mes | 5 +++++ src/bin/dhcp6/dhcp6_srv.cc | 9 +++++++++ 4 files changed, 17 insertions(+) diff --git a/src/bin/dhcp6/dhcp6_messages.cc b/src/bin/dhcp6/dhcp6_messages.cc index ac59966033..4df743c68f 100644 --- a/src/bin/dhcp6/dhcp6_messages.cc +++ b/src/bin/dhcp6/dhcp6_messages.cc @@ -84,6 +84,7 @@ extern const isc::log::MessageID DHCP6_HOOK_PACKET_RCVD_SKIP = "DHCP6_HOOK_PACKE extern const isc::log::MessageID DHCP6_HOOK_PACKET_SEND_DROP = "DHCP6_HOOK_PACKET_SEND_DROP"; extern const isc::log::MessageID DHCP6_HOOK_PACKET_SEND_SKIP = "DHCP6_HOOK_PACKET_SEND_SKIP"; extern const isc::log::MessageID DHCP6_HOOK_SUBNET6_SELECT_DROP = "DHCP6_HOOK_SUBNET6_SELECT_DROP"; +extern const isc::log::MessageID DHCP6_HOOK_SUBNET6_SELECT_PARK = "DHCP6_HOOK_SUBNET6_SELECT_PARK"; extern const isc::log::MessageID DHCP6_HOOK_SUBNET6_SELECT_SKIP = "DHCP6_HOOK_SUBNET6_SELECT_SKIP"; extern const isc::log::MessageID DHCP6_INIT_FAIL = "DHCP6_INIT_FAIL"; extern const isc::log::MessageID DHCP6_LEASE_ADVERT = "DHCP6_LEASE_ADVERT"; @@ -258,6 +259,7 @@ const char* values[] = { "DHCP6_HOOK_PACKET_SEND_DROP", "%1: prepared DHCPv6 response was not sent because a callout set the next ste to DROP", "DHCP6_HOOK_PACKET_SEND_SKIP", "%1: prepared DHCPv6 response is not built because a callout set the next step to SKIP", "DHCP6_HOOK_SUBNET6_SELECT_DROP", "%1: packet was dropped because a callout set the drop flag", + "DHCP6_HOOK_SUBNET6_SELECT_PARK", "%1: packet was parked", "DHCP6_HOOK_SUBNET6_SELECT_SKIP", "%1: no subnet was selected because a callout set the next step to SKIP", "DHCP6_INIT_FAIL", "failed to initialize Kea server: %1", "DHCP6_LEASE_ADVERT", "%1: lease for address %2 and iaid=%3 will be advertised", diff --git a/src/bin/dhcp6/dhcp6_messages.h b/src/bin/dhcp6/dhcp6_messages.h index d087bb317a..5df401a99e 100644 --- a/src/bin/dhcp6/dhcp6_messages.h +++ b/src/bin/dhcp6/dhcp6_messages.h @@ -85,6 +85,7 @@ extern const isc::log::MessageID DHCP6_HOOK_PACKET_RCVD_SKIP; extern const isc::log::MessageID DHCP6_HOOK_PACKET_SEND_DROP; extern const isc::log::MessageID DHCP6_HOOK_PACKET_SEND_SKIP; extern const isc::log::MessageID DHCP6_HOOK_SUBNET6_SELECT_DROP; +extern const isc::log::MessageID DHCP6_HOOK_SUBNET6_SELECT_PARK; extern const isc::log::MessageID DHCP6_HOOK_SUBNET6_SELECT_SKIP; extern const isc::log::MessageID DHCP6_INIT_FAIL; extern const isc::log::MessageID DHCP6_LEASE_ADVERT; diff --git a/src/bin/dhcp6/dhcp6_messages.mes b/src/bin/dhcp6/dhcp6_messages.mes index 288663b9e6..d0e50ce817 100644 --- a/src/bin/dhcp6/dhcp6_messages.mes +++ b/src/bin/dhcp6/dhcp6_messages.mes @@ -472,6 +472,11 @@ point, the setting of the flag instructs the server to drop the received packet. The argument holds the client and transaction identification information. +% DHCP6_HOOK_SUBNET6_SELECT_PARK %1: packet was parked +This debug message is printed when a callout installed on the +subnet6_select hook point set the park flag. The argument holds the +client and transaction identification information. + % DHCP6_HOOK_SUBNET6_SELECT_SKIP %1: no subnet was selected because a callout set the next step to SKIP This debug message is printed when a callout installed on the subnet6_select hook point set the next step to SKIP value. For this particular hook diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc index c7050038a1..4a0e045168 100644 --- a/src/bin/dhcp6/dhcp6_srv.cc +++ b/src/bin/dhcp6/dhcp6_srv.cc @@ -2013,6 +2013,15 @@ Dhcpv6Srv::selectSubnet(const Pkt6Ptr& question, bool& drop) { return (Subnet6Ptr()); } + // Callouts parked the packet. Same as drop but callouts will resume + // processing or drop the packet later. + if (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_PARK) { + LOG_DEBUG(hooks_logger, DBG_DHCP6_HOOKS, DHCP6_HOOK_SUBNET6_SELECT_PARK) + .arg(question->getLabel()); + drop = true; + return (Subnet6Ptr()); + } + // Use whatever subnet was specified by the callout callout_handle->getArgument("subnet6", subnet); }