All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	"open list:Network Block Dev..." <qemu-block@nongnu.org>
Subject: [Qemu-devel] [PULL 09/11] nbd/server: rename clientflags var in nbd_negotiate_options
Date: Mon, 10 Jul 2017 07:14:32 -0500	[thread overview]
Message-ID: <20170710121434.5047-10-eblake@redhat.com> (raw)
In-Reply-To: <20170710121434.5047-1-eblake@redhat.com>

From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>

Rename 'clientflags' to just 'option'. This variable has nothing to do
with flags, but is a single integer representing the option requested
by the client.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20170707152918.23086-9-vsementsov@virtuozzo.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
---
 nbd/server.c | 38 +++++++++++++++++++-------------------
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/nbd/server.c b/nbd/server.c
index 1eeafcc..c4d64fb 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -415,7 +415,7 @@ static int nbd_negotiate_options(NBDClient *client, Error **errp)

     while (1) {
         int ret;
-        uint32_t clientflags, length;
+        uint32_t option, length;
         uint64_t magic;

         if (nbd_read(client->ioc, &magic, sizeof(magic), errp) < 0) {
@@ -428,12 +428,12 @@ static int nbd_negotiate_options(NBDClient *client, Error **errp)
             return -EINVAL;
         }

-        if (nbd_read(client->ioc, &clientflags,
-                     sizeof(clientflags), errp) < 0) {
+        if (nbd_read(client->ioc, &option,
+                     sizeof(option), errp) < 0) {
             error_prepend(errp, "read failed: ");
             return -EINVAL;
         }
-        clientflags = be32_to_cpu(clientflags);
+        option = be32_to_cpu(option);

         if (nbd_read(client->ioc, &length, sizeof(length), errp) < 0) {
             error_prepend(errp, "read failed: ");
@@ -441,15 +441,15 @@ static int nbd_negotiate_options(NBDClient *client, Error **errp)
         }
         length = be32_to_cpu(length);

-        TRACE("Checking option 0x%" PRIx32, clientflags);
+        TRACE("Checking option 0x%" PRIx32, option);
         if (client->tlscreds &&
             client->ioc == (QIOChannel *)client->sioc) {
             QIOChannel *tioc;
             if (!fixedNewstyle) {
-                error_setg(errp, "Unsupported option 0x%" PRIx32, clientflags);
+                error_setg(errp, "Unsupported option 0x%" PRIx32, option);
                 return -EINVAL;
             }
-            switch (clientflags) {
+            switch (option) {
             case NBD_OPT_STARTTLS:
                 tioc = nbd_negotiate_handle_starttls(client, length, errp);
                 if (!tioc) {
@@ -462,7 +462,7 @@ static int nbd_negotiate_options(NBDClient *client, Error **errp)
             case NBD_OPT_EXPORT_NAME:
                 /* No way to return an error to client, so drop connection */
                 error_setg(errp, "Option 0x%x not permitted before TLS",
-                           clientflags);
+                           option);
                 return -EINVAL;

             default:
@@ -471,21 +471,21 @@ static int nbd_negotiate_options(NBDClient *client, Error **errp)
                 }
                 ret = nbd_negotiate_send_rep_err(client->ioc,
                                                  NBD_REP_ERR_TLS_REQD,
-                                                 clientflags, errp,
+                                                 option, errp,
                                                  "Option 0x%" PRIx32
                                                  "not permitted before TLS",
-                                                 clientflags);
+                                                 option);
                 if (ret < 0) {
                     return ret;
                 }
                 /* Let the client keep trying, unless they asked to quit */
-                if (clientflags == NBD_OPT_ABORT) {
+                if (option == NBD_OPT_ABORT) {
                     return 1;
                 }
                 break;
             }
         } else if (fixedNewstyle) {
-            switch (clientflags) {
+            switch (option) {
             case NBD_OPT_LIST:
                 ret = nbd_negotiate_handle_list(client, length, errp);
                 if (ret < 0) {
@@ -497,7 +497,7 @@ static int nbd_negotiate_options(NBDClient *client, Error **errp)
                 /* NBD spec says we must try to reply before
                  * disconnecting, but that we must also tolerate
                  * guests that don't wait for our reply. */
-                nbd_negotiate_send_rep(client->ioc, NBD_REP_ACK, clientflags,
+                nbd_negotiate_send_rep(client->ioc, NBD_REP_ACK, option,
                                        &local_err);

                 if (local_err != NULL) {
@@ -518,12 +518,12 @@ static int nbd_negotiate_options(NBDClient *client, Error **errp)
                 if (client->tlscreds) {
                     ret = nbd_negotiate_send_rep_err(client->ioc,
                                                      NBD_REP_ERR_INVALID,
-                                                     clientflags, errp,
+                                                     option, errp,
                                                      "TLS already enabled");
                 } else {
                     ret = nbd_negotiate_send_rep_err(client->ioc,
                                                      NBD_REP_ERR_POLICY,
-                                                     clientflags, errp,
+                                                     option, errp,
                                                      "TLS not configured");
                 }
                 if (ret < 0) {
@@ -536,10 +536,10 @@ static int nbd_negotiate_options(NBDClient *client, Error **errp)
                 }
                 ret = nbd_negotiate_send_rep_err(client->ioc,
                                                  NBD_REP_ERR_UNSUP,
-                                                 clientflags, errp,
+                                                 option, errp,
                                                  "Unsupported option 0x%"
                                                  PRIx32,
-                                                 clientflags);
+                                                 option);
                 if (ret < 0) {
                     return ret;
                 }
@@ -550,12 +550,12 @@ static int nbd_negotiate_options(NBDClient *client, Error **errp)
              * If broken new-style we should drop the connection
              * for anything except NBD_OPT_EXPORT_NAME
              */
-            switch (clientflags) {
+            switch (option) {
             case NBD_OPT_EXPORT_NAME:
                 return nbd_negotiate_handle_export_name(client, length, errp);

             default:
-                error_setg(errp, "Unsupported option 0x%" PRIx32, clientflags);
+                error_setg(errp, "Unsupported option 0x%" PRIx32, option);
                 return -EINVAL;
             }
         }
-- 
2.9.4

  parent reply	other threads:[~2017-07-10 12:15 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-10 12:14 [Qemu-devel] [PULL 00/11] NBD patches Eric Blake
2017-07-10 12:14 ` [Qemu-devel] [PULL 01/11] MAINTAINERS: Promote NBD to supported, with new maintainer Eric Blake
2017-07-10 14:47   ` Eric Blake
2017-07-10 12:14 ` [Qemu-devel] [PULL 02/11] nbd/server: nbd_negotiate: return 1 on NBD_OPT_ABORT Eric Blake
2017-07-10 12:14 ` [Qemu-devel] [PULL 03/11] nbd/server: refactor nbd_negotiate Eric Blake
2017-07-10 12:14 ` [Qemu-devel] [PULL 04/11] nbd/server: use errp instead of LOG Eric Blake
2017-07-10 12:14 ` [Qemu-devel] [PULL 05/11] nbd/server: add errp to nbd_send_reply() Eric Blake
2017-07-10 12:14 ` [Qemu-devel] [PULL 06/11] nbd/common: nbd_tls_handshake: remove extra TRACE Eric Blake
2017-07-10 12:14 ` [Qemu-devel] [PULL 07/11] nbd/client: refactor TRACE of NBD_MAGIC Eric Blake
2017-07-10 12:14 ` [Qemu-devel] [PULL 08/11] nbd/server: fix TRACE in nbd_negotiate_send_rep_len Eric Blake
2017-07-10 12:14 ` Eric Blake [this message]
2017-07-10 12:14 ` [Qemu-devel] [PULL 10/11] nbd: refactor tracing Eric Blake
2017-07-10 12:14 ` [Qemu-devel] [PULL 11/11] nbd: use generic trace subsystem instead of TRACE macro Eric Blake
2017-07-10 14:24 ` [Qemu-devel] [PULL 00/11] NBD patches Peter Maydell
2017-07-10 14:44   ` 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=20170710121434.5047-10-eblake@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 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.