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=hfLWr1vq; 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 752275A0653 for ; Mon, 15 Dec 2025 23:43:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1765838634; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aC3lJN5hCGTR5orivCJ83Urso443973hqWpOG9bjR/Q=; b=hfLWr1vqFff/LlkhQNEA4T437lJts/z7FfXf8yarnxNUt957rZd9zbJ7IbmFIcIi+yvd8a O+eKZ3KpHz3ZsYpNq2vXLwB4y16YhgREjPBJDLY6eJr/+YUFI+VGMmCXQ1nFKnRzBt7FSS 59fRDHMgatv1n/2GUhJYGfW3RY9tH9c= Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-296-Vi4DjznuNMGZU84tYlZr1g-1; Mon, 15 Dec 2025 17:43:52 -0500 X-MC-Unique: Vi4DjznuNMGZU84tYlZr1g-1 X-Mimecast-MFC-AGG-ID: Vi4DjznuNMGZU84tYlZr1g_1765838631 Received: by mail-pl1-f199.google.com with SMTP id d9443c01a7336-29e6b269686so93157775ad.1 for ; Mon, 15 Dec 2025 14:43:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765838631; x=1766443431; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=aC3lJN5hCGTR5orivCJ83Urso443973hqWpOG9bjR/Q=; b=s7gpUuyDyVaMfTA7Il3vyulTT9JbElTaAGZELltXgqlCKceBZvpPw8rWvE6CU8ETMp QIricqZ/WLb9Qwj6r4v8sU2q8q0ERh1yY6mJAtSgJC9vuLFaSiaxgA8NVGksvoO7T7un PomFqqk50y850e1vWnfFwL47L4o793CfvCopSInnR2mkbXB4y9OZcGVS4PuNBi42iu2n glLE0/ZtSvfPAAaWVomfKTuuCp3DExAYQNeWJEBps5UUxflHNhbZE7qyte7E9000+l3H 4RpJv4/mHMKCcHh9z3tRvmmJ0YmjIIiaiPC67mWcCawk3TVvuLWayUxtAnhR9skmXIz0 UhiQ== X-Gm-Message-State: AOJu0YzD93vYniEl3YGYJXap61eRULtGpOfX7FYJ1PKKe5EMClhKYnG7 GrV16A1DmZkCAfOm4lcm8dJ9Sgt2YPy3xRC54zai0LGNYHUkhAZcep8eqPVabIX813ETLdm2aMy 8wbyY8etw1B0tfGfXIAhOz08pyK8iTw75pjU6kfRHV/6/lLRKj73saA3FyD+wKzQilI1DPT0rUx FwbGRBhMsPeHtU0dz3+/dIFIfs7e1cODTz0Ec= X-Gm-Gg: AY/fxX4fhketMzyU1vBuOyUCcnAAknHzmrI1lBd7OXdZcTGB2wABrOXxmPzwCe7hoaI cR5q1Hl4hrk2P/3iFknoznflSXwQ9+bMx7f238Sc6SM8rkzia5qEY83PohCBXtaqp3FJJgwgxHu 9LOrgX8SRRc8YDtiM4kutvR0yOetiYKKGLJxnGNKs/7S/l2xROs3jkIQkxwaNcer+pftDPvTKzB F0r9PUAN2ELdsPU2vP6r0PJZqrn6fazO4d+avlq4vjDxM8d77MeE/dlWRZeWSpwCJWcqakcrR8l VQgbcImHubxoWNlVF6aHXaNNK+W+atNbVeBuHdnwIeoH+C9EP7hGhviIzfEhXiF+H6iphHavWgX BBUtweXhFvOWRG2lENM1qD/66TzKbCUoAXHsYKQ3ImPeKa8xhl4VZBWTeEYow8I1Cn3BXheHork /s3dlT X-Received: by 2002:a05:7300:50e4:b0:2a4:3593:6452 with SMTP id 5a478bee46e88-2ac2f85e8a0mr8154525eec.2.1765838630848; Mon, 15 Dec 2025 14:43:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IHE4ZPtXk9X0+iUO3fMRABnHZtr9m4uDqOX+GvdO2JlTeT3V/EOM9dVcpohbwKMKqUuMUxN1w== X-Received: by 2002:a05:7300:50e4:b0:2a4:3593:6452 with SMTP id 5a478bee46e88-2ac2f85e8a0mr8154499eec.2.1765838629968; Mon, 15 Dec 2025 14:43:49 -0800 (PST) Received: from [192.168.2.15] (lnsm3-montreal02-142-116-222-198.internet.virginmobile.ca. [142.116.222.198]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-11f2e2ff624sm48902130c88.12.2025.12.15.14.43.48 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 15 Dec 2025 14:43:49 -0800 (PST) Message-ID: <3d55dca1-c321-46d7-8b01-2432db940b35@redhat.com> Date: Mon, 15 Dec 2025 17:43:47 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC 04/12] conf: Apply -n/--netmask to most recently added address To: passt-dev@passt.top References: <20251215015441.887736-1-jmaloy@redhat.com> <20251215015441.887736-5-jmaloy@redhat.com> From: Jon Maloy In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: QTCmidemm9Bdalex6mTCgascSr1xc_pE-i-W6L_JQRs_1765838631 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID-Hash: PQGFX2ZX2BSUUKMBMB2MXKYBS67INKSO X-Message-ID-Hash: PQGFX2ZX2BSUUKMBMB2MXKYBS67INKSO X-MailFrom: jmaloy@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 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 2025-12-15 04:54, David Gibson wrote: > On Sun, Dec 14, 2025 at 08:54:33PM -0500, Jon Maloy wrote: >> We allow for multiple -n/--netmask options, and update the handling so >> that each given prefix length is applied to the most recently added >> address instead of always to addrs[0]. >> >> This allows per-address prefix configuration, such as: >> >> -a 10.0.0.1 -n 24 -a 10.0.0.2 -n 16 >> >> If no address has been added yet, -n still applies to addrs[0] for >> backwards compatibility. > > Huh. I'd forgotten until looking at this series that we had the -n > option. We probably do need this change, but in general I think we'd > be better off deprecating -n, in favour of allowing a prefix len as > part of the -a option, e.g. > > -a 10.0.0.1/24 -a 10.0.0.2/16 > > That could be a smaller change preliminary to this series. Excellent idea. I really wasn't happy this semantics, either. I'll send a separate patch. /j > >> >> Signed-off-by: Jon Maloy >> --- >> conf.c | 9 +++++++-- >> 1 file changed, 7 insertions(+), 2 deletions(-) >> >> diff --git a/conf.c b/conf.c >> index e9f217b..0a4a28a 100644 >> --- a/conf.c >> +++ b/conf.c >> @@ -1528,6 +1528,7 @@ void conf(struct ctx *c, int argc, char **argv) >> size_t logsize = 0; >> char *runas = NULL; >> long fd_tap_opt; >> + int prefix, idx; >> int name, ret; >> uid_t uid; >> gid_t gid; >> @@ -1872,10 +1873,14 @@ void conf(struct ctx *c, int argc, char **argv) >> die("Invalid address: %s", optarg); >> break; >> case 'n': >> - c->ip4.addrs[0].prefix_len = conf_ip4_prefix(optarg); >> - if (c->ip4.addrs[0].prefix_len < 0) >> + prefix = conf_ip4_prefix(optarg); >> + >> + if (prefix < 0) >> die("Invalid netmask: %s", optarg); >> >> + /* Apply to most recent address, or addrs[0] if none yet */ >> + idx = c->ip4.addr_count ? c->ip4.addr_count - 1 : 0; >> + c->ip4.addrs[idx].prefix_len = prefix; >> break; >> case 'M': >> parse_mac(c->our_tap_mac, optarg); >> -- >> 2.51.1 >> >