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=NH+3kXjg; 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 4FC1C5A0262 for ; Wed, 08 Apr 2026 01:16:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775603779; 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=JZufloy15bLfYStFsCIjKj4CcfamH3nG4BHlWSCzgzk=; b=NH+3kXjgUarXRwR0nMcLVcK0LgOp7Ws+1UC5O4NQdVdrUFmnqXIQ2oRNdqgoODJVowcmpP Ld1OSMWHxhJ7nDMucLIBODiQ25VlyzkUcENSintw05WvjjGZX0L2C2MENO3FK24gpzuT/p NdSrQ/gen/MInp/NQolqfwBzhRNSfZI= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-330-F_MXdUhFOQa3G_WZIwNLlw-1; Tue, 07 Apr 2026 19:16:17 -0400 X-MC-Unique: F_MXdUhFOQa3G_WZIwNLlw-1 X-Mimecast-MFC-AGG-ID: F_MXdUhFOQa3G_WZIwNLlw_1775603777 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-488b966e9dbso12295625e9.3 for ; Tue, 07 Apr 2026 16:16:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775603776; x=1776208576; 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=JZufloy15bLfYStFsCIjKj4CcfamH3nG4BHlWSCzgzk=; b=cuVnj9CdKOOzXZAes5Onwj/SjAIvZrxYyMQ3OI3ejxEPGBmABmSpFTHmgHbWgUvYUI qWJiNLnumFmgdfIwLH1etNMewUhOL8pZ+mByO1MTAD8SblrADquFXr8zi+ATwkQEeeB9 nv44qaJivu+t2AVzw3pZOvFKdFKUCfUIEMm8t7wJ/qoTBgcEu5ZJI1VjjzzqZ3t28mvZ AgdhhHZuEsbdPRHoP7dRw18UnqIe+cBkZXi9al4cDumFjUM/ldCV6vIhZWsiG2guEk/v J6Bx69dESYRP4j27rHN0cK+EKLvebpUU0yqyOgTGSlZAKuGSMvSOvUNvdxkoF1O/MYg7 i9HQ== X-Gm-Message-State: AOJu0YwFdG85W89HmX+nWIhW08cSEs7/DQ67BLJHwRMtztOXVOAWGSUq 976NFC+pMhH7yHytlVg1p6Ga2wSpjrPyhOs7Re2W72d8hrFr9fABj5C6zo7rgYwiZQaoHK2ke4w P4Dp56UX3s2TMSvAGCSzOoFJQL2AraSO1q2x6Uu+ioD74FZOHeguGVBY9QxLGbQ== X-Gm-Gg: AeBDiesXJDb/XovdQLxdiE3XBMF5i5263PVXbPMZAW+mPMAGZEbUCqEUef2ouzvN4Ii jff9PgOsSrwyGPTvP1ftFEi/QeAtJf4ORZNK1cFzI/+1L1lVjJ9812E/z1yBUXOtsF1rk7KLijk ZvVmSom0Yf6iNGMCeMLOsBcWHrv8YhcwjiOimFOAiIeWP6OlHOrKOgzLDbtndbyvB+3EImxjzti m8JEUvrohOl+tBhtw6Il1GkCd1RQ+JLwVVuW27yBwmF5P+YNwSn3QcceurWfPcC/gBriIHNj40u APdzf+QHNkgoqMunSMRFwFvefBF/RV4Bc3WDdB6YWai2oYqyyODnrrkKPHwgtCk2TVsid3OsVuW KLQ3B3obkeREB7vd6AEnZXREUsEAENTuX X-Received: by 2002:a05:600c:5292:b0:485:2ce2:4c87 with SMTP id 5b1f17b1804b1-488996cd77cmr281331645e9.4.1775603776207; Tue, 07 Apr 2026 16:16:16 -0700 (PDT) X-Received: by 2002:a05:600c:5292:b0:485:2ce2:4c87 with SMTP id 5b1f17b1804b1-488996cd77cmr281331465e9.4.1775603775743; Tue, 07 Apr 2026 16:16:15 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [2a10:fc81:a806:d6a9::1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4887e83682fsm616042155e9.7.2026.04.07.16.14.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2026 16:14:57 -0700 (PDT) From: Stefano Brivio To: David Gibson Subject: Re: [PATCH 02/18] conf: Simplify handling of default forwarding mode Message-ID: <20260408011435.3b425877@elisabeth> In-Reply-To: <20260407031630.2457081-3-david@gibson.dropbear.id.au> References: <20260407031630.2457081-1-david@gibson.dropbear.id.au> <20260407031630.2457081-3-david@gibson.dropbear.id.au> 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, 08 Apr 2026 01:14:36 +0200 (CEST) X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: o064Q-jyNlvpC9IA7XtQ8WxWRKPO4V5NBeKgDRQY2IM_1775603777 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: SVEKQXXFL4UMPMIO6ZJZY5PAEKHIY5TL X-Message-ID-Hash: SVEKQXXFL4UMPMIO6ZJZY5PAEKHIY5TL 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 Tue, 7 Apr 2026 13:16:14 +1000 David Gibson wrote: > For passt, the default forwarding mode is "none", which falls out naturally > from the other handling: if we don't get any options, we get empty > forwarding tables, which corresponds to "none" behaviour. However, for > pasta the default is "auto". This is handled a bit oddly: in conf_ports() > we set the mode variable, but don't set up the rules we need for "auto" > mode. Instead we want until nearly the end of conf() and if the mode is > FWD_MODE_AUTO or unset, we make conf_ports_range_except() calls to set up > the "auto" rules. > > Simplify this a bit, by creating the rules within conf_ports() itself when > we parse -[tuTU] auto. For the case of no forwarding options we call > into conf_ports() itself with synthetic arguments. As well as making the > code a little shorter, this makes it more obvious that giving no arguments > really is equivalent to -[tuTU] auto. > > Signed-off-by: David Gibson > --- > conf.c | 54 ++++++++++++++++++++++-------------------------------- > 1 file changed, 22 insertions(+), 32 deletions(-) > > diff --git a/conf.c b/conf.c > index c515480b..7d718f91 100644 > --- a/conf.c > +++ b/conf.c > @@ -345,6 +345,10 @@ static void conf_ports(const struct ctx *c, char optname, const char *optarg, > die("'auto' port forwarding is only allowed for pasta"); > > *mode = FWD_MODE_AUTO; > + > + conf_ports_range_except(c, optname, optarg, fwd, NULL, NULL, > + 1, NUM_PORTS - 1, NULL, 1, FWD_SCAN); > + > return; > } Pre-existing, it goes away in 12/18 of the current series, and it's harmless unless somebody should ever touch 'enum fwd_mode' in a rather unlikely way: the code here checks: if (*mode) ... relying on the fact that FWD_MODE_UNSPEC is 0 (and we also have a _NONE value, which makes it somewhat risky) instead of directly checking if (*mode == FWD_MODE_UNSPEC). I thought I would note it here in the unlikely case we'd need to back to mode constants for whatever reason. -- Stefano