Skip to content

Commit 2f722b1

Browse files
jinliangwigaw
authored andcommitted
mi: set correct rc and errno when crc mismatch
Before the fix, when we meet crc mismatch response, the errno is 0 and rc is 1. This combination will be mistaken as Admin Generic Command Status code value 0x1 (Invalid Command Opcode): $ nvme id-ctrl mctp:1,20 crc mismatch NVMe status: Invalid Command Opcode: A reserved coded value or an unsupported value in the command opcode field(0x1 After the fix, the rc is -1, and errno is set to Bad message. $ nvme id-ctrl mctp:1,20 crc mismatch identify controller: Bad message Signed-off-by: Jinliang Wang <[email protected]>
1 parent 5084885 commit 2f722b1

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

src/nvme/mi.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,8 @@ int nvme_mi_submit(nvme_mi_ep_t ep, struct nvme_mi_req *req,
433433
rc = nvme_mi_verify_resp_mic(resp);
434434
if (rc) {
435435
nvme_msg(ep->root, LOG_WARNING, "crc mismatch\n");
436-
return rc;
436+
errno = EBADMSG;
437+
return -1;
437438
}
438439
}
439440

test/mi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ static void test_invalid_crc(nvme_mi_ep_t ep)
306306

307307
test_set_transport_callback(ep, test_invalid_crc_cb, NULL);
308308
rc = nvme_mi_mi_read_mi_data_subsys(ep, &ss_info);
309-
assert(rc != 0);
309+
assert(rc < 0);
310310
}
311311

312312
/* test: test that the controller list populates the endpoint's list of

0 commit comments

Comments
 (0)