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=gHrz3pvS; 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 495FE5A0262 for ; Mon, 30 Mar 2026 23:57:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1774907828; 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=0kZaYbELDIozeWWyFxbdy7L2JAmyiM0qIYpUcXbhm3c=; b=gHrz3pvSqKUCLRQhgD0NNRjdpLEKjYvmdi7BfGdKmwQY2P+fTfxdvosnWBW62HrTSFOux6 pSKXDclgPwhKkZ+D9SyWdvP8pH5ZTeFZ2b4GIaqEJW9PZcFPTHgMbCwp4YghJBSB/jrPQV 59ilAK+N0prtZNexH5WcVj3lIt5pYew= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-307-i7yPPn8-O_2yM46bXEsYhA-1; Mon, 30 Mar 2026 17:57:05 -0400 X-MC-Unique: i7yPPn8-O_2yM46bXEsYhA-1 X-Mimecast-MFC-AGG-ID: i7yPPn8-O_2yM46bXEsYhA_1774907824 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-43cfc3bf7f6so1879301f8f.2 for ; Mon, 30 Mar 2026 14:57:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774907824; x=1775512624; 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=0kZaYbELDIozeWWyFxbdy7L2JAmyiM0qIYpUcXbhm3c=; b=LFJ90vhmMe7mU4H70LlUpHs0vPoH0P4FodTEzk6GZJD7S+uPvKTNwN293qGZrOsPGU Lz4O5h+4IRyVIuWyI84i87sQumX+oJiuAL2jqBzMaOVPSaLZCSklKDKmCrzOTC0OF6op Jx4ZguR7G08s19ZHALPxPkpzHcnPG07NCKH6tU1LvAcYOSS2iQ3H3Rxw1bUozoXBB8g4 ggBHTUvEYo+Ae0kNjJFDG5kJwa4L/I1dbeFMORQ8hQ49s5NiA1J/89WbpY+jHPos64ud uySos+3nap+JV5S9AlNprSZf3pe2cJZuQQ35hSY+kStpcAY1reNH0W/FFzlBrWruVevm o5kg== X-Forwarded-Encrypted: i=1; AJvYcCX1CY93NozOWRrS3Rd/3FF2nQqGvE+aEKyp1PlnUDLSwAREpl+D7uQymNreLd4r1MjAYYi58nJVKjE=@passt.top X-Gm-Message-State: AOJu0YxodVTiVz80yABqPJCq/c+AzOHGiMBEBwr2bvqizkIVKLumQTzp 2iOM/6XONPl2hzNS5Q061im58BqlQNLswtsqQ63VgQfmW9XWZOPSHeGrP9TLbSIdkuC5FRF/Lpd qrgDGt/7VURtdmF1Iize5An4MKYvYJ/bvPmvRZOWPFgYi6IJpWE8roQ== X-Gm-Gg: ATEYQzy31AMxeIbiWSZaeewbi/tOgkVN8K4QBD8v10BE/qwvZqu9MkNhapkM4bfqTZG 3RHunKXeRujeskJXBYjyFusPpWcEsupjtIXPZE77x6ITRHznH0ImUklqOZo05q1qA1+F4ZgB9Vs wEnOgBmWP9nxQ/2TCKJ1mQ01CO9Yxyiwm2NgdDdhA9SseuCUbISiNA+BFj9JthzpuXZNPnVuCzu LzzQJRuODr58qj29W2fyy2mbMn+sqiHS1VGi+tNpf3l2Kjtvde3DJDN7nBmi3U0TorEK4FqXNTV LoLO3FWamToXJ9kF+Muz2JEVGffSRaEQrgtdGdLfnnaJQZv4b8aKMzYjONH8OcoMqsASUnEOk3j HciKSksB/JHOXhrOIqVvePvrc9LL3+v77 X-Received: by 2002:a05:600c:a44:b0:487:2432:f7ed with SMTP id 5b1f17b1804b1-48727efbffbmr241447905e9.8.1774907824430; Mon, 30 Mar 2026 14:57:04 -0700 (PDT) X-Received: by 2002:a05:600c:a44:b0:487:2432:f7ed with SMTP id 5b1f17b1804b1-48727efbffbmr241447625e9.8.1774907823888; Mon, 30 Mar 2026 14:57:03 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [2a10:fc81:a806:d6a9::1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48722c6b105sm588585025e9.1.2026.03.30.14.57.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Mar 2026 14:57:03 -0700 (PDT) From: Stefano Brivio To: David Gibson Subject: Re: [PATCH v6 01/13] conf: use a single buffer for print formatting in conf_print() Message-ID: <20260330235701.58df2691@elisabeth> In-Reply-To: References: <20260322004333.365713-1-jmaloy@redhat.com> <20260322004333.365713-2-jmaloy@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: Mon, 30 Mar 2026 23:57:02 +0200 (CEST) X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: noXhNDCeIu05xzyxYUD1o8SJmeJduFJ1sX2i9Q8BLPQ_1774907824 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: HCXDJCJGB4QRCFXRKMSZ4QKDYT4ED73W X-Message-ID-Hash: HCXDJCJGB4QRCFXRKMSZ4QKDYT4ED73W 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: Jon Maloy , passt-dev@passt.top 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: [Dropping redundant email address for David in all the replies to this series, but it would be nice if you didn't add it in the first place] On Tue, 24 Mar 2026 10:26:15 +1100 David Gibson wrote: > On Sat, Mar 21, 2026 at 08:43:21PM -0400, Jon Maloy wrote: > > The function conf_print() uses three different buffers as target > > for address print formatting. This is unnecessary, as a single > > buffer of length INET6_ADDRSTRLEN has sufficient space for all > > address types, IPv4, IPv6 and MAC. There is no risk for conflicts, > > since all formatting is followed by an immediate info() printout. > > > > To make our life easier in the following commits, we do this > > simplification here. > > > > Signed-off-by: Jon Maloy > > --- > > conf.c | 35 ++++++++++++++++++----------------- > > 1 file changed, 18 insertions(+), 17 deletions(-) > > > > diff --git a/conf.c b/conf.c > > index dafac46..9bcd9de 100644 > > --- a/conf.c > > +++ b/conf.c > > @@ -1136,11 +1136,12 @@ enum passt_modes conf_mode(int argc, char *argv[]) > > */ > > static void conf_print(const struct ctx *c) > > { > > - char buf4[INET_ADDRSTRLEN], buf6[INET6_ADDRSTRLEN]; > > - char bufmac[ETH_ADDRSTRLEN], ifn[IFNAMSIZ]; > > + char buf[INET6_ADDRSTRLEN]; > > INANY_ADDRSTRLEN is already defined to be the max of INET_ADDRSTRLEN > and INET6_ADDRSTRLEN. > > > int i; > > > > if (c->ifi4 > 0 || c->ifi6 > 0) { > > + char ifn[IFNAMSIZ]; > > + > > info("Template interface: %s%s%s%s%s", > > c->ifi4 > 0 ? if_indextoname(c->ifi4, ifn) : "", > > c->ifi4 > 0 ? " (IPv4)" : "", > > @@ -1162,24 +1163,24 @@ static void conf_print(const struct ctx *c) > > !IN6_IS_ADDR_UNSPECIFIED(&c->ip6.addr_out)) { > > info("Outbound address: %s%s%s", > > IN4_IS_ADDR_UNSPECIFIED(&c->ip4.addr_out) ? "" : > > - inet_ntop(AF_INET, &c->ip4.addr_out, buf4, sizeof(buf4)), > > + inet_ntop(AF_INET, &c->ip4.addr_out, buf, sizeof(buf)), > > (!IN4_IS_ADDR_UNSPECIFIED(&c->ip4.addr_out) && > > !IN6_IS_ADDR_UNSPECIFIED(&c->ip6.addr_out)) ? ", " : "", > > IN6_IS_ADDR_UNSPECIFIED(&c->ip6.addr_out) ? "" : > > - inet_ntop(AF_INET6, &c->ip6.addr_out, buf6, sizeof(buf6))); > > + inet_ntop(AF_INET6, &c->ip6.addr_out, buf, sizeof(buf))); > > This one won't work: you're using the same buffer twice for the same > print. The buffer will be overwritten by the second inet_ntop() > before the results from the first one are printed. Note: this is now fixed in: [PATCH v2] conf: use a single buffer for print formatting in conf_print() https://archives.passt.top/passt-dev/20260327195551.271076-1-jmaloy@redhat.com -- Stefano