From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTP id 2DF195A004E for ; Thu, 25 Jul 2024 13:27:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721906834; 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=do7dKoDHBGkziBCd5kintXzySFyLZ+Xnbphh0UBjflU=; b=iHdHwq0tegPBufAVyulJWX89ACGu+yHYm5caUG0FwyIGrLYQl9xrV/waLhK3EY5/NO/abN 2PXjTtDk4U5SytdTQRPpk9YxMmS2SZNNcpLTi7DPa30NJRZOL4w7f7cueH8QwYGk33l9yL v2/d9UrpmIddYDYechK9ysPFb8iBPOE= Received: from mail-ua1-f70.google.com (mail-ua1-f70.google.com [209.85.222.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-543-BI8V2rkxPoSyigfKg2CIcA-1; Thu, 25 Jul 2024 07:27:12 -0400 X-MC-Unique: BI8V2rkxPoSyigfKg2CIcA-1 Received: by mail-ua1-f70.google.com with SMTP id a1e0cc1a2514c-820f047c4feso126509241.3 for ; Thu, 25 Jul 2024 04:27:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721906831; x=1722511631; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=do7dKoDHBGkziBCd5kintXzySFyLZ+Xnbphh0UBjflU=; b=lGBLxFuxiuAab/oiaWsRWKOSu61OmbLENEs9uApAvxAuTK2mmx6I2jLZNvBAW53GIN epBFbHtViKcLX3pSnz47am0bImv/kTK8NxiQkGL3+HPrfjQXt98oRCB5Wokl1ZMumB31 fNNQjclPkKqs0Wrh6U04DVHZE9GunFK+uxFz2mcAcQimS3KfsvCLiOI5xg0qqFek6vYE Ts82Sg5O7XbQpONDHUR3BY1NXd7KiGrjQJrkVI7YpZWQzj89Rx31Y56hOhqBgAu6wWVV rLxyZtqGgm8o4IZa+RErf/bFTAFR5NXQvUtdS8JC2uelL1Dh6bCj7/MzE27G/W8P+QHO Mnhw== X-Gm-Message-State: AOJu0YxKiLBgmryD1s5cjTqQFbzg6di4x1QiFSPhjzSS4YIThSvgu2Xy +Ykgl7MLBiTzAKzaRZrgjLEJrQMzK22YMFyfy577Z5fk3Z9MCdpgy+9SiBnNvYbstyXIcybmuIZ eoHlFWLuaT+wIo0MAPBDqpHC7ryH3NN0bfjSdYxFyjwHdF3E/5285l1E+9BbN X-Received: by 2002:a05:6102:3e25:b0:492:a5a9:a74 with SMTP id ada2fe7eead31-493d64b6257mr3344889137.22.1721906831447; Thu, 25 Jul 2024 04:27:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFC+KGSolzgbYBHCz7sAzdEG3Rjq2yBjZVG7ivCUgGqbIyE6iHm3DLTuWafRP7Gy7AofJxrWQ== X-Received: by 2002:a05:6102:3e25:b0:492:a5a9:a74 with SMTP id ada2fe7eead31-493d64b6257mr3344867137.22.1721906830872; Thu, 25 Jul 2024 04:27:10 -0700 (PDT) Received: from maya.cloud.tilaa.com (maya.cloud.tilaa.com. [164.138.29.33]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a1d745d5aesm69559585a.126.2024.07.25.04.27.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jul 2024 04:27:10 -0700 (PDT) Date: Thu, 25 Jul 2024 13:26:35 +0200 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH 11/11] conf: Accept addresses enclosed by square brackets in port forwarding specifiers Message-ID: <20240725132628.226f76c5@elisabeth> In-Reply-To: References: <20240724215021.3366863-1-sbrivio@redhat.com> <20240724215021.3366863-12-sbrivio@redhat.com> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: FGIUIGX5I4ZNW3LJKYIYUKNGSUUWRHXZ X-Message-ID-Hash: FGIUIGX5I4ZNW3LJKYIYUKNGSUUWRHXZ 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 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, 25 Jul 2024 14:39:49 +1000 David Gibson wrote: > On Wed, Jul 24, 2024 at 11:50:17PM +0200, Stefano Brivio wrote: > > Even though we don't use : as delimiter for the port, making square > > brackets unneeded, RFC 3986, section 3.2.2, mandates them for IPv6 > > literals. We want IPv6 addresses there, but some users might still > > specify them out of habit. > > > > Same for IPv4 addresses: RFC 3986 doesn't specify square brackets for > > IPv4 literals, but I had reports of users actually trying to use them > > (they're accepted by many tools). > > > > Allow square brackets for both IPv4 and IPv6 addresses, correct or > > not, they're harmless anyway. > > > > Signed-off-by: Stefano Brivio > > Reviewed-by: David Gibson > > > --- > > conf.c | 24 +++++++++++++++++------- > > 1 file changed, 17 insertions(+), 7 deletions(-) > > > > diff --git a/conf.c b/conf.c > > index 3cf9ed8..338742e 100644 > > --- a/conf.c > > +++ b/conf.c > > @@ -209,14 +209,24 @@ static void conf_ports(const struct ctx *c, char optname, const char *optarg, > > > > } > > > > - if (ifname == buf + 1) /* Interface without address */ > > + if (ifname == buf + 1) { /* Interface without address */ > > addr = NULL; > > - else if (inet_pton(AF_INET, buf, addr)) > > - af = AF_INET; > > - else if (inet_pton(AF_INET6, buf, addr)) > > - af = AF_INET6; > > - else > > - goto bad; > > + } else { > > + p = buf; > > + > > + /* Allow square brackets for IPv4 too for convenience */ > > + if (*p == '[' && p[strlen(p) - 1] == ']') { > > + p[strlen(p) - 1] = 0; > > Nit: I think = '\0' would make the intention here clearer. Right, fixed on merge. -- Stefano