From aa321b3cd36298fca4306c4e06284d250e998cf7 Mon Sep 17 00:00:00 2001 From: Dan McDonald Date: Mon, 30 Apr 2018 11:30:28 -0400 Subject: 9500 HP scanner needs smaller SMB2 rwsize Reviewed by: Yuri Pankov Reviewed by: Andy Fiddaman Reviewed by: Bill Sommerfeld Reviewed by: Toomas Soome Approved by: Gordon Ross --- usr/src/uts/common/fs/smbsrv/smb2_negotiate.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/usr/src/uts/common/fs/smbsrv/smb2_negotiate.c b/usr/src/uts/common/fs/smbsrv/smb2_negotiate.c index a0affa8a58..a4f827e756 100644 --- a/usr/src/uts/common/fs/smbsrv/smb2_negotiate.c +++ b/usr/src/uts/common/fs/smbsrv/smb2_negotiate.c @@ -49,6 +49,15 @@ 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 @@ -249,6 +258,7 @@ 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; @@ -297,6 +307,14 @@ smb2_negotiate_common(smb_request_t *sr, uint16_t version) 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", @@ -308,8 +326,8 @@ smb2_negotiate_common(smb_request_t *sr, uint16_t version) &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 */ -- cgit v1.2.3