nbd/server: Refactor handling of command sanity checks
commit1ce7ddcd873b3ebcb1eab5fb1caf6cc4ed7bb305
authorEric Blake <eblake@redhat.com>
Mon, 15 May 2023 17:57:06 +0000 (15 12:57 -0500)
committerEric Blake <eblake@redhat.com>
Thu, 10 Aug 2023 14:44:01 +0000 (10 09:44 -0500)
treeb42ead8878f7fd22340813c470db8c78a51aa5aa
parente543bf20d1e1e892f7db3294eadfda0d3cf6d0e3
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>
---

v5: new patch split out from v4 13/24 [Vladimir]
nbd/server.c