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=ioYVdPEV; dkim-atps=neutral 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 5B6C65A0262 for ; Fri, 15 May 2026 01:28:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778801319; 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=GRW3dDj8scJ1MN5WCsCFr45fTwqOigvI15pR+Ha5g8Y=; b=ioYVdPEViy/p6kYuMSsdusaBGJTBlEAJnYMgcMSV29IDt677YRkzzJv3Mm2pF0/Rd+/sE0 NTMUQDILansL3cQTgxPwqzuM5ueQHAdNZgj87HPVmcL1X+O2L92RU/n6ZX2Byl7eXuA/xG JT9vKEa1lBGvelo7OiOPYlUAmE9/1wU= 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-694-XTD24VsiNGab3GwBV0-bFA-1; Thu, 14 May 2026 19:28:36 -0400 X-MC-Unique: XTD24VsiNGab3GwBV0-bFA-1 X-Mimecast-MFC-AGG-ID: XTD24VsiNGab3GwBV0-bFA_1778801315 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-4411a36715dso6075427f8f.2 for ; Thu, 14 May 2026 16:28:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778801315; x=1779406115; 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=GRW3dDj8scJ1MN5WCsCFr45fTwqOigvI15pR+Ha5g8Y=; b=nHDP/RcdAeAnqo+15hr4/NQUN3VwEe4Y9z3nxEVsmRRFjSBa1c9KBOhGizQys7ZLL9 NoPMq1wvQcpb4MtBitQY+3LyP1fCrEIMVJ/VbEpGH7Aq/1HbGXaEa2DGqj8jMrBfP7eO FNta+Lw86D39N5B8Ek/Gk0/t8y1osni8QtQuBQXv06SJfBeBVx0cUdbi4nuCKkxstmZL BnPTIi06Qv/2HkG+uNzvQ+C5/DZinGytuh+xthVrK7lWLrdHVvvnMhn1fgWA2To3Wcdz rt8Jf1Co80Dx86RZ0IhuHQgPoDoSiKWsG4NS5oz3THSq0TES9OVaP1Gpj6EWofuoMJj2 5Jpg== X-Forwarded-Encrypted: i=1; AFNElJ/F4c9t3krkZhXi/2htLcI7Up94hmVnD42UeB2XBbnj7JKqhJ+snmsybTu+x4rHRDl1d5VYx6ULRVA=@passt.top X-Gm-Message-State: AOJu0YzVvqSN/7QlpSmbL3xry8RXvZlI9gMfoRc9Ysa5HxLGYY5Olz50 ZJk0h7youZJ9HhnBAYf8W1AYwzWV47n91SdyOA2V6Cl1kuLwbMqMkgd+hOUq3iEwEgH/A0ebxi7 s9IXCwcfWjGX1JLEJV8wqc5ovyaEfaBRCkkqNcDdFHwngoW6hM8vvbw== X-Gm-Gg: Acq92OG8N+eA/sHzEX/vYu/kFtYSabcMbWe8NyyHgCqNzGK6wfrRy/R0zZUO1CI8foW vJ+x2rx0BI1R8C+OeFcjAMAK5uRmPulTuXJeSp6RgaCoi/Iq+Sx4+xxe/t1I1lY47ZaJ5S93LNW K21zctjyX86SX4O++6+rhjoM1m3F+mDTzU0iai3t7jKnbFWSiGiVv07PvYUaZ1ycWwzIV3QuBI6 RKBggBnrUwgdYhRW8BcNjC8cSIZj2Hn0W72FRSGYdCGJvp9QjCrmG1IyaE6lK//S9Iq342eUe5O JRjq1qjnUVWkuIyVkOtcLW3IjJUPmGnExUwBoryeBEEWToMNa2xUIQ1CNaPplIfgQxCGxCmWdg0 G+aCKtE7gq1LEwUs5oy2pzRyAxkBoGMBWm9eT9shSq/p3IbZsag== X-Received: by 2002:a05:6000:2c10:b0:450:e5fd:e1a1 with SMTP id ffacd0b85a97d-45e5c35dcc2mr1505168f8f.3.1778801314655; Thu, 14 May 2026 16:28:34 -0700 (PDT) X-Received: by 2002:a05:6000:2c10:b0:450:e5fd:e1a1 with SMTP id ffacd0b85a97d-45e5c35dcc2mr1505140f8f.3.1778801314243; Thu, 14 May 2026 16:28:34 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [176.103.220.4]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45da0a17ec2sm9027400f8f.24.2026.05.14.16.28.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 May 2026 16:28:33 -0700 (PDT) From: Stefano Brivio To: David Gibson Subject: Re: [PATCH v7 02/13] passt, pasta: Introduce unified multi-address data structures Message-ID: <20260515012832.547eadb6@elisabeth> In-Reply-To: References: <20260413005319.3295910-1-jmaloy@redhat.com> <20260413005319.3295910-3-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: Fri, 15 May 2026 01:28:33 +0200 (CEST) X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: WH_61rLfYOqr_WhjNZuPQ6EZplB_A3LYAL25mXsSueg_1778801315 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: FPMQAMN6DWO5DKKXG7QWQ37XMYKNS3YZ X-Message-ID-Hash: FPMQAMN6DWO5DKKXG7QWQ37XMYKNS3YZ 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: On Thu, 14 May 2026 16:30:16 +1000 David Gibson wrote: > On Sun, Apr 12, 2026 at 08:53:08PM -0400, Jon Maloy wrote: > > > [...] > > > > +/** inany_prefix_len() - Convert prefix length to native format > > + * @addr: IPv4 or IPv6 address > > + * @prefix_len: prefix length (any format, auto-detected) > > If it's pertaining to an inany, it should always be IPv6 format. > Auto-detecting just masks bugs elsewhere. > > > + * > > + * Return: prefix length in native format (0-32 for IPv4, 0-128 for IPv6) > > + */ > > +static inline int inany_prefix_len(const union inany_addr *addr, > > + int prefix_len) > > +{ > > + if (inany_v4(addr) && prefix_len >= 96) > > Yikes. Even ignoring the fact I don't like this function at all Can you then please suggest / sketch another solution? We went back and forth on this topic quite a bit but we couldn't come up with anything more elegant so far. > this > isn't good. If we somehow get a IPv4-mapped inany with a prefix_len > that's < 96, something has already gone wrong. This, however, will > just fall back to the IPv6 case. So if prefix_len is 33..96 it will > return something entirely nonsensical, and if it's 0..32 it will > return something that looks ok, but ignores the fact that something is > already wrong. > > > + return prefix_len - 96; > > + > > + return prefix_len; > > +} > > + > > +/** inany_prefix_len6() - Convert prefix length to generic format > > + * @addr: IPv4 or IPv6 address > > + * @prefix_len: prefix length (any format, auto-detected) > > + * > > + * Return: prefix length in generic format (96-128 for IPv4, 0-128 for IPv6) > > + */ > > +static inline int inany_prefix_len6(const union inany_addr *addr, > > + int prefix_len) > > This function should not be necessary. If the prefix_len is attached > to an inany, it should already be in IPv6 format. > > > +{ > > + if (inany_v4(addr) && prefix_len && prefix_len <= 32) > > + return prefix_len + 96; > > Similar comments here. Also a 0.0.0.0/0 is a valid prefix which > should be translated to ::ffff:0:0/96, not to ::ffff:0:0/0 as this > function will. > > > [...] -- Stefano