OSDN Git Service

nbd/server: Refactor handling of command sanity checks
authorEric Blake <eblake@redhat.com>
Tue, 29 Aug 2023 17:58:32 +0000 (12:58 -0500)
committerEric Blake <eblake@redhat.com>
Mon, 25 Sep 2023 13:43:22 +0000 (08:43 -0500)
commit8db7e2d65733268f7e788a69f5c6125f14f14cb0
tree4bb951686a85e6654f6578e4587be4dd34ac028c
parentb2578459323c56002b360f5fc02188be7f5ca4db
nbd/server: Refactor handling of command sanity checks

Upcoming additions to support NBD 64-bit effect lengths will add a new
command flag NBD_CMD_FLAG_PAYLOAD_LEN that needs to be considered in
our sanity checks of the client's messages (that is, more than just
CMD_WRITE have the potential to carry a client payload when extended
headers are in effect).  But before we can start to support that, it
is easier to first refactor the existing set of various if statements
over open-coded combinations of request->type to instead be a single
switch statement over all command types that sets witnesses, then
straight-line processing based on the witnesses.  No semantic change
is intended.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-ID: <20230829175826.377251-24-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
nbd/server.c