Skip to content

Commit 3946574

Browse files
committed
[#3683] Some fixes and improvements
1 parent 6861ed9 commit 3946574

File tree

7 files changed

+259
-73
lines changed

7 files changed

+259
-73
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[func] fdupont
2+
Added experimental support for registering self-generated
3+
IPv6 addresses using DHCPv6 (RFC 9686).
4+
(Gitlab #3683)

src/bin/dhcp6/dhcp6_hooks.dox

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -352,15 +352,16 @@ called before "subnet6_select".
352352
- name: @b response6, type: isc::dhcp::Pkt6Ptr, direction: <b>in</b>
353353
- name: @b address6, type: isc::asiolink::IOAddress, direction: <b>in</b>
354354
- name: @b old_lease6, type: isc::dhcp::Lease6Ptr, direction: <b>in</b>
355-
- name: @b new_lease6, type: isc::dhcp::Lease6Ptr, direction: <b>in/out<b>
355+
- name: @b new_lease6, type: isc::dhcp::Lease6Ptr, direction: <b>in<b>
356356

357357
- @b Description: this callout is executed when an addr-reg-inform was
358-
received and successfully processed. When the new_lease is cleared
359-
this instructs the server to make stateless registration i.e. address
360-
registration is used only for side effects and does not maintain state.
358+
received and successfully processed before the lease operation which
359+
maintains when not skipped the registration state.
361360

362-
- <b>Next step status</b>: If any callout sets the status to SKIP or DROP,
363-
the server will cancel current packet processing.
361+
- <b>Next step status</b>: If any callout sets the status to SKIP, the
362+
lease operation (add or update) will be skipped. If any callout sets the
363+
status to DROP, the server will cancel current packet processing and
364+
the query dropped.
364365

365366
@subsection dhcpv6Leases6Committed leases6_committed
366367

src/bin/dhcp6/dhcp6_messages.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ extern const isc::log::MessageID DHCP6_DYNAMIC_RECONFIGURATION = "DHCP6_DYNAMIC_
6565
extern const isc::log::MessageID DHCP6_DYNAMIC_RECONFIGURATION_FAIL = "DHCP6_DYNAMIC_RECONFIGURATION_FAIL";
6666
extern const isc::log::MessageID DHCP6_DYNAMIC_RECONFIGURATION_SUCCESS = "DHCP6_DYNAMIC_RECONFIGURATION_SUCCESS";
6767
extern const isc::log::MessageID DHCP6_FLEX_ID = "DHCP6_FLEX_ID";
68+
extern const isc::log::MessageID DHCP6_HOOK_ADDR6_REGISTER_DROP = "DHCP6_HOOK_ADDR6_REGISTER_DROP";
6869
extern const isc::log::MessageID DHCP6_HOOK_ADDR6_REGISTER_SKIP = "DHCP6_HOOK_ADDR6_REGISTER_SKIP";
6970
extern const isc::log::MessageID DHCP6_HOOK_BUFFER_RCVD_DROP = "DHCP6_HOOK_BUFFER_RCVD_DROP";
7071
extern const isc::log::MessageID DHCP6_HOOK_BUFFER_RCVD_SKIP = "DHCP6_HOOK_BUFFER_RCVD_SKIP";
@@ -237,7 +238,8 @@ const char* values[] = {
237238
"DHCP6_DYNAMIC_RECONFIGURATION_FAIL", "dynamic server reconfiguration failed with file: %1",
238239
"DHCP6_DYNAMIC_RECONFIGURATION_SUCCESS", "dynamic server reconfiguration succeeded with file: %1",
239240
"DHCP6_FLEX_ID", "%1: flexible identifier generated for incoming packet: %2",
240-
"DHCP6_HOOK_ADDR6_REGISTER_SKIP", "%1: ADDR-REG-INFORM for %2 is dropped, because a callout set the next step to SKIP",
241+
"DHCP6_HOOK_ADDR6_REGISTER_DROP", "%1: ADDR-REG-INFORM for %2 is dropped, because a callout set the next step to DROP",
242+
"DHCP6_HOOK_ADDR6_REGISTER_SKIP", "%1: lease %2 operation for %3 is skipped, because a callout set the next step to SKIP",
241243
"DHCP6_HOOK_BUFFER_RCVD_DROP", "received buffer from %1 to %2 over interface %3 was dropped because a callout set the drop flag",
242244
"DHCP6_HOOK_BUFFER_RCVD_SKIP", "received buffer from %1 to %2 over interface %3 is not parsed because a callout set the next step to SKIP",
243245
"DHCP6_HOOK_BUFFER_SEND_SKIP", "%1: prepared DHCPv6 response was dropped because a callout set the next step to SKIP",

src/bin/dhcp6/dhcp6_messages.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ extern const isc::log::MessageID DHCP6_DYNAMIC_RECONFIGURATION;
6666
extern const isc::log::MessageID DHCP6_DYNAMIC_RECONFIGURATION_FAIL;
6767
extern const isc::log::MessageID DHCP6_DYNAMIC_RECONFIGURATION_SUCCESS;
6868
extern const isc::log::MessageID DHCP6_FLEX_ID;
69+
extern const isc::log::MessageID DHCP6_HOOK_ADDR6_REGISTER_DROP;
6970
extern const isc::log::MessageID DHCP6_HOOK_ADDR6_REGISTER_SKIP;
7071
extern const isc::log::MessageID DHCP6_HOOK_BUFFER_RCVD_DROP;
7172
extern const isc::log::MessageID DHCP6_HOOK_BUFFER_RCVD_SKIP;

src/bin/dhcp6/dhcp6_messages.mes

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,13 +380,20 @@ and the expression specified in its configuration generated (was evaluated to)
380380
an identifier for incoming packet. This debug message is mainly intended as a
381381
debugging assistance for flexible identifier.
382382

383-
% DHCP6_HOOK_ADDR6_REGISTER_SKIP %1: ADDR-REG-INFORM for %2 is dropped, because a callout set the next step to SKIP
383+
% DHCP6_HOOK_ADDR6_REGISTER_DROP %1: ADDR-REG-INFORM for %2 is dropped, because a callout set the next step to DROP
384384
Logged at debug log level 40.
385385
This debug message is printed when a callout installed on the addr6_register
386-
hook point sets the next step to SKIP. For this particular hook point, the
386+
hook point sets the next step to DROP. For this particular hook point, the
387387
value setting instructs the server to cancel the address registration and
388388
drop the packet.
389389

390+
% DHCP6_HOOK_ADDR6_REGISTER_SKIP %1: lease %2 operation for %3 is skipped, because a callout set the next step to SKIP
391+
Logged at debug log level 40.
392+
This debug message is printed when a callout installed on the addr6_register
393+
hook point sets the next step to SKIP. For this particular hook point, the
394+
value setting instructs the server to skip the lease add or update operation
395+
for the registered address so not maintaining the registration state.
396+
390397
% DHCP6_HOOK_BUFFER_RCVD_DROP received buffer from %1 to %2 over interface %3 was dropped because a callout set the drop flag
391398
Logged at debug log level 15.
392399
This debug message is printed when a callout installed on buffer6_receive

src/bin/dhcp6/dhcp6_srv.cc

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4611,6 +4611,7 @@ Dhcpv6Srv::processAddrRegInform(AllocEngine::ClientContext6& ctx) {
46114611
appendRequestedVendorOptions(addr_reg_inf, addr_reg_rep, ctx, co_list);
46124612

46134613
// Handle the "addr6_register" callout point.
4614+
bool skip = false;
46144615
if (HooksManager::calloutsPresent(Hooks.hook_index_addr6_register_)) {
46154616
CalloutHandlePtr callout_handle = getCalloutHandle(addr_reg_inf);
46164617
ScopedCalloutHandleState callout_handle_state(callout_handle);
@@ -4636,25 +4637,27 @@ Dhcpv6Srv::processAddrRegInform(AllocEngine::ClientContext6& ctx) {
46364637
HooksManager::callCallouts(Hooks.hook_index_addr6_register_, *callout_handle);
46374638

46384639
// Callouts decided to skip the next processing step. This means
4639-
// cancel processing so drop.
4640-
if ((callout_handle->getStatus() == CalloutHandle::NEXT_STEP_SKIP) ||
4641-
(callout_handle->getStatus() == CalloutHandle::NEXT_STEP_DROP)) {
4640+
// to not perform the lease operation.
4641+
if (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_SKIP) {
46424642
LOG_DEBUG(hooks_logger, DBG_DHCP6_HOOKS,
46434643
DHCP6_HOOK_ADDR6_REGISTER_SKIP)
46444644
.arg(addr_reg_inf->getLabel())
4645+
.arg(old_lease ? "update" : "add")
4646+
.arg(addr);
4647+
skip = true;
4648+
} else
4649+
// Callouts decided to drop the next processing step. This means
4650+
// cancel processing so drop the query.
4651+
if (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_DROP) {
4652+
LOG_DEBUG(hooks_logger, DBG_DHCP6_HOOKS,
4653+
DHCP6_HOOK_ADDR6_REGISTER_DROP)
4654+
.arg(addr_reg_inf->getLabel())
46454655
.arg(addr);
46464656
return (Pkt6Ptr());
46474657
}
4648-
4649-
Lease6Ptr new_lease;
4650-
callout_handle->getArgument("new_lease6", new_lease);
4651-
if (!new_lease) {
4652-
// Stateless registration: skip lease code.
4653-
lease.reset();
4654-
}
46554658
}
46564659

4657-
if (lease) {
4660+
if (!skip) {
46584661
// Statefull registration.
46594662
if (old_lease) {
46604663
try {
@@ -4666,8 +4669,6 @@ Dhcpv6Srv::processAddrRegInform(AllocEngine::ClientContext6& ctx) {
46664669
.arg(ex.what());
46674670
return (Pkt6Ptr());
46684671
}
4669-
// Save the old lease for the lease6_committed callout.
4670-
ctx.currentIA().old_leases_.push_back(old_lease);
46714672
// Save the old lease for the DNS update.
46724673
ctx.currentIA().changed_leases_.push_back(old_lease);
46734674
// Update stats when the subnet changed.
@@ -4704,7 +4705,7 @@ Dhcpv6Srv::processAddrRegInform(AllocEngine::ClientContext6& ctx) {
47044705
StatsMgr::instance().addValue("cumulative-registered-nas",
47054706
static_cast<int64_t>(1));
47064707
}
4707-
// Save the new lease for the lease6_committed callout.
4708+
// Save the new lease for the leases6_committed callout.
47084709
ctx.new_leases_.push_back(lease);
47094710
}
47104711

0 commit comments

Comments
 (0)