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=hPEkM8vU; 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 4D0555A0265 for ; Wed, 01 Jul 2026 09:51:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782892281; 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=cAlioMBKc7f1dU1R1emNbfiuAw+6xBg8tDi6SLVRvQ8=; b=hPEkM8vU1b63okZre1grWu9egP5cvrLLtq27FfYuckhRKXgI3ujZi8+KpCQmifLS8/L7tj kJhzJcjdR2srO+O2rULU+2uLFj7ySIjpvhUlmUKd9wkTlyILkP/JxveNDw94tvWq0HvKEy V1KJWh4u4ULOe+NURK4vFFD13IHB7UY= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-363-JrGEX8EBM5WzMVSM5T1shA-1; Wed, 01 Jul 2026 03:51:20 -0400 X-MC-Unique: JrGEX8EBM5WzMVSM5T1shA-1 X-Mimecast-MFC-AGG-ID: JrGEX8EBM5WzMVSM5T1shA_1782892279 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4926596eebcso3259425e9.3 for ; Wed, 01 Jul 2026 00:51:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782892279; x=1783497079; h=date:content-transfer-encoding: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; bh=cAlioMBKc7f1dU1R1emNbfiuAw+6xBg8tDi6SLVRvQ8=; b=sduV+aw96UC+gV9FmidN1ruBVTz6OAYqFCu8fm0glsPKQUV68swWxuSRICcDrXJJOx zq8oco7pSDrho90PsZhDAZ//6SI8uga0S+5gW50dtzqLhJ3ktZYHdZhaPYm0wWJo3nHM 41xx5/eOMc1fS1deZ87W0iAhQ9qDZUD7BFXZH8op05OJjosVZ23FEPldC+YFC3TI3wJG A9IlNIRC2v1+sSxgvNwdynSeLL3d4p55JSYvIcZzgtRRCN3mxcMy1WWFQMmIf20jKolw EP7rqF1xukS19HdSm7+R7/tVRglEVx9LsmJpuEpUixW+imATGi2tlvZpwL7uTzStVUDW fI+w== X-Forwarded-Encrypted: i=1; AFNElJ8R5nRVu1IO2hkzsJ1+OTP9ijHZrzuuoosroZ0oL7sfGa8+8o2Ketazz9YsbBvl+nFQxoKTzUxAEjk=@passt.top X-Gm-Message-State: AOJu0Yyhgw9XC3Iai/Yug8sHFNoaOHfgfAhny2e8xi2vJvAmCcfC5Wes NDlEW6V8mKJtf5/Bdzx0/O7MWADnN5XwdRwZm8caadYrKTPJxaBSrwUNnfaGRjxSOlKOHjv5GAS BAzQ18DhH6Ln/3jimWN8eUhCQPoFHwnoiKzxGvU6DdRhalqRngXbyPA== X-Gm-Gg: AfdE7cmEJjejCROOuBysnn8wUwHiWXRDrWfSGr0M/IswyxpgJa0h0WKXAE6NIybXUOW kodVJhvbjmGEiJy6LWT3O6tO6JcqJUCrU95bYuttPp2i0ykdY8UfoBbitAR8xyTmXp9ye6rTGhn Q1IEIl+C3z7H7L0CTNMcKTCb9WDDULSJgvd4LLEuOZ4Uyzx0uwikz3o44dzrqGoMJPXBURcIJtH czD6F/7OZtNLYrUqpfAMl7O2FVYjMRJ04DlNR8E6jY7swDf3NurbKPoGZ1ez9r59dKvMIFvpwbp IHvZkeR8bILfQ3SDF6LrMNet1Vc2XEbK48NnTU0VDEwrswVEs83WU9IS2z8NzeGPrkEHK8mqD+0 n/JZ5zRS2hGohiy3cgpDL6FD12a/9q8v237hse6k= X-Received: by 2002:a05:600d:8494:10b0:493:a5d0:d1a1 with SMTP id 5b1f17b1804b1-493c2ba1f16mr5662855e9.31.1782892278568; Wed, 01 Jul 2026 00:51:18 -0700 (PDT) X-Received: by 2002:a05:600d:8494:10b0:493:a5d0:d1a1 with SMTP id 5b1f17b1804b1-493c2ba1f16mr5662375e9.31.1782892277942; Wed, 01 Jul 2026 00:51:17 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [176.103.220.4]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493be810c02sm61231195e9.11.2026.07.01.00.51.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2026 00:51:17 -0700 (PDT) From: Stefano Brivio To: Anshu Kumari Subject: Re: [PATCH v4 3/4] dhcp: Add --dhcp-opt with option table and value parser Message-ID: <20260701095115.4834f6fa@elisabeth> In-Reply-To: References: <20260617132243.1499556-1-anskuma@redhat.com> <20260617132243.1499556-4-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: Wed, 01 Jul 2026 09:51:16 +0200 (CEST) X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: lMdU_m8qS84_rsztUbnSHaxGFxZ6eb20s8eLmVOwIsw_1782892279 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: BD3KMI6IXGW5UA2X27TIGNBBZRVUS73U X-Message-ID-Hash: BD3KMI6IXGW5UA2X27TIGNBBZRVUS73U 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: David Gibson , passt-dev@passt.top, 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 Fri, 19 Jun 2026 12:59:10 +0530 Anshu Kumari wrote: > On Fri, Jun 19, 2026 at 9:24=E2=80=AFAM David Gibson > wrote: >=20 > > On Wed, Jun 17, 2026 at 06:52:37PM +0530, Anshu Kumari wrote: =20 > > > Introduce the --dhcp-opt flag that allows setting arbitrary DHCP > > > options from command-line in the form [--dhcp-opt CODE,VALUE]. > > > > > > Add a type lookup table mapping option codes to RFC 2132 value types > > > (IPv4, IPv4 list, integer, string) and dhcp_opt_parse() to convert > > > CLI strings to binary wire format. Parsed options are stored in > > > struct ctx and injected into DHCP replies. If the same option code > > > is given more than once, the last value wins. > > > > > > Link: https://bugs.passt.top/show_bug.cgi?id=3D192 > > > Signed-off-by: Anshu Kumari > > > --- > > > v4: > > > - Renamed custom_opts to dhcp_opts, 256 entries indexed by option > > > code, removed MAX_CUSTOM_DHCP_OPTS and count field. > > > - Changed str buffer from 256 to 255 bytes. > > > - Moved function to conf.c as static conf_dhcp_option(), renamed > > > from dhcp_add_option(). > > > - Made dhcp_opt_parse() non-static, declared in dhcp.h > > > - Dropped val/len from ctx struct; conf_dhcp_option() validates > > > with temp buffer, dhcp() parses str directly into opts[] at > > > reply time. =20 > > > > Hmm. So each option is parsed twice. What prevents you from parsing > > directly into the opts[] array at conf() time? >=20 > The first parse acts as a validation step to check that the user has > entered the > correct value format for the option. Without it, if the user passes > something > like *--dhcp-opt 3,notanip*, the error would surface only when the first > DHCP client connects, not at startup. >=20 > I think it's better to fail during startup if correct value format is not > entered in command-line rather than failing at later > stage during reply time. Sure, I would say we have to. But I think David was suggesting (that would be my suggestion as well) that you actually validate values right away, and store them directly into opts[], instead of having two steps and keeping a c->dhcp_opts[] array in parallel. The downside of a single parsing step, without duplicating values, is that you would need to render values back from opts[] to print them in conf_print(). But it should be relatively trivial. It might actually be less code than it is now. --=20 Stefan