2424#include "../smbfs_common/smb2pdu.h"
2525#include "smb2pdu.h"
2626
27- #define CIFS_MAGIC_NUMBER 0xFF534D42 /* the first four bytes of SMB PDUs */
28-
2927#define SMB_PATH_MAX 260
3028#define CIFS_PORT 445
3129#define RFC1001_PORT 139
@@ -113,7 +111,13 @@ enum statusEnum {
113111 CifsGood ,
114112 CifsExiting ,
115113 CifsNeedReconnect ,
116- CifsNeedNegotiate
114+ CifsNeedNegotiate ,
115+ CifsInNegotiate ,
116+ CifsNeedSessSetup ,
117+ CifsInSessSetup ,
118+ CifsNeedTcon ,
119+ CifsInTcon ,
120+ CifsInFilesInvalidate
117121};
118122
119123enum securityEnum {
@@ -263,13 +267,16 @@ struct smb_version_operations {
263267 /* check if we need to negotiate */
264268 bool (* need_neg )(struct TCP_Server_Info * );
265269 /* negotiate to the server */
266- int (* negotiate )(const unsigned int , struct cifs_ses * );
270+ int (* negotiate )(const unsigned int xid ,
271+ struct cifs_ses * ses ,
272+ struct TCP_Server_Info * server );
267273 /* set negotiated write size */
268274 unsigned int (* negotiate_wsize )(struct cifs_tcon * tcon , struct smb3_fs_context * ctx );
269275 /* set negotiated read size */
270276 unsigned int (* negotiate_rsize )(struct cifs_tcon * tcon , struct smb3_fs_context * ctx );
271277 /* setup smb sessionn */
272278 int (* sess_setup )(const unsigned int , struct cifs_ses * ,
279+ struct TCP_Server_Info * server ,
273280 const struct nls_table * );
274281 /* close smb session */
275282 int (* logoff )(const unsigned int , struct cifs_ses * );
@@ -414,7 +421,8 @@ struct smb_version_operations {
414421 void (* set_lease_key )(struct inode * , struct cifs_fid * );
415422 /* generate new lease key */
416423 void (* new_lease_key )(struct cifs_fid * );
417- int (* generate_signingkey )(struct cifs_ses * );
424+ int (* generate_signingkey )(struct cifs_ses * ses ,
425+ struct TCP_Server_Info * server );
418426 int (* calc_signature )(struct smb_rqst * , struct TCP_Server_Info * ,
419427 bool allocate_crypto );
420428 int (* set_integrity )(const unsigned int , struct cifs_tcon * tcon ,
@@ -582,7 +590,7 @@ struct TCP_Server_Info {
582590 char server_RFC1001_name [RFC1001_NAME_LEN_WITH_NULL ];
583591 struct smb_version_operations * ops ;
584592 struct smb_version_values * vals ;
585- /* updates to tcpStatus protected by GlobalMid_Lock */
593+ /* updates to tcpStatus protected by cifs_tcp_ses_lock */
586594 enum statusEnum tcpStatus ; /* what we think the status is */
587595 char * hostname ; /* hostname portion of UNC string */
588596 struct socket * ssocket ;
@@ -920,7 +928,7 @@ struct cifs_ses {
920928 struct mutex session_mutex ;
921929 struct TCP_Server_Info * server ; /* pointer to server info */
922930 int ses_count ; /* reference counter */
923- enum statusEnum status ; /* updates protected by GlobalMid_Lock */
931+ enum statusEnum status ; /* updates protected by cifs_tcp_ses_lock */
924932 unsigned overrideSecFlg ; /* if non-zero override global sec flags */
925933 char * serverOS ; /* name of operating system underlying server */
926934 char * serverNOS ; /* name of network operating system of server */
@@ -939,17 +947,13 @@ struct cifs_ses {
939947 struct ntlmssp_auth * ntlmssp ; /* ciphertext, flags, server challenge */
940948 enum securityEnum sectype ; /* what security flavor was specified? */
941949 bool sign ; /* is signing required? */
942- bool need_reconnect :1 ; /* connection reset, uid now invalid */
943950 bool domainAuto :1 ;
944- bool binding :1 ; /* are we binding the session? */
945951 __u16 session_flags ;
946952 __u8 smb3signingkey [SMB3_SIGN_KEY_SIZE ];
947953 __u8 smb3encryptionkey [SMB3_ENC_DEC_KEY_SIZE ];
948954 __u8 smb3decryptionkey [SMB3_ENC_DEC_KEY_SIZE ];
949955 __u8 preauth_sha_hash [SMB2_PREAUTH_HASH_SIZE ];
950956
951- __u8 binding_preauth_sha_hash [SMB2_PREAUTH_HASH_SIZE ];
952-
953957 /*
954958 * Network interfaces available on the server this session is
955959 * connected to.
@@ -969,45 +973,34 @@ struct cifs_ses {
969973 spinlock_t chan_lock ;
970974 /* ========= begin: protected by chan_lock ======== */
971975#define CIFS_MAX_CHANNELS 16
976+ #define CIFS_ALL_CHANNELS_SET (ses ) \
977+ ((1UL << (ses)->chan_count) - 1)
978+ #define CIFS_ALL_CHANS_NEED_RECONNECT (ses ) \
979+ ((ses)->chans_need_reconnect == CIFS_ALL_CHANNELS_SET(ses))
980+ #define CIFS_SET_ALL_CHANS_NEED_RECONNECT (ses ) \
981+ ((ses)->chans_need_reconnect = CIFS_ALL_CHANNELS_SET(ses))
982+ #define CIFS_CHAN_NEEDS_RECONNECT (ses , index ) \
983+ test_bit((index), &(ses)->chans_need_reconnect)
984+
972985 struct cifs_chan chans [CIFS_MAX_CHANNELS ];
973- struct cifs_chan * binding_chan ;
974986 size_t chan_count ;
975987 size_t chan_max ;
976988 atomic_t chan_seq ; /* round robin state */
989+
990+ /*
991+ * chans_need_reconnect is a bitmap indicating which of the channels
992+ * under this smb session needs to be reconnected.
993+ * If not multichannel session, only one bit will be used.
994+ *
995+ * We will ask for sess and tcon reconnection only if all the
996+ * channels are marked for needing reconnection. This will
997+ * enable the sessions on top to continue to live till any
998+ * of the channels below are active.
999+ */
1000+ unsigned long chans_need_reconnect ;
9771001 /* ========= end: protected by chan_lock ======== */
9781002};
9791003
980- /*
981- * When binding a new channel, we need to access the channel which isn't fully
982- * established yet.
983- */
984-
985- static inline
986- struct cifs_chan * cifs_ses_binding_channel (struct cifs_ses * ses )
987- {
988- if (ses -> binding )
989- return ses -> binding_chan ;
990- else
991- return NULL ;
992- }
993-
994- /*
995- * Returns the server pointer of the session. When binding a new
996- * channel this returns the last channel which isn't fully established
997- * yet.
998- *
999- * This function should be use for negprot/sess.setup codepaths. For
1000- * the other requests see cifs_pick_channel().
1001- */
1002- static inline
1003- struct TCP_Server_Info * cifs_ses_server (struct cifs_ses * ses )
1004- {
1005- if (ses -> binding )
1006- return ses -> binding_chan -> server ;
1007- else
1008- return ses -> server ;
1009- }
1010-
10111004static inline bool
10121005cap_unix (struct cifs_ses * ses )
10131006{
0 commit comments