]> www.infradead.org Git - users/sagi/libnvme.git/commit
mi-mctp: better handling for error/unexpected responses
authorJeremy Kerr <jk@codeconstruct.com.au>
Wed, 29 Jun 2022 10:14:51 +0000 (18:14 +0800)
committerJeremy Kerr <jk@codeconstruct.com.au>
Fri, 1 Jul 2022 06:52:36 +0000 (14:52 +0800)
commite451d1e984b363fab83f28bfd267b5fb909de4d3
treedb0c92ffcaba3d9352e17f7d4b388ff18dbace14
parent502707c11a1792472b11e48d6f83f71c8ae3d7eb
mi-mctp: better handling for error/unexpected responses

Currently, the mi-mctp transport expects there to be at least a complete
header-sized reply - matching the caller's resp->hdr_size value,
otherwise we consider this a transport failure.

However, Admin command responses have a header that's larger than the
generic error response message, so we should be able to handle response
messages that are just the small header and no payload.

This change reworks the response-buffer handling in the MCTP transport.
Rather than storing the payload and MIC into an extra allocated buffer,
we just lay out the response iovec directly into the header, payload and
MIC buffers, and then handle the short-response cases as needed. This
means we can properly extract the error response, rather than just
having the transport report a generic "header too small" failure itself.

This is at high risk for off-by-one errors, so add tests to cover each
of the possible buffer-arrangement cases.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
src/nvme/mi-mctp.c
test/mi-mctp.c