qemu-e2k/nbd
Eric Blake ef8c887ee0 nbd/server: Fix structured read of length 0
The NBD spec was recently clarified to state that a read of length 0
should not be attempted by a compliant client; but that a server must
still handle it correctly in an unspecified manner (that is, either
a successful no-op or an error reply, but not a crash) [1].  However,
it also implies that NBD_REPLY_TYPE_OFFSET_DATA must have a non-zero
payload length, but our existing code was replying with a chunk
that a picky client could reject as invalid because it was missing
a payload (our own client implementation was recently patched to be
that picky, after first fixing it to not send 0-length requests).

We are already doing successful no-ops for 0-length writes and for
non-structured reads; so for consistency, we want structured reply
reads to also be a no-op.  The easiest way to do this is to return
a NBD_REPLY_TYPE_NONE chunk; this is best done via a new helper
function (especially since future patches for other structured
replies may benefit from using the same helper).

[1] https://github.com/NetworkBlockDevice/nbd/commit/ee926037

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20171108215703.9295-8-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2017-11-09 10:25:11 -06:00
..
client.c nbd/client: Nicer trace of structured reply 2017-11-09 10:16:45 -06:00
common.c nbd: Expose constants and structs for structured read 2017-10-30 21:07:21 +01:00
Makefile.objs
nbd-internal.h nbd: Minimal structured read for client 2017-10-30 21:48:41 +01:00
server.c nbd/server: Fix structured read of length 0 2017-11-09 10:25:11 -06:00
trace-events nbd/server: Fix structured read of length 0 2017-11-09 10:25:11 -06:00