From 4fa0bf5b98e4a9fba42bd56920930b1901c7824f Mon Sep 17 00:00:00 2001 From: ryohtakawase Date: Wed, 25 Sep 2024 13:23:00 +0900 Subject: [PATCH] Fix #704 tcmu_cdb_get_length() will return 10 for vendor specific cdb tcmur_cmdproc_thread() will not drop vendor specific command --- api.c | 2 +- main.c | 24 +++++++++++++++++------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/api.c b/api.c index 6ffbcd1f..1b52e51c 100644 --- a/api.c +++ b/api.c @@ -51,6 +51,7 @@ int tcmu_cdb_get_length(uint8_t *cdb) return 12; case 6: /*110b Vendor Specific */ case 7: /*111b Vendor Specific */ + return 10; default: /* TODO: */ goto cdb_not_supp; @@ -327,7 +328,6 @@ void tcmu_cdb_print_info(struct tcmu_device *dev, char fix[CDB_FIX_SIZE], *buf; buf = fix; - bytes = tcmu_cdb_get_length(cmd->cdb); if (bytes < 0) return; diff --git a/main.c b/main.c index 70b42335..5202a2ce 100644 --- a/main.c +++ b/main.c @@ -814,13 +814,23 @@ static void *tcmur_cmdproc_thread(void *arg) if (tcmu_get_log_level() == TCMU_LOG_DEBUG_SCSI_CMD) tcmu_cdb_print_info(dev, cmd, NULL); - if (tcmur_handler_is_passthrough_only(rhandler)) - ret = tcmur_cmd_passthrough_handler(dev, cmd); - else - ret = tcmur_generic_handle_cmd(dev, cmd); - - if (ret == TCMU_STS_NOT_HANDLED) - tcmu_cdb_print_info(dev, cmd, "is not supported"); + if (cmd->cdb[0] <= 0xC0) { + if (tcmur_handler_is_passthrough_only(rhandler)) + ret = tcmur_cmd_passthrough_handler(dev, cmd); + else + ret = tcmur_generic_handle_cmd(dev, cmd); + + if (ret == TCMU_STS_NOT_HANDLED) + tcmu_cdb_print_info(dev, cmd, "is not supported"); + } else { + /* + * Vendor specific opcodes are currently not supported in TCMU + * given it requires callbacks that currently don't exist for + * TCMU backstores. + */ + ret = TCMU_STS_NOT_HANDLED; + tcmu_cdb_print_info(dev, cmd, "Vendor specific opcodes not supported."); + } /* * command (processing) completion is called in the following