From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=fail (p=quarantine dis=none) header.from=redhat.com Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTPS id 27B2F5A0271 for ; Sun, 25 Oct 2026 13:01:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1792929703; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tPXPIBL1MZh1wmM9Xj8vl9E4qBOzPSRn4wVhLsH3hZw=; b=AHWZaLfKK6zIY/R8L7on0TjRn62Q6jeatz9ysWEnnoDVyzXN8JGWAQvXBt3zcAUOm76wh9 M4/o6NKhKE9wVh1IfZA046vfgKIhQPlxhxMsR6+0H7CbdqUyHZXLTAZjDNAUP2eWAeuGMD usV5cbIeMsa2ODMqnsTj+Ve4SGGe/s0= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-660-_G-oTB3CP5KhP9O_-WNChg-1; Sun, 25 Oct 2026 08:01:41 -0400 X-MC-Unique: _G-oTB3CP5KhP9O_-WNChg-1 X-Mimecast-MFC-AGG-ID: _G-oTB3CP5KhP9O_-WNChg_1792929700 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-c25501f4aa2so265830466b.1 for ; Sun, 25 Oct 2026 05:01:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792929700; x=1793534500; h=date:content-transfer-encoding:content-type:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type;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2002:a17:907:e8c:b0:c49:8bf8:a7a7 with SMTP id a640c23a62f3a-c498bf8a886mr46785366b.7.1792929699159; Sun, 25 Oct 2026 05:01:39 -0700 (PDT) X-Received: by 2002:a17:907:e8c:b0:c49:8bf8:a7a7 with SMTP id a640c23a62f3a-c498bf8a886mr46780666b.7.1792929698457; Sun, 25 Oct 2026 05:01:38 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [176.103.220.4]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c46bd4ea608sm194141066b.21.2026.10.25.05.01.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Oct 2026 05:01:37 -0700 (PDT) From: Stefano Brivio To: Anshu Kumari Subject: Re: [PATCH v4 2/2] dhcpv6: Inject custom options into DHCPv6 replies Message-ID: <20261025130136.6085c3e0@elisabeth> In-Reply-To: <20261006090454.1474409-3-anskuma@redhat.com> References: <20261006090454.1474409-1-anskuma@redhat.com> <20261006090454.1474409-3-anskuma@redhat.com> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.49; x86_64-pc-linux-gnu) MIME-Version: 1.0 Date: Sun, 25 Oct 2026 13:01:37 +0100 (CET) X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: HoyzS7IV2RMHIyZFZ4TmYAFUKKtX41u43KiX0GDqzuA_1792929700 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: NIPOUUWGTRLPU2CLKCJ6BT2QJXW3RJWA X-Message-ID-Hash: NIPOUUWGTRLPU2CLKCJ6BT2QJXW3RJWA X-MailFrom: sbrivio@redhat.com 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, 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: On Tue, 6 Oct 2026 14:34:53 +0530 Anshu Kumari wrote: > Append user-specified options from --dhcpv6-opt to DHCPv6 reply > messages. Options that exceed available buffer space are skipped > with a warning. > > Link: https://bugs.passt.top/show_bug.cgi?id=192 > Signed-off-by: Anshu Kumari > --- > v4: > - warn() instead of debug() when options don't fit in the reply. > - doc comment for dhcpv6_user_opts_fill() updated. > > v3: > - rename dhcpv6_custom_opts_fill() to dhcpv6_user_opts_fill(). > - Iterate directly over the pre-parsed binary dhcpv6_user_opts[] > array instead of re-parsing string values at reply time. > > v2: > - Updated dhcpv6_custom_opts_fill() to parse str at reply time > using dhcpv6_opt_parse() instead of copying cached val/len. > --- > dhcpv6.c | 36 ++++++++++++++++++++++++++++++++++++ > 1 file changed, 36 insertions(+) > > diff --git a/dhcpv6.c b/dhcpv6.c > index abc45813..a0545406 100644 > --- a/dhcpv6.c > +++ b/dhcpv6.c > @@ -879,6 +879,41 @@ static size_t dhcpv6_client_fqdn_fill(const struct iov_tail *data, > return offset + sizeof(struct opt_hdr) + opt_len; > } > > +/** > + * dhcpv6_user_opts_fill() - Append user-specified options to reply > + * @buf: Response message buffer > + * @offset: Current offset in buffer > + * > + * Return: offset after appended user options > + */ > +static size_t dhcpv6_user_opts_fill(char *buf, size_t offset) > +{ > + unsigned int i; > + > + for (i = 0; i < ARRAY_SIZE(dhcpv6_user_opts); i++) { > + int vlen = dhcpv6_user_opts[i].len; > + struct opt_hdr *hdr; > + > + if (!vlen) > + continue; > + > + if (offset + sizeof(struct opt_hdr) + vlen > OPT_MAX_SIZE) { > + warn("DHCPv6: option %u doesn't fit, skipping", i); I've seen Laurent's comment in: https://archives.passt.top/passt-dev/6fcca48c-a992-436f-a308-061ae0017d4f@redhat.com/ but the issue with a warn() call here is that the guest could try to flood logs that way. You could rate-limit it by passing the timestamp to here via dhcpv6(), it's just one caller to modify, it doesn't look that bad. > + continue; > + } > + > + hdr = (struct opt_hdr *)(buf + offset); > + hdr->t = htons(i); > + hdr->l = htons(vlen); > + offset += sizeof(struct opt_hdr); > + > + memcpy(buf + offset, dhcpv6_user_opts[i].val, vlen); > + offset += vlen; > + } > + > + return offset; > +} > + > /** > * dhcpv6() - Check if this is a DHCPv6 message, reply as needed > * @c: Execution context > @@ -1017,6 +1052,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_user_opts_fill((char *)&resp, n); > > resp.hdr.xid = mh->xid; > -- Stefano