qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: "Oleinik, Alexander" <alxndr@bu.edu>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: "pbonzini@redhat.com" <pbonzini@redhat.com>,
	"bsd@redhat.com" <bsd@redhat.com>,
	"stefanha@redhat.com" <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 1/2] net: assert that tx packets have nonzero size
Date: Thu, 7 Nov 2019 12:21:04 +0800	[thread overview]
Message-ID: <d549979a-3482-febc-4dc8-77dae431ad2c@redhat.com> (raw)
In-Reply-To: <20190722132344.30798-2-alxndr@bu.edu>


On 2019/7/22 下午9:24, Oleinik, Alexander wrote:
> Virtual devices should not try to send zero-sized packets. The caller
> should check the size prior to calling qemu_sendv_packet_async.
>
> Signed-off-by: Alexander Oleinik <alxndr@bu.edu>
> ---
> v2:
>    * Improve the comment to explain the rationale for adding the assert.
>   net/net.c | 9 +++++++++
>   1 file changed, 9 insertions(+)
>
> diff --git a/net/net.c b/net/net.c
> index 7d4098254f..4ad21df36f 100644
> --- a/net/net.c
> +++ b/net/net.c
> @@ -741,6 +741,15 @@ ssize_t qemu_sendv_packet_async(NetClientState *sender,
>       size_t size = iov_size(iov, iovcnt);
>       int ret;
>   
> +    /*
> +     * Since this function returns the size of the sent packets, and a return
> +     * value of zero indicates that the packet will be sent asynchronously,
> +     * there is currently no way to report that a 0-sized packet has been sent
> +     * successfully. Forbid it for now, and if someone needs this functionality
> +     * later, the API will require a change.
> +     */
> +    assert(size);


This probably will make the assertion triggerable from guest. Is this 
better to warn and return NET_BUFSIZE + 1 here?

Thanks


> +
>       if (size > NET_BUFSIZE) {
>           return size;
>       }



  reply	other threads:[~2019-11-07  4:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-22 13:24 [Qemu-devel] [PATCH v2 0/2] Avoid sending zero-size packets Oleinik, Alexander
2019-07-22 13:24 ` [Qemu-devel] [PATCH v2 1/2] net: assert that tx packets have nonzero size Oleinik, Alexander
2019-11-07  4:21   ` Jason Wang [this message]
2019-11-21 13:51     ` Alexander Bulekov
2019-07-22 13:24 ` [Qemu-devel] [PATCH v2 2/2] virtio-net: check that tx packet has positive size Oleinik, Alexander
2019-07-23 12:55 ` [Qemu-devel] [PATCH v2 0/2] Avoid sending zero-size packets Stefan Hajnoczi
2019-11-06 15:33 ` Stefan Hajnoczi

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=d549979a-3482-febc-4dc8-77dae431ad2c@redhat.com \
    --to=jasowang@redhat.com \
    --cc=alxndr@bu.edu \
    --cc=bsd@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@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).