From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202602 header.b=OJ71po7Z; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id EE2F25A0262 for ; Fri, 05 Jun 2026 03:23:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202602; t=1780622614; bh=5AO+ve8YGIIKzUS/h9AZuqsbRp14KgkpNwHD9thPqDQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OJ71po7Zf8ZyBBc/+iX6b/k3cd3l457QwX37JgDzGzZZBYu3lzkheoBcNASn2wVAD kjb+zouaSsqRNI/xHxKQBROs6L8PmStwo+lOE+iTlL2n3BuAqZ4l5TIZ0LBOpyfIY4 JQ7U997f5EAsZSdjUljBPTrcGw9KQyaBH8EKq9uWzEJmA8Xgy2lPqXjEPjR0AtwFyl fmKfeln1uGE0cjA9ZJc6vtIPe0b5htrhZTpRF1YcucKB+Uw4Obf1eC3Sdvy+nAQYzI jPhI/8dT6HQ1BswMqboWR586jd1L/57xJLlz1bhB/oQxSuI+LQSfJI6RJd4ZPszSql ALFGg5xlWglvw== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4gWkGZ6ybzz58bX; Fri, 05 Jun 2026 11:23:34 +1000 (AEST) Date: Fri, 5 Jun 2026 11:16:13 +1000 From: David Gibson To: Anshu Kumari Subject: Re: [PATCH 3/3] dhcpv6: Inject custom options into DHCPv6 replies Message-ID: References: <20260604105150.1977905-1-anskuma@redhat.com> <20260604105150.1977905-4-anskuma@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="YVoD+EV1IjIxAWCj" Content-Disposition: inline In-Reply-To: <20260604105150.1977905-4-anskuma@redhat.com> Message-ID-Hash: I4NCBR7V7QESTEYNEGKSIL7VFHIYUHHI X-Message-ID-Hash: I4NCBR7V7QESTEYNEGKSIL7VFHIYUHHI X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top, sbrivio@redhat.com, jmaloy@redhat.com, lvivier@redhat.com X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --YVoD+EV1IjIxAWCj Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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. >=20 > 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. >=20 > Signed-off-by: Anshu Kumari Reviewed-by: David Gibson > --- > dhcpv6.c | 36 ++++++++++++++++++++++++++++++++++++ > 1 file changed, 36 insertions(+) >=20 > 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 i= ov_tail *data, > return offset + sizeof(struct opt_hdr) + opt_len; > } > =20 > +/** > + * dhcpv6_custom_opts_fill() - Append user-specified custom options to r= eply > + * @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 =3D 0; i < c->custom_v6opts_count; i++) { > + struct opt_hdr *hdr; > + uint16_t len =3D 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 =3D (struct opt_hdr *)(buf + offset); > + hdr->t =3D htons(c->custom_v6opts[i].code); > + hdr->l =3D htons(len); > + offset +=3D sizeof(struct opt_hdr); > + > + memcpy(buf + offset, c->custom_v6opts[i].val, len); > + offset +=3D 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 =3D dhcpv6_dns_fill(c, (char *)&resp, n); > n =3D dhcpv6_client_fqdn_fill(data, c, (char *)&resp, n); > + n =3D dhcpv6_custom_opts_fill(c, (char *)&resp, n); > =20 > resp.hdr.xid =3D mh->xid; > =20 > --=20 > 2.54.0 >=20 --=20 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 --YVoD+EV1IjIxAWCj Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmoiI1wACgkQzQJF27ox 2GdfBg/8CpHKnL47K3A6fxBv86PSsGMxruLwhSdPDuRP9q9QpJyWCTKBoEGu7xHm 0Ab0YXpmLbR1koNIEfJOJw02D+oQLqTbRoPiJJgYzWOszpKg+VELh2btpNIh7Ffq wtql3hsQp5t7jYIo2648lA5IR+DyTrFYfvE++0Q0pHI75+MYpOPTvV8Oz/r1uuz7 dlb3EmMrG6punkZvYUEhAPsr3bqQ7bX3CBNI3E+vykeTTup011FknXHxly/d3Gz1 zbr7j7Sd67I7bn+9RmHTByND1o4mhWFc5ealGulSB8940pFg9F4aUkOpfr+nUAFC Xg1AheXo/7X0vlEBq618hpIwbuWMIR9ERlKsrdvEhxIgRSDdXhI0JoOh7wjmQMj4 CZzpBa8zRuS6AxFlgzz/f6lwTf9y99e31WT7z2zOzdE38kSJ1dZCPUQ8CUNvTRQe pHmBRG8AbgcPeexzBN1HM4Xf7JQ5zB3IPCR+xvQU4RwVNwYtRcpSzRE1xzU8ftjz gCJuo3Q3I3/tWB5NXVmdHduw59jDcliUzupS5FVAROwYWBJeqB/c+fNi09zM5VWy gy8zbj7Fhe+j1krdCXXJKFZr84afeJVq3xEK7wFaK/FOuDebBAlgl/rGNiClZPDX 5Lx68T3uqkaOI2QMShCWGoIwcK2QSm6pZX/PDjoY8ALgZa+oNqI= =7NgR -----END PGP SIGNATURE----- --YVoD+EV1IjIxAWCj--