[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC PATCH 5/6] Check Service Action when handling Read Capacity 16



Read Capacity 16 shares the same opcode with other Service Action In 16
subcommands.

Add an explicit check for SERVICE_ACTION_READ_CAPACITY16.

Signed-off-by: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>
---
 include/xencdb.h    |  8 ++++++++
 src/xenvbd/target.c | 26 ++++++++++++++++++++++++--
 2 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/include/xencdb.h b/include/xencdb.h
index 492d50d..594e9fe 100644
--- a/include/xencdb.h
+++ b/include/xencdb.h
@@ -261,6 +261,14 @@ FORCEINLINE UCHAR Cdb_EVPD(const SCSI_REQUEST_BLOCK* const 
srb)
     return Cdb_EVPDRaw(srb->CdbLength, srb->Cdb);
 }
 
+FORCEINLINE UCHAR Cdb_ServiceAction(const SCSI_REQUEST_BLOCK* const srb)
+{
+    if (srb->CdbLength > 6)
+        return srb->Cdb[1] & 0x1F;
+    else
+        return 0;
+}
+
 FORCEINLINE const char* Cdb_OperationName(UCHAR op)
 {
 #define _SCSIOP_NAME(x) case x: return #x;
diff --git a/src/xenvbd/target.c b/src/xenvbd/target.c
index 3d48ade..2cae479 100644
--- a/src/xenvbd/target.c
+++ b/src/xenvbd/target.c
@@ -636,6 +636,28 @@ fail1:
     Error("fail1\n");
 }
 
+static DECLSPEC_NOINLINE VOID
+TargetServiceActionIn16(
+    IN  PXENVBD_TARGET      Target,
+    IN  PSCSI_REQUEST_BLOCK Srb
+    )
+{
+    UCHAR                   ServiceAction = Cdb_ServiceAction(Srb);
+
+    switch (ServiceAction){
+    case SERVICE_ACTION_READ_CAPACITY16:
+        TargetReadCapacity16(Target, Srb);
+        return;
+    default:
+        Trace("Target[%d] : Unsupported SCSIOP_SERVICE_ACTION_IN16 "
+              "service action (%02hhx)\n",
+              TargetGetTargetId(Target),
+              ServiceAction);
+        Srb->SrbStatus = SRB_STATUS_INVALID_REQUEST;
+        break;
+    }
+}
+
 static FORCEINLINE VOID
 TargetInquiryStd(
     IN  PXENVBD_TARGET      Target,
@@ -1063,8 +1085,8 @@ TargetStartIo(
         TargetReadCapacity(Target, Srb);
         break;
 
-    case SCSIOP_READ_CAPACITY16:
-        TargetReadCapacity16(Target, Srb);
+    case SCSIOP_SERVICE_ACTION_IN16:
+        TargetServiceActionIn16(Target, Srb);
         break;
 
     case SCSIOP_MEDIUM_REMOVAL:
-- 
2.51.2.windows.1



--
Ngoc Tu Dinh | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.