qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
	qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v5 08/11] nbd/client: refactor nbd_receive_starttls
Date: Fri, 20 Oct 2017 14:33:39 -0500	[thread overview]
Message-ID: <bab67a31-3f07-1d77-153a-6b78fcbb9d24@redhat.com> (raw)
In-Reply-To: <7573697c-4eb8-2c98-82c3-53a0ab884c65@virtuozzo.com>

[-- Attachment #1: Type: text/plain, Size: 2128 bytes --]

On 10/20/2017 02:26 PM, Vladimir Sementsov-Ogievskiy wrote:
> 20.10.2017 01:26, Eric Blake wrote:
>> From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>>
>> Split out nbd_request_simple_option to be reused for structured reply
>> option.
>>
>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>> Signed-off-by: Eric Blake <eblake@redhat.com>
>>
>> ---
>> v5: only check length for ACK responses
>> v4: reduce redundant traces, typo fix in commit message
>> ---

>> +/* nbd_request_simple_option: Send an option request, and parse the
>> reply
>> + * return 1 for successful negotiation,
>> + *        0 if operation is unsupported,
>> + *        -1 with errp set for any other error
>> + */
>> +static int nbd_request_simple_option(QIOChannel *ioc, int opt, Error
>> **errp)
>> +{
>> +    nbd_opt_reply reply;
>> +    int error;
>> +
>> +    if (nbd_send_option_request(ioc, opt, 0, NULL, errp) < 0) {
>> +        return -1;
>> +    }
>> +
>> +    if (nbd_receive_option_reply(ioc, opt, &reply, errp) < 0) {
>> +        return -1;
>> +    }
>> +    error = nbd_handle_reply_err(ioc, &reply, errp);
>> +    if (error <= 0) {
>> +        return error;
>> +    }
>> +
>> +    if (reply.type != NBD_REP_ACK) {
>> +        error_setg(errp, "Server rejected request for option %d (%s) "
> 
> Looks like now it is not rejected (nbd_handle_reply_err return >0 only
> for successful replies), but it should be
> Server replied ... with unexpected reply ...

Hmm.  For NBD_OPT_STARTTLS, NBD_REP_ERR_POLICY is an example of an
expected (error) reply.  Then again, we can't reach here on that reply,
because it would have already been handled in nbd_handle_reply_error().
Okay, I can see where you are coming from - since we already treated all
NBD_REP_ERR_* as rejection messages, anything else that the server sends
is unexpected if it is not ACK.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

  reply	other threads:[~2017-10-20 19:33 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-19 22:26 [Qemu-devel] [PATCH v5 00/11] nbd minimal structured read Eric Blake
2017-10-19 22:26 ` [Qemu-devel] [PATCH v5 01/11] nbd: Include error names in trace messages Eric Blake
2017-10-19 22:26 ` [Qemu-devel] [PATCH v5 02/11] nbd: Move nbd_errno_to_system_errno() to public header Eric Blake
2017-10-19 22:26 ` [Qemu-devel] [PATCH v5 03/11] nbd: Expose constants and structs for structured read Eric Blake
2017-10-20  8:00   ` Vladimir Sementsov-Ogievskiy
2017-10-19 22:26 ` [Qemu-devel] [PATCH v5 04/11] nbd/server: Report error for write to read-only export Eric Blake
2017-10-20  8:06   ` Vladimir Sementsov-Ogievskiy
2017-10-19 22:26 ` [Qemu-devel] [PATCH v5 05/11] nbd/server: Refactor zero-length option check Eric Blake
2017-10-20  8:34   ` Vladimir Sementsov-Ogievskiy
2017-10-20 15:07     ` Eric Blake
2017-10-20 18:12       ` Vladimir Sementsov-Ogievskiy
2017-10-19 22:26 ` [Qemu-devel] [PATCH v5 06/11] nbd: Minimal structured read for server Eric Blake
2017-10-20 19:03   ` Vladimir Sementsov-Ogievskiy
2017-10-20 19:11     ` Eric Blake
2017-10-20 19:30       ` Vladimir Sementsov-Ogievskiy
2017-10-21 16:02         ` Eric Blake
2017-10-19 22:26 ` [Qemu-devel] [PATCH v5 07/11] nbd/server: Include human-readable message in structured errors Eric Blake
2017-10-20 19:08   ` Vladimir Sementsov-Ogievskiy
2017-10-19 22:26 ` [Qemu-devel] [PATCH v5 08/11] nbd/client: refactor nbd_receive_starttls Eric Blake
2017-10-20 19:26   ` Vladimir Sementsov-Ogievskiy
2017-10-20 19:33     ` Eric Blake [this message]
2017-10-19 22:26 ` [Qemu-devel] [PATCH v5 09/11] nbd/client: prepare nbd_receive_reply for structured reply Eric Blake
2017-10-19 22:26 ` [Qemu-devel] [PATCH v5 10/11] nbd: Move nbd_read() to common header Eric Blake
2017-10-19 22:26 ` [Qemu-devel] [PATCH v5 11/11] nbd: Minimal structured read for client Eric Blake
2017-10-20 19:58   ` Vladimir Sementsov-Ogievskiy
2017-10-20 20:46     ` Eric Blake
2017-10-23 11:57   ` Eric Blake
2017-10-23 12:24     ` Vladimir Sementsov-Ogievskiy
2017-10-24  7:31   ` Eric Blake
2017-10-19 23:07 ` [Qemu-devel] [PATCH v5 00/11] nbd minimal structured read no-reply
2017-10-20 15:09   ` Eric Blake

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=bab67a31-3f07-1d77-153a-6b78fcbb9d24@redhat.com \
    --to=eblake@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=vsementsov@virtuozzo.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).