From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=none 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=KyH11o9k; 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 946D05A026F for ; Tue, 11 Mar 2025 23:46:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741733185; 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=06BXV9AwiKHbTMqqNxwVm49TyrEpC0l/DBr/1jtk2+w=; b=KyH11o9k11s5hxiXH6GbzK9c4Ewa0WF8nfBbxxWleoFobcxTVwQKOOOfy3+Ojcev8unl1+ jDd8MI/nGeAHM3lJRadUh1HWP99aN5yfI/Takmt4GZNSrzXUlnJu5cZpRY0ih0VYNdTJCI Vd76BiTzBHpjwaLcvt089tZOWuHkYak= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-662-b20Pab3FOdS18vN3tPqinQ-1; Tue, 11 Mar 2025 18:45:09 -0400 X-MC-Unique: b20Pab3FOdS18vN3tPqinQ-1 X-Mimecast-MFC-AGG-ID: b20Pab3FOdS18vN3tPqinQ_1741733108 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-43d007b2c79so15079385e9.2 for ; Tue, 11 Mar 2025 15:45:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741733107; x=1742337907; 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=06BXV9AwiKHbTMqqNxwVm49TyrEpC0l/DBr/1jtk2+w=; b=OF+zNxNvpDINliKejHlH1cjbnsRiv13TnL8+Q0r7WwBZ1MqcLmhN/r4gUVRGzN7+Ns tZ4AxniHX7dEaZnMTDHEyAdpogThnJhWqgbYlodZosc0qsHNCehk90P7ShL0AFd587p9 E3Vi710G8r65kjVQqwgVDUsIiZmupj35biYjwKtog9ydyKeYtCSy0eiI4vbSnHyKii+z nq+mjIgpfPl27OLVpZQM54cvSoLgZT9pLnLQX5Zi1ZfDh46a6Uu5Zmj8H50Osyra2aG+ T7GVYUboQi5PPK4X2dOfK8H0DlrG3/fa6VvosFPHoY52SH8iOPnU+8YMzSpLpLw8TqA2 IsEw== X-Gm-Message-State: AOJu0Yx56+zdZj9tbnu7662gM22G/fbGSFTevrN4a2df6I75RKJ2tK0m /6WFypj1Q+3KdxJPbZBf9jJMM//JauSCNntWJlTIIdbEBcJ+3/3qOoWzKCYrPcFdymzMhS8sHop 9jeucqFLYpM2oQU4IR4ABiUsfMY9ulkLpW/3fdz5oDmE8HDi2d7Kcyy51kw== X-Gm-Gg: ASbGnctPmx4R3w/9qzmSGrD8e/kEzb+rBL7P2p/iX3ixSx1V82294VbWj8skBnE2xhG dRWun19J7pLtsbb7ukXeTyZq64+Ui78VhgFtnHUY3eI+ft6lrwi9LspvBDAinXMa6UDwwPqDdD4 OgCGXAvCuRUWNak7NkqoxreuA16/YB6FVjZeK1HMofbaaABjz72Mb7hH6IehIyPoM8C084tRaWQ jMFbCW9SEUDQ6IhlPvs634RINewfnibaOhMCu5BOVA/hyZf+/5q4ysmrXdfjirt0Owj8HBLDUj5 S3CG28StWmUPbO1+jM7v6heQVJOvztQbasQwYuR2V2DY X-Received: by 2002:a05:600c:3143:b0:43c:ec0a:ddfd with SMTP id 5b1f17b1804b1-43d01bd2182mr63057165e9.6.1741733107628; Tue, 11 Mar 2025 15:45:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHn8LTrqJW7O+Rte7GGfY4dpvCK5QfKacHosgmAMgbFnsYb6r5W1KAypqd1aFiAzZbmnwx1MA== X-Received: by 2002:a05:600c:3143:b0:43c:ec0a:ddfd with SMTP id 5b1f17b1804b1-43d01bd2182mr63057045e9.6.1741733107220; Tue, 11 Mar 2025 15:45:07 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [176.103.220.4]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43d0a7a3b53sm2773825e9.39.2025.03.11.15.45.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Mar 2025 15:45:06 -0700 (PDT) Date: Tue, 11 Mar 2025 23:45:03 +0100 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH 3/9] conf: Detect vhost-user mode earlier Message-ID: <20250311234503.5bb0d132@elisabeth> In-Reply-To: <20250311060318.1502861-4-david@gibson.dropbear.id.au> References: <20250311060318.1502861-1-david@gibson.dropbear.id.au> <20250311060318.1502861-4-david@gibson.dropbear.id.au> 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-MFC-PROC-ID: gRClXeRrbIK_bY_EiUO55B4Bia5OKm64ESgcwJwGPSs_1741733108 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: KCCLDJLXEID6H63SA4K6SMKBMIKEWEG6 X-Message-ID-Hash: KCCLDJLXEID6H63SA4K6SMKBMIKEWEG6 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, 11 Mar 2025 17:03:12 +1100 David Gibson wrote: > We detect our operating mode in conf_mode(), unless we're using vhost-user > mode, in which case we change it later when we parse the --vhost-user > option. That means we need to delay parsing the --repair-path option (for > vhost-user only) until still later. > > However, there are many other places in the main option parsing loop which > also rely on mode. We get away with those, because they happen to be able > to treat passt and vhost-user modes identically. This is potentially > confusing, though. So, move setting of MODE_VU into conf_mode() so > c->mode always has its final value from that point onwards. > > To match, we move the parsing of --repair-path back into the main option > parsing loop. > > Signed-off-by: David Gibson > --- > conf.c | 43 ++++++++++++++++++++++++++----------------- > 1 file changed, 26 insertions(+), 17 deletions(-) > > diff --git a/conf.c b/conf.c > index 2022ea1d..b58e2a6e 100644 > --- a/conf.c > +++ b/conf.c > @@ -998,10 +998,23 @@ pasta_opts: > * > * Return: mode to operate in, PASTA or PASST > */ > -/* cppcheck-suppress constParameter */ > enum passt_modes conf_mode(int argc, char *argv[]) > { > + int vhost_user = 0; > + const struct option optvu[] = { > + {"vhost-user", no_argument, &vhost_user, 1 }, > + { 0 }, > + }; > char argv0[PATH_MAX], *basearg0; > + int name; > + > + optind = 0; > + do { > + name = getopt_long(argc, argv, "-:", optvu, NULL); > + } while (name != -1); > + > + if (vhost_user) > + return MODE_VU; > > if (argc < 1) > die("Cannot determine argv[0]"); > @@ -1604,9 +1617,8 @@ void conf(struct ctx *c, int argc, char **argv) > > die("Invalid host nameserver address: %s", optarg); > case 25: > - if (c->mode == MODE_PASTA) > - die("--vhost-user is for passt mode only"); This check should now be moved to conf_mode() instead of being dropped, otherwise you can do: $ ./pasta -f --vhost-user and at this point, the mode is MODE_VU, so it's all fine, but I don't think it's intended (...or is it?). > - c->mode = MODE_VU; > + /* Already handled in conf_mode() */ > + ASSERT(c->mode == MODE_VU); > break; > case 26: > vu_print_capabilities(); Pre-existing, but now we can fix this: case 26 (--print-capabilities) should only be accepted if (c->mode == MODE_VU). It can also be done in another patch I would say, if you don't want to re-spin this. -- Stefano