From: David Gibson <david@gibson.dropbear.id.au>
To: Anshu Kumari <anskuma@redhat.com>
Cc: passt-dev@passt.top, sbrivio@redhat.com, jmaloy@redhat.com,
lvivier@redhat.com
Subject: Re: [PATCH 3/3] dhcpv6: Inject custom options into DHCPv6 replies
Date: Fri, 5 Jun 2026 11:16:13 +1000 [thread overview]
Message-ID: <aiIjXfkQiYsNuTTF@zatzit> (raw)
In-Reply-To: <20260604105150.1977905-4-anskuma@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2651 bytes --]
On Thu, Jun 04, 2026 at 04:21:50PM +0530, Anshu Kumari wrote:
> Add dhcpv6_custom_opts_fill() which appends user-specified custom
> options to DHCPv6 response packets, and call it from the main dhcpv6()
> handler after the built-in DNS and FQDN options.
>
> Each custom option is written with its DHCPv6 option header (code +
> length) followed by the binary-encoded value from dhcpv6_opt_parse().
> Options that would exceed the IPv6 minimum MTU are skipped with a
> debug message.
>
> Signed-off-by: Anshu Kumari <anskuma@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> dhcpv6.c | 36 ++++++++++++++++++++++++++++++++++++
> 1 file changed, 36 insertions(+)
>
> diff --git a/dhcpv6.c b/dhcpv6.c
> index 85e2926..590c40d 100644
> --- a/dhcpv6.c
> +++ b/dhcpv6.c
> @@ -798,6 +798,41 @@ static size_t dhcpv6_client_fqdn_fill(const struct iov_tail *data,
> return offset + sizeof(struct opt_hdr) + opt_len;
> }
>
> +/**
> + * dhcpv6_custom_opts_fill() - Append user-specified custom options to reply
> + * @c: Execution context
> + * @buf: Response message buffer
> + * @offset: Current offset in buffer
> + *
> + * Return: updated offset after appending custom options
> + */
> +static size_t dhcpv6_custom_opts_fill(const struct ctx *c,
> + char *buf, int offset)
> +{
> + int i;
> +
> + for (i = 0; i < c->custom_v6opts_count; i++) {
> + struct opt_hdr *hdr;
> + uint16_t len = c->custom_v6opts[i].len;
> +
> + if ((size_t)offset + sizeof(struct opt_hdr) + len > OPT_MAX_SIZE) {
> + debug("DHCPv6: custom option %u doesn't fit, skipping",
> + c->custom_v6opts[i].code);
> + continue;
> + }
> +
> + hdr = (struct opt_hdr *)(buf + offset);
> + hdr->t = htons(c->custom_v6opts[i].code);
> + hdr->l = htons(len);
> + offset += sizeof(struct opt_hdr);
> +
> + memcpy(buf + offset, c->custom_v6opts[i].val, len);
> + offset += len;
> + }
> +
> + return offset;
> +}
> +
> /**
> * dhcpv6() - Check if this is a DHCPv6 message, reply as needed
> * @c: Execution context
> @@ -936,6 +971,7 @@ int dhcpv6(struct ctx *c, struct iov_tail *data,
> sizeof(struct opt_hdr) + ntohs(client_id->l);
> n = dhcpv6_dns_fill(c, (char *)&resp, n);
> n = dhcpv6_client_fqdn_fill(data, c, (char *)&resp, n);
> + n = dhcpv6_custom_opts_fill(c, (char *)&resp, n);
>
> resp.hdr.xid = mh->xid;
>
> --
> 2.54.0
>
--
David Gibson (he or they) | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you, not the other way
| around.
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2026-06-05 1:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-04 10:51 [PATCH 0/3] [PATCH 0/3] dhcpv6: Add --dhcpv6-opt for custom DHCPv6 options Anshu Kumari
2026-06-04 10:51 ` [PATCH 1/3] conf: Add --dhcpv6-opt command-line option Anshu Kumari
2026-06-05 0:50 ` David Gibson
2026-06-04 10:51 ` [PATCH 2/3] dhcpv6: Add option type table and value parser Anshu Kumari
2026-06-05 1:08 ` David Gibson
2026-06-04 10:51 ` [PATCH 3/3] dhcpv6: Inject custom options into DHCPv6 replies Anshu Kumari
2026-06-05 1:16 ` David Gibson [this message]
2026-06-04 11:00 ` [PATCH 0/3] [PATCH 0/3] dhcpv6: Add --dhcpv6-opt for custom DHCPv6 options Anshu Kumari
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aiIjXfkQiYsNuTTF@zatzit \
--to=david@gibson.dropbear.id.au \
--cc=anskuma@redhat.com \
--cc=jmaloy@redhat.com \
--cc=lvivier@redhat.com \
--cc=passt-dev@passt.top \
--cc=sbrivio@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).