nbd/server: rename clientflags var in nbd_negotiate_options
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>
This commit is contained in:
parent
4875196163
commit
7f9039cdaa
38
nbd/server.c
38
nbd/server.c
@ -415,7 +415,7 @@ static int nbd_negotiate_options(NBDClient *client, Error **errp)
|
|||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
int ret;
|
int ret;
|
||||||
uint32_t clientflags, length;
|
uint32_t option, length;
|
||||||
uint64_t magic;
|
uint64_t magic;
|
||||||
|
|
||||||
if (nbd_read(client->ioc, &magic, sizeof(magic), errp) < 0) {
|
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;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nbd_read(client->ioc, &clientflags,
|
if (nbd_read(client->ioc, &option,
|
||||||
sizeof(clientflags), errp) < 0) {
|
sizeof(option), errp) < 0) {
|
||||||
error_prepend(errp, "read failed: ");
|
error_prepend(errp, "read failed: ");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
clientflags = be32_to_cpu(clientflags);
|
option = be32_to_cpu(option);
|
||||||
|
|
||||||
if (nbd_read(client->ioc, &length, sizeof(length), errp) < 0) {
|
if (nbd_read(client->ioc, &length, sizeof(length), errp) < 0) {
|
||||||
error_prepend(errp, "read failed: ");
|
error_prepend(errp, "read failed: ");
|
||||||
@ -441,15 +441,15 @@ static int nbd_negotiate_options(NBDClient *client, Error **errp)
|
|||||||
}
|
}
|
||||||
length = be32_to_cpu(length);
|
length = be32_to_cpu(length);
|
||||||
|
|
||||||
TRACE("Checking option 0x%" PRIx32, clientflags);
|
TRACE("Checking option 0x%" PRIx32, option);
|
||||||
if (client->tlscreds &&
|
if (client->tlscreds &&
|
||||||
client->ioc == (QIOChannel *)client->sioc) {
|
client->ioc == (QIOChannel *)client->sioc) {
|
||||||
QIOChannel *tioc;
|
QIOChannel *tioc;
|
||||||
if (!fixedNewstyle) {
|
if (!fixedNewstyle) {
|
||||||
error_setg(errp, "Unsupported option 0x%" PRIx32, clientflags);
|
error_setg(errp, "Unsupported option 0x%" PRIx32, option);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
switch (clientflags) {
|
switch (option) {
|
||||||
case NBD_OPT_STARTTLS:
|
case NBD_OPT_STARTTLS:
|
||||||
tioc = nbd_negotiate_handle_starttls(client, length, errp);
|
tioc = nbd_negotiate_handle_starttls(client, length, errp);
|
||||||
if (!tioc) {
|
if (!tioc) {
|
||||||
@ -462,7 +462,7 @@ static int nbd_negotiate_options(NBDClient *client, Error **errp)
|
|||||||
case NBD_OPT_EXPORT_NAME:
|
case NBD_OPT_EXPORT_NAME:
|
||||||
/* No way to return an error to client, so drop connection */
|
/* No way to return an error to client, so drop connection */
|
||||||
error_setg(errp, "Option 0x%x not permitted before TLS",
|
error_setg(errp, "Option 0x%x not permitted before TLS",
|
||||||
clientflags);
|
option);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -471,21 +471,21 @@ static int nbd_negotiate_options(NBDClient *client, Error **errp)
|
|||||||
}
|
}
|
||||||
ret = nbd_negotiate_send_rep_err(client->ioc,
|
ret = nbd_negotiate_send_rep_err(client->ioc,
|
||||||
NBD_REP_ERR_TLS_REQD,
|
NBD_REP_ERR_TLS_REQD,
|
||||||
clientflags, errp,
|
option, errp,
|
||||||
"Option 0x%" PRIx32
|
"Option 0x%" PRIx32
|
||||||
"not permitted before TLS",
|
"not permitted before TLS",
|
||||||
clientflags);
|
option);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
/* Let the client keep trying, unless they asked to quit */
|
/* Let the client keep trying, unless they asked to quit */
|
||||||
if (clientflags == NBD_OPT_ABORT) {
|
if (option == NBD_OPT_ABORT) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (fixedNewstyle) {
|
} else if (fixedNewstyle) {
|
||||||
switch (clientflags) {
|
switch (option) {
|
||||||
case NBD_OPT_LIST:
|
case NBD_OPT_LIST:
|
||||||
ret = nbd_negotiate_handle_list(client, length, errp);
|
ret = nbd_negotiate_handle_list(client, length, errp);
|
||||||
if (ret < 0) {
|
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
|
/* NBD spec says we must try to reply before
|
||||||
* disconnecting, but that we must also tolerate
|
* disconnecting, but that we must also tolerate
|
||||||
* guests that don't wait for our reply. */
|
* 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);
|
&local_err);
|
||||||
|
|
||||||
if (local_err != NULL) {
|
if (local_err != NULL) {
|
||||||
@ -518,12 +518,12 @@ static int nbd_negotiate_options(NBDClient *client, Error **errp)
|
|||||||
if (client->tlscreds) {
|
if (client->tlscreds) {
|
||||||
ret = nbd_negotiate_send_rep_err(client->ioc,
|
ret = nbd_negotiate_send_rep_err(client->ioc,
|
||||||
NBD_REP_ERR_INVALID,
|
NBD_REP_ERR_INVALID,
|
||||||
clientflags, errp,
|
option, errp,
|
||||||
"TLS already enabled");
|
"TLS already enabled");
|
||||||
} else {
|
} else {
|
||||||
ret = nbd_negotiate_send_rep_err(client->ioc,
|
ret = nbd_negotiate_send_rep_err(client->ioc,
|
||||||
NBD_REP_ERR_POLICY,
|
NBD_REP_ERR_POLICY,
|
||||||
clientflags, errp,
|
option, errp,
|
||||||
"TLS not configured");
|
"TLS not configured");
|
||||||
}
|
}
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@ -536,10 +536,10 @@ static int nbd_negotiate_options(NBDClient *client, Error **errp)
|
|||||||
}
|
}
|
||||||
ret = nbd_negotiate_send_rep_err(client->ioc,
|
ret = nbd_negotiate_send_rep_err(client->ioc,
|
||||||
NBD_REP_ERR_UNSUP,
|
NBD_REP_ERR_UNSUP,
|
||||||
clientflags, errp,
|
option, errp,
|
||||||
"Unsupported option 0x%"
|
"Unsupported option 0x%"
|
||||||
PRIx32,
|
PRIx32,
|
||||||
clientflags);
|
option);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -550,12 +550,12 @@ static int nbd_negotiate_options(NBDClient *client, Error **errp)
|
|||||||
* If broken new-style we should drop the connection
|
* If broken new-style we should drop the connection
|
||||||
* for anything except NBD_OPT_EXPORT_NAME
|
* for anything except NBD_OPT_EXPORT_NAME
|
||||||
*/
|
*/
|
||||||
switch (clientflags) {
|
switch (option) {
|
||||||
case NBD_OPT_EXPORT_NAME:
|
case NBD_OPT_EXPORT_NAME:
|
||||||
return nbd_negotiate_handle_export_name(client, length, errp);
|
return nbd_negotiate_handle_export_name(client, length, errp);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
error_setg(errp, "Unsupported option 0x%" PRIx32, clientflags);
|
error_setg(errp, "Unsupported option 0x%" PRIx32, option);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user