public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Stefano Brivio <sbrivio@redhat.com>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: passt-dev@passt.top
Subject: Re: [PATCH 2/3] packet: Don't have struct pool specify its buffer
Date: Thu, 19 Dec 2024 10:00:11 +0100	[thread overview]
Message-ID: <20241219100011.5faed9fd@elisabeth> (raw)
In-Reply-To: <20241213120156.4123972-3-david@gibson.dropbear.id.au>

On Fri, 13 Dec 2024 23:01:55 +1100
David Gibson <david@gibson.dropbear.id.au> wrote:

> struct pool, which represents a batch of packets includes values giving
> the buffer in which all the packets lie - or for vhost_user a link to the
> vu_dev_region array in which the packets sit.  Originally that made sense
> because we stored each packet as an offset and length within that buffer.
> 
> However dd143e389 ("packet: replace struct desc by struct iovec") replaced
> the offset and length with a struct iovec which can directly reference a
> packet anywhere in memory.  This means we no longer need the buffer
> reference to interpret packets from the pool.  So there's really no need
> to check where the packet sits.  We can remove the buf reference and all
> checks associated with it.  As a bonus this removes the special case for
> vhost-user.
> 
> Similarly the old representation used a 16-bit length, so there were some
> checks that packets didn't exceed that.  That's also no longer necessary
> with the struct iovec which uses a size_t length.
> 
> I think under an unlikely set of circumstances it might have been possible
> to hit that 16-bit limit for a legitimate packet: other parts of the code
> place a limit of 65535 bytes on the L2 frame, however that doesn't include
> the length tag used by the qemu socket protocol.  That tag *is* included in
> the packet as stored in the pool, however, meaning we could get a 65539
> byte packet at this level.

As I mentioned in the call on Monday: sure, we need to fix this, but at
the same time I'm not quite convinced that it's a good idea to drop all
these sanity checks.

Even if they're not based on offsets anymore, I think it's still
valuable to ensure that the packets are not exactly _anywhere_ in
memory, but only where we expect them to be.

If it's doable, I would rather keep these checks, and change the ones
on the length to allow a maximum value of 65539 bytes. I mean, there's
a big difference between 65539 and, say, 4294967296.

By the way, I haven't checked what happens with MTUs slightly bigger
than 65520 bytes: virtio-net (at least with QEMU) doesn't budge if I
set more than 65520, but I didn't actually send big packets. I'll try
to have a look (also with muvm) unless you already checked.

-- 
Stefano


  reply	other threads:[~2024-12-19  9:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-13 12:01 [PATCH 0/3] Cleanups to packet pool handling and sizing David Gibson
2024-12-13 12:01 ` [PATCH 1/3] packet: Use flexible array member in struct pool David Gibson
2024-12-13 12:01 ` [PATCH 2/3] packet: Don't have struct pool specify its buffer David Gibson
2024-12-19  9:00   ` Stefano Brivio [this message]
2024-12-20  0:59     ` David Gibson
2024-12-20  9:51       ` Stefano Brivio
2024-12-21  6:59         ` David Gibson
2024-12-13 12:01 ` [PATCH 3/3] tap: Don't size pool_tap[46] for the maximum number of packets David Gibson
2024-12-19  9:00   ` Stefano Brivio
2024-12-20  1:13     ` David Gibson
2024-12-20  9:51       ` Stefano Brivio
2024-12-21  7:00         ` 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=20241219100011.5faed9fd@elisabeth \
    --to=sbrivio@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=passt-dev@passt.top \
    /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).