[linux-cifs-client] [PATCH] Missing VC number

Yehuda Sadeh-Weinraub yehudas at expand.com
Mon May 14 12:59:16 GMT 2007


It appears that the VC number is not set anymore. This is a problem when 
working against several types of file servers (not samba). When trying 
to make more than one connection from a single machine, windows file 
servers (don't know what versions) will disconnect the old connections, 
keeping only one connection alive. E.g.:
1. Connect to a win2k share, using smbclient
2. Mount win2k share using the linux cifs module
The smbclient will be disconnected after step 2.

The following patch should fix the problem.

Yehuda

Index: cifspdu.h
===================================================================
--- cifspdu.h   (revision 111)
+++ cifspdu.h   (working copy)
@@ -494,6 +494,8 @@
#define CAP_COMPRESSED_DATA    0x40000000
#define CAP_EXTENDED_SECURITY  0x80000000

+#define VCNUMBER 1
+
typedef union smb_com_session_setup_andx {
       struct {                /* request format */
               struct smb_hdr hdr;     /* wct = 12 */
Index: sess.c
===================================================================
--- sess.c      (revision 111)
+++ sess.c      (working copy)
@@ -42,6 +42,7 @@
       pSMB->req.AndXCommand = 0xFF;
       pSMB->req.MaxBufferSize = cpu_to_le16(ses->server->maxBuf);
       pSMB->req.MaxMpxCount = cpu_to_le16(ses->server->maxReq);
+       pSMB->req.VcNumber = VCNUMBER;

       /* Now no need to set SMBFLG_CASELESS or obsolete CANONICAL PATH */

@@ -380,6 +381,7 @@
               /* no capabilities flags in old lanman negotiation */

               pSMB->old_req.PasswordLength = cpu_to_le16(CIFS_SESS_KEY_SIZE);
+               pSMB->old_req.VcNumber = VCNUMBER;
               /* BB calculate hash with password */
               /* and copy into bcc */

@@ -409,6 +411,7 @@
                       cpu_to_le16(CIFS_SESS_KEY_SIZE);
               pSMB->req_no_secext.CaseSensitivePasswordLength =
                       cpu_to_le16(CIFS_SESS_KEY_SIZE);
+               pSMB->req_no_secext.VcNumber = VCNUMBER;

               /* calculate session key */
               SMBNTencrypt(ses->password, ses->server->cryptKey,
@@ -445,6 +448,7 @@
                       return -ENOMEM;
               }

+               pSMB->req_no_secext.VcNumber = VCNUMBER;
               pSMB->req_no_secext.Capabilities = cpu_to_le32(capabilities);

               /* LM2 password would be here if we supported it */
@@ -479,6 +483,7 @@
               pSMB->req.hdr.Flags2 |= SMBFLG2_EXT_SEC;
               capabilities |= CAP_EXTENDED_SECURITY;
               pSMB->req.Capabilities = cpu_to_le32(capabilities);
+               pSMB->req.VcNumber = VCNUMBER;
               /* BB set password lengths */
       }

Index: connect.c
===================================================================
--- connect.c   (revision 111)
+++ connect.c   (working copy)
@@ -2146,6 +2146,7 @@
       pSMB->req_no_secext.AndXCommand = 0xFF;
       pSMB->req_no_secext.MaxBufferSize = cpu_to_le16(ses->server->maxBuf);
       pSMB->req_no_secext.MaxMpxCount = cpu_to_le16(ses->server->maxReq);
+       pSMB->req_no_secext.VcNumber = VCNUMBER;

       if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
               smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
@@ -2442,6 +2443,7 @@
       pSMB->req.AndXCommand = 0xFF;
       pSMB->req.MaxBufferSize = cpu_to_le16(ses->server->maxBuf);
       pSMB->req.MaxMpxCount = cpu_to_le16(ses->server->maxReq);
+       pSMB->req.VcNumber = VCNUMBER;

       if(ses->server->secMode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
               smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
@@ -2775,6 +2777,7 @@
       pSMB->req.AndXCommand = 0xFF;
       pSMB->req.MaxBufferSize = cpu_to_le16(ses->server->maxBuf);
       pSMB->req.MaxMpxCount = cpu_to_le16(ses->server->maxReq);
+       pSMB->req.VcNumber = VCNUMBER;

       pSMB->req.hdr.Uid = ses->Suid;







More information about the linux-cifs-client mailing list