Print this page
Build provider 3rd arg from smb_request_t
hacking...
NEX-1643 dtrace provider for smbsrv
Also illumos 1841:
 DTrace smb provider was mis-implemented, doesn't exist.
Add back handlers for read/write raw, so that
 legacy dtrace consumers can find the probes.
Kill extra arg in smb_negotiate
Fix missing "done" probe with smb_notify
Add example consumer: smb-trace.d
fix soi_pid

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/smbsrv/smb_read.c
          +++ new/usr/src/uts/common/fs/smbsrv/smb_read.c
↓ open down ↓ 65 lines elided ↑ open up ↑
  66   66          param = kmem_zalloc(sizeof (smb_rw_param_t), KM_SLEEP);
  67   67          sr->arg.rw = param;
  68   68  
  69   69          rc = smbsr_decode_vwv(sr, "wwlw", &sr->smb_fid,
  70   70              &count, &off_low, &remcnt);
  71   71  
  72   72          param->rw_offset = (uint64_t)off_low;
  73   73          param->rw_count = (uint32_t)count;
  74   74          param->rw_mincnt = 0;
  75   75  
  76      -        DTRACE_SMB_2(op__Read__start, smb_request_t *, sr,
  77      -            smb_rw_param_t *, param);
       76 +        DTRACE_SMB_1(op__Read__start, smb_request_t *, sr); /* arg.rw */
  78   77  
  79   78          return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
  80   79  }
  81   80  
  82   81  void
  83   82  smb_post_read(smb_request_t *sr)
  84   83  {
  85      -        DTRACE_SMB_2(op__Read__done, smb_request_t *, sr,
  86      -            smb_rw_param_t *, sr->arg.rw);
       84 +        DTRACE_SMB_1(op__Read__done, smb_request_t *, sr); /* arg.rw */
  87   85  
  88   86          kmem_free(sr->arg.rw, sizeof (smb_rw_param_t));
  89   87  }
  90   88  
  91   89  smb_sdrc_t
  92   90  smb_com_read(smb_request_t *sr)
  93   91  {
  94   92          smb_rw_param_t *param = sr->arg.rw;
  95   93          uint16_t count;
  96   94          int rc;
↓ open down ↓ 55 lines elided ↑ open up ↑
 152  150          param = kmem_zalloc(sizeof (smb_rw_param_t), KM_SLEEP);
 153  151          sr->arg.rw = param;
 154  152  
 155  153          rc = smbsr_decode_vwv(sr, "wwlw", &sr->smb_fid,
 156  154              &count, &off_low, &remcnt);
 157  155  
 158  156          param->rw_offset = (uint64_t)off_low;
 159  157          param->rw_count = (uint32_t)count;
 160  158          param->rw_mincnt = 0;
 161  159  
 162      -        DTRACE_SMB_2(op__LockAndRead__start, smb_request_t *, sr,
 163      -            smb_rw_param_t *, param);
      160 +        DTRACE_SMB_1(op__LockAndRead__start, smb_request_t *, sr); /* arg.rw */
 164  161  
 165  162          return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
 166  163  }
 167  164  
 168  165  void
 169  166  smb_post_lock_and_read(smb_request_t *sr)
 170  167  {
 171      -        DTRACE_SMB_2(op__LockAndRead__done, smb_request_t *, sr,
 172      -            smb_rw_param_t *, sr->arg.rw);
      168 +        DTRACE_SMB_1(op__LockAndRead__done, smb_request_t *, sr); /* arg.rw */
 173  169  
 174  170          kmem_free(sr->arg.rw, sizeof (smb_rw_param_t));
 175  171  }
 176  172  
 177  173  smb_sdrc_t
 178  174  smb_com_lock_and_read(smb_request_t *sr)
 179  175  {
 180  176          smb_rw_param_t *param = sr->arg.rw;
 181  177          DWORD status;
 182  178          uint32_t lk_pid;
↓ open down ↓ 33 lines elided ↑ open up ↑
 216  212          }
 217  213  
 218  214          count = (uint16_t)param->rw_count;
 219  215          rc = smbsr_encode_result(sr, 5, VAR_BCC, "bw8.wbwC",
 220  216              5, count, VAR_BCC, 0x1, count, &sr->raw_data);
 221  217  
 222  218          return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
 223  219  }
 224  220  
 225  221  /*
      222 + * The SMB_COM_READ_RAW protocol was a negotiated option introduced in
      223 + * SMB Core Plus to maximize performance when reading a large block
      224 + * of data from a server.  It's obsolete and no longer supported.
      225 + *
      226 + * We keep a handler for it so the dtrace provider can see if
      227 + * the client tried to use this command.
      228 + */
      229 +smb_sdrc_t
      230 +smb_pre_read_raw(smb_request_t *sr)
      231 +{
      232 +        smb_rw_param_t *param;
      233 +        uint32_t off_low;
      234 +        uint32_t off_high;
      235 +        uint32_t timeout;
      236 +        uint16_t count;
      237 +        int rc;
      238 +
      239 +        param = kmem_zalloc(sizeof (smb_rw_param_t), KM_SLEEP);
      240 +        sr->arg.rw = param;
      241 +        if (sr->smb_wct == 8) {
      242 +                rc = smbsr_decode_vwv(sr, "wlwwl2.", &sr->smb_fid,
      243 +                    &off_low, &count, &param->rw_mincnt, &timeout);
      244 +                if (rc == 0) {
      245 +                        param->rw_offset = (uint64_t)off_low;
      246 +                        param->rw_count = (uint32_t)count;
      247 +                }
      248 +        } else {
      249 +                rc = smbsr_decode_vwv(sr, "wlwwl2.l", &sr->smb_fid,
      250 +                    &off_low, &count, &param->rw_mincnt, &timeout, &off_high);
      251 +                if (rc == 0) {
      252 +                        param->rw_offset = ((uint64_t)off_high << 32) | off_low;
      253 +                        param->rw_count = (uint32_t)count;
      254 +                }
      255 +        }
      256 +        DTRACE_SMB_1(op__ReadRaw__start, smb_request_t *, sr); /* arg.rw */
      257 +        return (SDRC_SUCCESS);
      258 +}
      259 +
      260 +void
      261 +smb_post_read_raw(smb_request_t *sr)
      262 +{
      263 +        DTRACE_SMB_1(op__ReadRaw__done, smb_request_t *, sr); /* arg.rw */
      264 +
      265 +        kmem_free(sr->arg.rw, sizeof (smb_rw_param_t));
      266 +}
      267 +
      268 +smb_sdrc_t
      269 +smb_com_read_raw(smb_request_t *sr)
      270 +{
      271 +        smbsr_error(sr, NT_STATUS_NOT_SUPPORTED, ERRDOS,
      272 +            ERROR_NOT_SUPPORTED);
      273 +        return (SDRC_ERROR);
      274 +}
      275 +
      276 +/*
 226  277   * Read bytes from a file (SMB Core).  This request was extended in
 227  278   * LM 0.12 to support 64-bit offsets, indicated by sending a wct of
 228  279   * 12 and including additional offset information.
 229  280   *
 230  281   * MS-SMB 3.3.5.7 update to LM 0.12 4.2.4:
 231  282   * If wct is 12 and CAP_LARGE_READX is set, the count may be larger
 232  283   * than the negotiated buffer size.  If maxcnt_high is 0xFF, it must
 233  284   * be ignored.  Otherwise, maxcnt_high represents the upper 16 bits
 234  285   * of rw_count.
 235  286   */
↓ open down ↓ 29 lines elided ↑ open up ↑
 265  316                  rc = smbsr_decode_vwv(sr, "b3.wlwwlw", &param->rw_andx,
 266  317                      &sr->smb_fid, &off_low, &maxcnt_low, &mincnt, &maxcnt_high,
 267  318                      &remcnt);
 268  319  
 269  320                  param->rw_offset = (uint64_t)off_low;
 270  321                  param->rw_count = (uint32_t)maxcnt_low;
 271  322          }
 272  323  
 273  324          param->rw_mincnt = 0;
 274  325  
 275      -        DTRACE_SMB_2(op__ReadX__start, smb_request_t *, sr,
 276      -            smb_rw_param_t *, param);
      326 +        DTRACE_SMB_1(op__ReadX__start, smb_request_t *, sr); /* arg.rw */
 277  327  
 278  328          return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
 279  329  }
 280  330  
 281  331  void
 282  332  smb_post_read_andx(smb_request_t *sr)
 283  333  {
 284      -        DTRACE_SMB_2(op__ReadX__done, smb_request_t *, sr,
 285      -            smb_rw_param_t *, sr->arg.rw);
      334 +        DTRACE_SMB_1(op__ReadX__done, smb_request_t *, sr); /* arg.rw */
 286  335  
 287  336          kmem_free(sr->arg.rw, sizeof (smb_rw_param_t));
 288  337  }
 289  338  
 290  339  smb_sdrc_t
 291  340  smb_com_read_andx(smb_request_t *sr)
 292  341  {
 293  342          smb_rw_param_t *param = sr->arg.rw;
 294  343          uint16_t datalen_high;
 295  344          uint16_t datalen_low;
↓ open down ↓ 169 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX