From: "Michael S. Tsirkin" <mst@redhat.com>
To: Amit Shah <amit.shah@redhat.com>
Cc: alex.williamson@redhat.com, qemu-devel@nongnu.org,
Juan Quintela <quintela@redhat.com>
Subject: [Qemu-devel] Re: [PATCHv3] virtio-net: correct packet length math
Date: Fri, 25 Jun 2010 13:58:33 +0300 [thread overview]
Message-ID: <20100625105833.GA16444@redhat.com> (raw)
In-Reply-To: <20100625071703.GA1332@amit-laptop.redhat.com>
On Fri, Jun 25, 2010 at 12:47:03PM +0530, Amit Shah wrote:
> On (Thu) Jun 24 2010 [18:54:07], Michael S. Tsirkin wrote:
> > We were requesting too much when checking buffer
> > length: size already includes host header length.
> >
> > Further, we should not exit if we get a packet that
> > is too long, since this might not be under control
> > of the guest. Just drop the packet.
>
> control of the host?
Well, host too I guess. What I was trying to say, it might not
be the fault of the guest that it got a packet
that is too long.
> > @@ -579,19 +581,32 @@ static ssize_t virtio_net_receive(VLANClientState *nc, const uint8_t *buf, size_
> > mhdr = (struct virtio_net_hdr_mrg_rxbuf *)sg[0].iov_base;
> >
> > offset += receive_header(n, sg, elem.in_num,
> > - buf + offset, size - offset, hdr_len);
> > - total += hdr_len;
> > + buf + offset, size - offset, guest_hdr_len);
> > + total += guest_hdr_len;
> > }
> >
> > /* copy in packet. ugh */
> > len = iov_from_buf(sg, elem.in_num,
> > buf + offset, size - offset);
> > total += len;
> > + offset += len;
> > + /* If buffers can't be merged, at this point we
> > + * must have consumed the complete packet.
> > + * Otherwise, drop it. */
> > + if (!n->mergeable_rx_bufs && offset < size) {
> > +#if 0
> > + fprintf(stderr, "virtio-net truncated non-mergeable packet: "
> > +
> > + "i %zd mergeable %d offset %zd, size %zd, "
> > + "guest hdr len %zd, host hdr len %zd\n",
> > + i, n->mergeable_rx_bufs,
> > + offset, size, guest_hdr_len, host_hdr_len);
> > +#endif
> > + return size;
> > + }
>
> Before returning, won't you have to finish off the virtqueue operations
> -- fill, flush, kick, etc.?
>
> Amit
No, this would consume a buffer. We just want to drop the packet
without side-effects. But we do need to decrement the inuse counter.
I'll respin the patch.
--
MST
prev parent reply other threads:[~2010-06-25 17:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-24 15:54 [Qemu-devel] [PATCHv3] virtio-net: correct packet length math Michael S. Tsirkin
2010-06-25 7:17 ` [Qemu-devel] " Amit Shah
2010-06-25 10:58 ` Michael S. Tsirkin [this message]
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=20100625105833.GA16444@redhat.com \
--to=mst@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=amit.shah@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@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.
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 NNTP newsgroup(s).