All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Wu <wudxw@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] net: Only flush queue or call sent callback on successful delivery
Date: Fri, 28 Oct 2011 18:02:39 +0800	[thread overview]
Message-ID: <4EAA7DBF.8000306@linux.vnet.ibm.com> (raw)
In-Reply-To: <CAJSP0QUH42Y8d-ofvCG9=rq5JKae4cHX-juN61Lm6rwo5zGEcQ@mail.gmail.com>

On 10/28/2011 05:13 PM, Stefan Hajnoczi wrote:
> On Thu, Oct 27, 2011 at 10:02 AM, Mark Wu<wudxw@linux.vnet.ibm.com>  wrote:
>> Now queue flushing and sent callback could be invoked even on delivery
>> failure. We add a checking of receiver's return value to avoid this
>> case.
>>
>> Signed-off-by: Mark Wu<wudxw@linux.vnet.ibm.com>
>> ---
>>   net/queue.c |   12 +++++++-----
>>   1 files changed, 7 insertions(+), 5 deletions(-)
> What problem are you trying to fix?
>
>> @@ -251,7 +253,7 @@ void qemu_net_queue_flush(NetQueue *queue)
>>              break;
>>          }
>>
>> -        if (packet->sent_cb) {
>> +        if (ret>  0&&  packet->sent_cb) {
>>              packet->sent_cb(packet->sender, ret);
> This looks wrong.  ret is passed as an argument to the callback.  You
> are skipping the callback on error and not giving it a chance to see
> negative ret.
>
> Looking at virtio_net_tx_complete() this causes a virtqueue element leak.
Thanks for your review!
Yes, that's a problem. I thought only tap call queue send function with 
a callback (tap_send_completed) and confirmed that no memory leak in the 
case of tap. I agree that it will cause a
descriptor leak, but actually virtio_net_tx_complete doesn't check 
'ret'. It just pushes the elem to the virtqueue with 'async_tx.len' and 
flushes the tx queue. I think it assumes the callback is only called on 
success. Otherwise, it doesn't make sense for me. My point is that flush 
shouldn't happen on a deliver failure. Probably it will cause more 
failures. tap_send_completed assumes it's called on successfully deliver 
a packet too because it re-enables polling of tap fd.  That's why I add 
a checking of 'ret'.

I am not sure if the original code really needs a fix because it will 
not cause any visible problems.
> Stefan
>

  reply	other threads:[~2011-10-28 10:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-27  9:02 [Qemu-devel] [PATCH] net: Only flush queue or call sent callback on successful delivery Mark Wu
2011-10-28  9:13 ` Stefan Hajnoczi
2011-10-28 10:02   ` Mark Wu [this message]
2011-10-28 10:10     ` 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=4EAA7DBF.8000306@linux.vnet.ibm.com \
    --to=wudxw@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.