nbd/server: Support a request payload
commit8f2433c480c2294d6f8246e6677e9a7d8a64fb67
authorEric Blake <eblake@redhat.com>
Tue, 8 Aug 2023 14:37:23 +0000 (8 09:37 -0500)
committerEric Blake <eblake@redhat.com>
Thu, 10 Aug 2023 14:44:01 +0000 (10 09:44 -0500)
tree1a0da07a59828c31e09a327f5e3b9f3c2929dc20
parent1ce7ddcd873b3ebcb1eab5fb1caf6cc4ed7bb305
nbd/server: Support a request payload

Upcoming additions to support NBD 64-bit effect lengths allow for the
possibility to distinguish between payload length (capped at 32M) and
effect length (64 bits, although we generally assume 63 bits because
of off_t limitations).  Without that extension, only the NBD_CMD_WRITE
request has a payload; but with the extension, it makes sense to allow
at least NBD_CMD_BLOCK_STATUS to have both a payload and effect length
in a future patch (where the payload is a limited-size struct that in
turn gives the real effect length as well as a subset of known ids for
which status is requested).  Other future NBD commands may also have a
request payload, so the 64-bit extension introduces a new
NBD_CMD_FLAG_PAYLOAD_LEN that distinguishes between whether the header
length is a payload length or an effect length, rather than
hard-coding the decision based on the command; although a client
should never send a command with a payload without the negotiation
phase proving such extension is available, we are now able to
gracefully fail unexpected client payloads while keeping the
connection alive.  Note that we do not support the payload version of
BLOCK_STATUS yet.

Signed-off-by: Eric Blake <eblake@redhat.com>
---

v5: retitled from v4 13/24, rewrite on top of previous patch's switch
statement [Vladimir]

v4: less indentation on several 'if's [Vladimir]
nbd/server.c
nbd/trace-events