Print this page
9500 HP scanner needs smaller SMB2 rwsize
@@ -48,10 +48,19 @@
uint32_t smb2_tcp_bufsize = (1<<22); /* 4MB */
uint32_t smb2_max_rwsize = (1<<20); /* 1MB */
uint32_t smb2_max_trans = (1<<16); /* 64KB */
/*
+ * With clients (e.g. HP scanners) that don't advertise SMB2_CAP_LARGE_MTU
+ * (including all clients using dialect < SMB 2.1), use a "conservative" value
+ * for max r/w size because some older clients misbehave with larger values.
+ * 64KB is recommended in the [MS-SMB2] spec. (3.3.5.3.1 SMB 2.1 or SMB 3.x
+ * Support) as the minimum so we'll use that.
+ */
+uint32_t smb2_old_rwsize = (1<<16); /* 64KB */
+
+/*
* List of all SMB2 versions we implement. Note that the
* highest version we support may be limited by the
* _cfg.skc_max_protocol setting.
*/
static uint16_t smb2_versions[] = {
@@ -247,10 +256,11 @@
smb2_negotiate_common(smb_request_t *sr, uint16_t version)
{
timestruc_t boot_tv, now_tv;
smb_session_t *s = sr->session;
int rc;
+ uint32_t max_rwsize;
uint16_t secmode;
sr->smb2_status = 0;
/*
@@ -295,10 +305,18 @@
smb2sr_put_error(sr, sr->smb2_status);
smb2_send_reply(sr);
return (-1); /* will drop */
}
+ /*
+ * See notes above smb2_max_rwsize, smb2_old_rwsize
+ */
+ if (s->capabilities & SMB2_CAP_LARGE_MTU)
+ max_rwsize = smb2_max_rwsize;
+ else
+ max_rwsize = smb2_old_rwsize;
+
rc = smb_mbc_encodef(
&sr->reply,
"wwww#cllllTTwwl#c",
65, /* StructSize */ /* w */
s->secmode, /* w */
@@ -306,12 +324,12 @@
0, /* reserved */ /* w */
UUID_LEN, /* # */
&s->s_cfg.skc_machine_uuid, /* c */
smb2srv_capabilities, /* l */
smb2_max_trans, /* l */
- smb2_max_rwsize, /* l */
- smb2_max_rwsize, /* l */
+ max_rwsize, /* l */
+ max_rwsize, /* l */
&now_tv, /* T */
&boot_tv, /* T */
128, /* SecBufOff */ /* w */
sr->sr_cfg->skc_negtok_len, /* w */
0, /* reserved */ /* l */