From: David Gibson <david@gibson.dropbear.id.au>
To: Stefano Brivio <sbrivio@redhat.com>
Cc: passt-dev@passt.top
Subject: Re: [PATCH 3/9] conf: Detect vhost-user mode earlier
Date: Wed, 12 Mar 2025 11:48:56 +1100 [thread overview]
Message-ID: <Z9DZ-Cq4VbJY63R4@zatzit> (raw)
In-Reply-To: <20250311234503.5bb0d132@elisabeth>
[-- Attachment #1: Type: text/plain, Size: 3746 bytes --]
On Tue, Mar 11, 2025 at 11:45:03PM +0100, Stefano Brivio wrote:
> On Tue, 11 Mar 2025 17:03:12 +1100
> David Gibson <david@gibson.dropbear.id.au> 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 <david@gibson.dropbear.id.au>
> > ---
> > 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?).
It's more or less intended. To me it seemed simpler to treat
"vhost-user mode" as co-equal with "/dev/net/tun mode" (pasta) or
"qemu -net stream mode" (passt), rather than having vu be sort of a
sub-mode of passt. It's true that vu mode has slightly more in common
with passt mode than pasta at the moment, but I don't see that as
really inherent.
I also saw this as a precursor to a "--mode whatever" option which
would override the mode regardless of argv[0], in case there are
circumstances where manipulating argv[0] is inconvenient.
But if you'd really prefer I can reinstate the check.
> > - 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).
I was unsure about this, because I wasn't certain if --vhost-user was
passed when we were invoked just to probe capabilities.
> It can also be done in another patch I would say, if you don't want to
> re-spin this.
>
--
David Gibson (he or they) | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you, not the other way
| around.
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2025-03-12 0:57 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-11 6:03 [PATCH 0/9] Improve handling of MTU limits David Gibson
2025-03-11 6:03 ` [PATCH 1/9] conf: Use the same optstring for passt and pasta modes David Gibson
2025-03-11 6:03 ` [PATCH 2/9] conf: Move mode detection into helper function David Gibson
2025-03-11 6:03 ` [PATCH 3/9] conf: Detect vhost-user mode earlier David Gibson
2025-03-11 22:45 ` Stefano Brivio
2025-03-12 0:48 ` David Gibson [this message]
2025-03-11 6:03 ` [PATCH 4/9] packet: Give explicit name to maximum packet size David Gibson
2025-03-11 6:03 ` [PATCH 5/9] packet: Remove redundant TAP_BUF_BYTES define David Gibson
2025-03-11 6:03 ` [PATCH 6/9] tap: Use explicit defines for maximum length of L2 frame David Gibson
2025-03-11 22:45 ` Stefano Brivio
2025-03-12 0:56 ` David Gibson
2025-03-11 6:03 ` [PATCH 7/9] Simplify sizing of pkt_buf David Gibson
2025-03-11 6:03 ` [PATCH 8/9] pcap: Correctly set snaplen based on tap backend type David Gibson
2025-03-11 6:03 ` [PATCH 9/9] conf: Limit maximum MTU based on backend frame size David Gibson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z9DZ-Cq4VbJY63R4@zatzit \
--to=david@gibson.dropbear.id.au \
--cc=passt-dev@passt.top \
--cc=sbrivio@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).