Skip to content

Commit

Permalink
nbd: zero from and len fields in NBD_CMD_DISCONNECT.
Browse files Browse the repository at this point in the history
Len field is already set to zero, but not the from field which is sent
as 0xfffffffffffffe00.  This makes no sense, and may cause confuse
server implementations doing sanity checks (qemu-nbd is an example.)

Signed-off-by: Hani Benhabiles <hani@linux.com>
Cc: Paul Clements <paul.clements@us.sios.com>
Cc: Paul Clements <Paul.Clements@steeleye.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Hani Benhabiles authored and Linus Torvalds committed Jun 6, 2014
1 parent b1de0d1 commit 04cfac4
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions drivers/block/nbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,11 @@ static int nbd_send_req(struct nbd_device *nbd, struct request *req)
struct nbd_request request;
unsigned long size = blk_rq_bytes(req);

memset(&request, 0, sizeof(request));
request.magic = htonl(NBD_REQUEST_MAGIC);
request.type = htonl(nbd_cmd(req));

if (nbd_cmd(req) == NBD_CMD_FLUSH) {
/* Other values are reserved for FLUSH requests. */
request.from = 0;
request.len = 0;
} else {
if (nbd_cmd(req) != NBD_CMD_FLUSH && nbd_cmd(req) != NBD_CMD_DISC) {
request.from = cpu_to_be64((u64)blk_rq_pos(req) << 9);
request.len = htonl(size);
}
Expand Down

0 comments on commit 04cfac4

Please sign in to comment.