From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=YGhR4TOg; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTPS id ED0F75A0272 for ; Thu, 10 Sep 2026 16:51:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789051880; 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=N7fA7aX4v4Br6wyr6B7cso71jkYsFtU/donS30tQlYs=; b=YGhR4TOg41dmaPIcU2pJmdo05XHGJ7Wo2ojZeqM7BLIzB2A9fZIzC9aq+FP3H/WvpcOq2i 92bRghoRkeZKscDratZVsNt2INxaF2vzRoZxomWFIoTx0Jvv5TrlamoBUD9JBXN9RPxplv lGCsD+s5vfp7YBOJvVk+N44pyiHqrOs= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-57-IZLwivYcMmyzAIvkc7t4CA-1; Thu, 10 Sep 2026 10:51:19 -0400 X-MC-Unique: IZLwivYcMmyzAIvkc7t4CA-1 X-Mimecast-MFC-AGG-ID: IZLwivYcMmyzAIvkc7t4CA_1789051878 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-482e2541c30so674893f8f.1 for ; Thu, 10 Sep 2026 07:51:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789051878; x=1789656678; 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; bh=N7fA7aX4v4Br6wyr6B7cso71jkYsFtU/donS30tQlYs=; b=kjEdc+4zPdVnWyf3uhN8jPzBjJUswEIFdH2u82pjDLg1fZ7nWKJODv7H+z8ge2My4u FpL4GSty4nHTeDaq0dp2QgeMjINlzJ5GrmZbjN4C6RYCkjTChdVYIUSX8LwYngh9OtYY 7phL/pmKj4e77vl338zTN0GlQ9K7xzaHi1pLDSpcn5ltnqCL4LeHwwYuBo58zynFkYrv mwR/q4MB449c5mV1c5iq+HDMF/DWYT7UoXZ4fhu33m0Cpwlkuh22Jiou3Z6smyZ39xeM Me7Ma7L7hiKedPrkq2Glc0fkc7H4eSeJojSQ3Nww3aw5lwXvLsYd5IIBBOCIyClrA48M 5sjA== X-Gm-Message-State: AFuF++kD0V6Hc5R2AzA5hGE11+rX9eMH9Hl3S+a09iZb7qFnngnY7YhM AJqBqmAa2wb+a48xUwPd5jq4iY5mnKzE05T9EIf8f6b/uH+ARPr01Cq8BMbrEyxruqzwFl/N7OJ 8pGVqjn4E9vF89b01v4JWcyOKY4zGdbjGBhSAFducBext7AjwLBVI+A== X-Gm-Gg: AYBFou0RSEeaw5ChcV5iSspjnP2ZtQ/fBFsUDKjX+P9n20nB+v8RarTTvzZ+1wyoaOg i37TfTvSSxaDHQkzbXpx67pc5H02/a+2AAm6AYNEZrTNhpoXGTgVKRK/N0l+anM058WToStW6hG bgucEKyrAilUWbDiSseQqyslTlRv3H7q+Zqb3dfG7OG3M93ImlggQUPymxL0Fi/uEQaGn7lYPHn q2BgGIOtZupdBeqCzkOKlyy2lc3HabzwxZjxQHgYn+mo4mtmtMC0PIqg4L2nT0iNUYAucDtYUf4 GGS3LQBGMJUlF7NsPpIgddWOGluYnYc/VTfE8uJZj5KCDk+Nykkoh8gsDLlOtJzY8M90ECs5MjL JZP2vWnVWktG1qBuAGu1Io9KZEEk6 X-Received: by 2002:a05:6000:2f8a:b0:486:e60f:a4e3 with SMTP id ffacd0b85a97d-486e60fae41mr3347484f8f.1.1789051877792; Thu, 10 Sep 2026 07:51:17 -0700 (PDT) X-Received: by 2002:a05:6000:2f8a:b0:486:e60f:a4e3 with SMTP id ffacd0b85a97d-486e60fae41mr3347426f8f.1.1789051877273; Thu, 10 Sep 2026 07:51:17 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [176.103.220.4]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-485883acd33sm52102067f8f.18.2026.09.10.07.51.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 07:51:16 -0700 (PDT) From: Stefano Brivio To: Anshu Kumari Subject: Re: [PATCH v3 2/2] dhcpv6: Inject custom options into DHCPv6 replies Message-ID: <20260910165113.0a9c0bbf@elisabeth> In-Reply-To: <20260824121352.244081-3-anskuma@redhat.com> References: <20260824121352.244081-1-anskuma@redhat.com> <20260824121352.244081-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: Thu, 10 Sep 2026 16:51:15 +0200 (CEST) X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: ynjO_o18jDD881y3DGzvUQeqYDCqKYKHAGlpMwXcIw0_1789051878 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: 565EKRBVN5SW4ZH6WLM75SZTFBQQFHTO X-Message-ID-Hash: 565EKRBVN5SW4ZH6WLM75SZTFBQQFHTO 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, david@gibson.dropbear.id.au, 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: On Mon, 24 Aug 2026 17:43:52 +0530 Anshu Kumari wrote: > Append user-specified options from --dhcpv6-opt to DHCPv6 reply > messages. Options are read from the pre-parsed static storage > populated by dhcpv6_set_opt() at startup, and skipped with a > debug message if they exceed the available space. > > Link: https://bugs.passt.top/show_bug.cgi?id=192 > Signed-off-by: Anshu Kumari > --- > 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 | 39 +++++++++++++++++++++++++++++++++++++++ > 1 file changed, 39 insertions(+) > > diff --git a/dhcpv6.c b/dhcpv6.c > index 3964dd9..041b589 100644 > --- a/dhcpv6.c > +++ b/dhcpv6.c > @@ -865,6 +865,43 @@ 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: updated offset after appending user options It's not really "updated": at a glance that gives the idea that we would update data accessed by a pointer. I would simply say "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) { This fits on one line. > + debug("DHCPv6: option %u doesn't fit," > + " skipping", i); This too. > + 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 > @@ -1003,6 +1040,8 @@ 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; > > tap_udp6_send(c, src, 547, saddr, 546, mh->xid, &resp, n); -- Stefano