Fix DHCPv6 options serialization to prevent extra bytes in replies #626
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed Changes
In the
generate_reply_options
function, fixed an issue where DHCPv6 reply packets contained extra unintended bytes at the end. The problem was due to theoptions
pointer not being incremented after copying theopt_rapid
andboot_file_url
options into the packet buffer.Changes made:
opt_rapid
, theoptions
pointer is now incremented byreply_options.opt_rapid_len
.boot_file_url
, theoptions
pointer is now incremented byreply_options.opt_boot_file_len
.These changes ensure that all DHCPv6 options are correctly serialized in the packet buffer without overlaps or gaps. By properly advancing the
options
pointer, we prevent unintended data from being included at the end of the packet, eliminating the extra bytes that were being sent.This fix addresses the issue where clients were receiving malformed DHCPv6 packets due to the extra bytes, which could lead to communication errors or unexpected behavior.