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
*** 59,79 ****
param->rw_count = (uint32_t)count;
param->rw_offset = (uint64_t)off;
param->rw_vdb.vdb_uio.uio_loffset = (offset_t)param->rw_offset;
! DTRACE_SMB_2(op__Write__start, smb_request_t *, sr,
! smb_rw_param_t *, param);
return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
}
void
smb_post_write(smb_request_t *sr)
{
! DTRACE_SMB_2(op__Write__done, smb_request_t *, sr,
! smb_rw_param_t *, sr->arg.rw);
kmem_free(sr->arg.rw, sizeof (smb_rw_param_t));
}
smb_sdrc_t
--- 59,77 ----
param->rw_count = (uint32_t)count;
param->rw_offset = (uint64_t)off;
param->rw_vdb.vdb_uio.uio_loffset = (offset_t)param->rw_offset;
! DTRACE_SMB_1(op__Write__start, smb_request_t *, sr); /* arg.rw */
return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
}
void
smb_post_write(smb_request_t *sr)
{
! DTRACE_SMB_1(op__Write__done, smb_request_t *, sr); /* arg.rw */
kmem_free(sr->arg.rw, sizeof (smb_rw_param_t));
}
smb_sdrc_t
*** 149,169 ****
}
param->rw_count = (uint32_t)count;
param->rw_offset = (uint64_t)off;
! DTRACE_SMB_2(op__WriteAndClose__start, smb_request_t *, sr,
! smb_rw_param_t *, param);
return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
}
void
smb_post_write_and_close(smb_request_t *sr)
{
! DTRACE_SMB_2(op__WriteAndClose__done, smb_request_t *, sr,
! smb_rw_param_t *, sr->arg.rw);
kmem_free(sr->arg.rw, sizeof (smb_rw_param_t));
}
smb_sdrc_t
--- 147,165 ----
}
param->rw_count = (uint32_t)count;
param->rw_offset = (uint64_t)off;
! DTRACE_SMB_1(op__WriteAndClose__start, smb_request_t *, sr); /* arg.rw */
return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
}
void
smb_post_write_and_close(smb_request_t *sr)
{
! DTRACE_SMB_1(op__WriteAndClose__done, smb_request_t *, sr); /* arg.rw */
kmem_free(sr->arg.rw, sizeof (smb_rw_param_t));
}
smb_sdrc_t
*** 247,267 ****
rc = smbsr_decode_vwv(sr, "wwlw", &sr->smb_fid, &count, &off, &remcnt);
param->rw_count = (uint32_t)count;
param->rw_offset = (uint64_t)off;
! DTRACE_SMB_2(op__WriteAndUnlock__start, smb_request_t *, sr,
! smb_rw_param_t *, param);
return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
}
void
smb_post_write_and_unlock(smb_request_t *sr)
{
! DTRACE_SMB_2(op__WriteAndUnlock__done, smb_request_t *, sr,
! smb_rw_param_t *, sr->arg.rw);
kmem_free(sr->arg.rw, sizeof (smb_rw_param_t));
}
smb_sdrc_t
--- 243,261 ----
rc = smbsr_decode_vwv(sr, "wwlw", &sr->smb_fid, &count, &off, &remcnt);
param->rw_count = (uint32_t)count;
param->rw_offset = (uint64_t)off;
! DTRACE_SMB_1(op__WriteAndUnlock__start, smb_request_t *, sr); /* arg.rw */
return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
}
void
smb_post_write_and_unlock(smb_request_t *sr)
{
! DTRACE_SMB_1(op__WriteAndUnlock__done, smb_request_t *, sr); /* arg.rw */
kmem_free(sr->arg.rw, sizeof (smb_rw_param_t));
}
smb_sdrc_t
*** 323,332 ****
--- 317,386 ----
(uint16_t)param->rw_count, 0);
return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
}
/*
+ * The SMB_COM_WRITE_RAW protocol was a negotiated option introduced in
+ * SMB Core Plus to maximize performance when writing a large block
+ * of data to a server. It's obsolete and no longer supported.
+ *
+ * We keep a handler for it so the dtrace provider can see if
+ * the client tried to use this command.
+ */
+ smb_sdrc_t
+ smb_pre_write_raw(smb_request_t *sr)
+ {
+ smb_rw_param_t *param;
+ uint32_t off_low;
+ uint32_t timeout;
+ uint32_t off_high;
+ uint16_t datalen;
+ uint16_t total;
+ int rc;
+
+ param = kmem_zalloc(sizeof (smb_rw_param_t), KM_SLEEP);
+ sr->arg.rw = param;
+
+ if (sr->smb_wct == 12) {
+ rc = smbsr_decode_vwv(sr, "ww2.llw4.ww", &sr->smb_fid, &total,
+ &off_low, &timeout, ¶m->rw_mode, &datalen,
+ ¶m->rw_dsoff);
+
+ param->rw_offset = (uint64_t)off_low;
+ } else {
+ rc = smbsr_decode_vwv(sr, "ww2.llw4.wwl", &sr->smb_fid, &total,
+ &off_low, &timeout, ¶m->rw_mode, &datalen,
+ ¶m->rw_dsoff, &off_high);
+
+ param->rw_offset = ((uint64_t)off_high << 32) | off_low;
+ }
+
+ param->rw_count = (uint32_t)datalen;
+ param->rw_total = (uint32_t)total;
+
+ DTRACE_SMB_1(op__WriteRaw__start, smb_request_t *, sr); /* arg.rw */
+
+ return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
+ }
+
+ void
+ smb_post_write_raw(smb_request_t *sr)
+ {
+ DTRACE_SMB_1(op__WriteRaw__done, smb_request_t *, sr); /* arg.rw */
+
+ kmem_free(sr->arg.rw, sizeof (smb_rw_param_t));
+ }
+
+ smb_sdrc_t
+ smb_com_write_raw(struct smb_request *sr)
+ {
+ smbsr_error(sr, NT_STATUS_NOT_SUPPORTED, ERRDOS,
+ ERROR_NOT_SUPPORTED);
+ return (SDRC_ERROR);
+ }
+
+ /*
* Write bytes to a file (SMB Core). This request was extended in
* LM 0.12 to support 64-bit offsets, indicated by sending a wct of
* 14, instead of 12, and including additional offset information.
*
* A ByteCount of 0 does not truncate the file - use SMB_COM_WRITE
*** 385,405 ****
*/
if ((sr->session->capabilities & CAP_LARGE_WRITEX) != 0 ||
(sr->smb_data.max_bytes > (sr->smb_data.chain_offset + 0xFFFF)))
param->rw_count |= ((uint32_t)datalen_high << 16);
! DTRACE_SMB_2(op__WriteX__start, smb_request_t *, sr,
! smb_rw_param_t *, param);
return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
}
void
smb_post_write_andx(smb_request_t *sr)
{
! DTRACE_SMB_2(op__WriteX__done, smb_request_t *, sr,
! smb_rw_param_t *, sr->arg.rw);
kmem_free(sr->arg.rw, sizeof (smb_rw_param_t));
}
smb_sdrc_t
--- 439,457 ----
*/
if ((sr->session->capabilities & CAP_LARGE_WRITEX) != 0 ||
(sr->smb_data.max_bytes > (sr->smb_data.chain_offset + 0xFFFF)))
param->rw_count |= ((uint32_t)datalen_high << 16);
! DTRACE_SMB_1(op__WriteX__start, smb_request_t *, sr); /* arg.rw */
return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
}
void
smb_post_write_andx(smb_request_t *sr)
{
! DTRACE_SMB_1(op__WriteX__done, smb_request_t *, sr); /* arg.rw */
kmem_free(sr->arg.rw, sizeof (smb_rw_param_t));
}
smb_sdrc_t