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=202606 header.b=iJvlpu0J; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 450BF5A0272 for ; Fri, 19 Jun 2026 06:03:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202606; t=1781841807; bh=l82ggiukBalhEzQQyDc/RsI16mju2Myrx6VvFzlM6kY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=iJvlpu0JG6nXuqj9/10fu47V+9FlrYGywUAF5vcflK5Kt5A1Q0jjyOVGyIVprcJy8 KQR/3TgUcrD97gtafBPIf7Be9pfDiY66hTcXpxcuyfex8OZOrfyE8vk+gKKMKv8U4r K+q5FUTGxuzIO9LLWGoPQAaazuONCNkrMdS+ViynuoHdOqGzYu21UmXAU+JmfkP1jE 5K3o7jDbVqRTz58GbVM2dwDE72/ubJ6CK8Tk5NVAH1bX/H9XuNnUJoztUsBByw2A+V CObrgqi9wFOofOWb5JR0DqjJn4J6mSrCGJyBkhnU5dyJQtRUHCoVvlv80IcwLjAu4x Yk6ALCFbjN8Bg== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4ghP8b54G4z4vyt; Fri, 19 Jun 2026 14:03:27 +1000 (AEST) Date: Fri, 19 Jun 2026 14:03:10 +1000 From: David Gibson To: Anshu Kumari Subject: Re: [PATCH v2 2/2] dhcpv6: Inject custom options into DHCPv6 replies Message-ID: References: <20260618120529.1768765-1-anskuma@redhat.com> <20260618120529.1768765-3-anskuma@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="z3HQi6Rj7AimIGc9" Content-Disposition: inline In-Reply-To: <20260618120529.1768765-3-anskuma@redhat.com> Message-ID-Hash: G3SOL4IB6VEREZOVGI3G3NSG3FX3AMUO X-Message-ID-Hash: G3SOL4IB6VEREZOVGI3G3NSG3FX3AMUO 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: sbrivio@redhat.com, passt-dev@passt.top, lvivier@redhat.com, jmaloy@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: --z3HQi6Rj7AimIGc9 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jun 18, 2026 at 05:35:29PM +0530, Anshu Kumari wrote: > Append user-specified options from --dhcpv6-opt to DHCPv6 reply > messages. Options are parsed from the stored string value at reply > time using dhcpv6_opt_parse(), and skipped with a debug message if > they exceed the available space. >=20 > Link: https://bugs.passt.top/show_bug.cgi?id=3D192 > Signed-off-by: Anshu Kumari > --- > v2: > - Updated dhcpv6_custom_opts_fill() to parse str at reply time > using dhcpv6_opt_parse() instead of copying cached val/len. As with DHCPv4, it's not that I'm against storing the parsed values persistently, just that I'm against storing them twice. The existing data structures for DHCPv6 are different, so maybe there's not an obvious place to store pre-parsed options. > --- > dhcpv6.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 44 insertions(+) >=20 > diff --git a/dhcpv6.c b/dhcpv6.c > index 1e1dd0d..6b1e90b 100644 > --- a/dhcpv6.c > +++ b/dhcpv6.c > @@ -748,6 +748,49 @@ 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 As discussed elsewhere "custom" isn't a great name. "user" might be better, or just drop it. > + * @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->dhcpv6_opts_count; i++) { > + uint16_t code =3D c->dhcpv6_opts[i].code; > + struct opt_hdr *hdr; > + uint8_t val[255]; > + int vlen; > + > + vlen =3D dhcpv6_opt_parse(code, c->dhcpv6_opts[i].str, > + val, sizeof(val)); > + if (vlen < 0) > + continue; > + > + if ((size_t)offset + sizeof(struct opt_hdr) + vlen > > + OPT_MAX_SIZE) { > + debug("DHCPv6: custom option %u doesn't fit," > + " skipping", code); > + continue; > + } > + > + hdr =3D (struct opt_hdr *)(buf + offset); > + hdr->t =3D htons(code); > + hdr->l =3D htons(vlen); > + offset +=3D sizeof(struct opt_hdr); > + > + memcpy(buf + offset, val, vlen); > + offset +=3D vlen; > + } > + > + return offset; > +} > + > /** > * dhcpv6() - Check if this is a DHCPv6 message, reply as needed > * @c: Execution context > @@ -886,6 +929,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 --z3HQi6Rj7AimIGc9 Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmo0v3AACgkQzQJF27ox 2GcOIw//Y9ZExX1QujR2Wiq1ic9BzS7E/SIgc1zItpY2ciJYd/hvZeqybBc7YnJa 0XRfNMde5SfxBdfhv2QCRXuWKQrLOfM75ceSYrGAes7aRfdDRPvVKsz19kQTjPcP c2YWyX2TqPfcX/v1JiyICpHsXbYMksTzNuGwraoG2s5PBU0nwRZ2rvjuodRP5WWr SD47f9pmjg+UJAQa2ebmg25Z9iffxwuacPqCQzIgkkvieIvzslRYEbAcBSIkoGPO U3CVGS5O/W/z5HP8LcqgXoBD4XCdmZFTiyGJ0aW2dDFH8tgQLEKm3cCjTaYtjdfH 1nI8B73iviM8phtbYKoE2qmS5qqxqGmTVzTijpdSR04Ww+mnGn+x5MEQk7w7oBrl LPYYoqFC3QqzkXEudbyZr+VGKlpT5CHeOi+qoQxVuktDYoX/Pep28vh/7yFwspcW zm/7zZgi6TLBhwCv+c0+PfwNr/iwJ+uxSAs4JrAb5kTdx/7rIEGDuRD7gqHez4Jm nPk1bM/c9vBF1d0+v82eww23Qfp6CE2RVSkCJSoPP2qOFwrS6pPYjKRnL9oumIXH 8r3Wz2mAMJFdefl0tyGVM+dezkCzVx5BgH6xVCkjJ2Lk3hmcH7OfIXq8+E4cYarW 1Ri8rTfuJ3qDqmqmAnklJUFnOTAy95QpgxeoNQsQUu0n3uORO/c= =UDzp -----END PGP SIGNATURE----- --z3HQi6Rj7AimIGc9--