Lines Matching refs:ses

290  * Resolve hostname and set ip addr in tcp ses. Useful for hostnames that may
394 struct cifs_ses *ses;
457 ses = list_entry(tmp, struct cifs_ses, smb_ses_list);
458 ses->need_reconnect = true;
459 list_for_each(tmp2, &ses->tcon_list) {
463 if (ses->tcon_ipc)
464 ses->tcon_ipc->need_reconnect = true;
2469 * Skip ses channels since they're only handled in lower layers
2680 static int match_session(struct cifs_ses *ses, struct smb_vol *vol)
2683 vol->sectype != ses->sectype)
2690 if (ses->chan_max < vol->max_channels)
2693 switch (ses->sectype) {
2695 if (!uid_eq(vol->cred_uid, ses->cred_uid))
2700 if (ses->user_name == NULL) {
2707 if (strncmp(ses->user_name,
2712 ses->password != NULL &&
2713 strncmp(ses->password,
2728 cifs_setup_ipc(struct cifs_ses *ses, struct smb_vol *volume_info)
2735 struct TCP_Server_Info *server = ses->server;
2761 tcon->ses = ses;
2764 rc = server->ops->tree_connect(xid, ses, unc, tcon, nls_codepage);
2775 ses->tcon_ipc = tcon;
2787 cifs_free_ipc(struct cifs_ses *ses)
2790 struct cifs_tcon *tcon = ses->tcon_ipc;
2795 if (ses->server->ops->tree_disconnect) {
2797 rc = ses->server->ops->tree_disconnect(xid, tcon);
2805 ses->tcon_ipc = NULL;
2812 struct cifs_ses *ses;
2815 list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) {
2816 if (ses->status == CifsExiting)
2818 if (!match_session(ses, vol))
2820 ++ses->ses_count;
2822 return ses;
2828 void cifs_put_smb_ses(struct cifs_ses *ses)
2831 struct TCP_Server_Info *server = ses->server;
2833 cifs_dbg(FYI, "%s: ses_count=%d\n", __func__, ses->ses_count);
2836 if (ses->status == CifsExiting) {
2840 if (--ses->ses_count > 0) {
2847 if (ses->status == CifsGood)
2848 ses->status = CifsExiting;
2851 cifs_free_ipc(ses);
2853 if (ses->status == CifsExiting && server->ops->logoff) {
2855 rc = server->ops->logoff(xid, ses);
2863 list_del_init(&ses->smb_ses_list);
2867 if (ses->chan_count > 1) {
2870 for (i = 1; i < ses->chan_count; i++)
2871 cifs_put_tcp_session(ses->chans[i].server, 0);
2874 sesInfoFree(ses);
2885 cifs_set_cifscreds(struct smb_vol *vol, struct cifs_ses *ses)
2893 struct TCP_Server_Info *server = ses->server;
2922 if (!ses->domainName) {
2929 sprintf(desc, "cifs:d:%s", ses->domainName);
2998 if (is_domain && ses->domainName) {
2999 vol->domainname = kstrndup(ses->domainName,
3000 strlen(ses->domainName),
3025 struct cifs_ses *ses __attribute__((unused)))
3043 struct cifs_ses *ses;
3049 ses = cifs_find_smb_ses(server, volume_info);
3050 if (ses) {
3052 ses->status);
3054 mutex_lock(&ses->session_mutex);
3055 rc = cifs_negotiate_protocol(xid, ses);
3057 mutex_unlock(&ses->session_mutex);
3058 /* problem -- put our ses reference */
3059 cifs_put_smb_ses(ses);
3063 if (ses->need_reconnect) {
3065 rc = cifs_setup_session(xid, ses,
3068 mutex_unlock(&ses->session_mutex);
3070 cifs_put_smb_ses(ses);
3075 mutex_unlock(&ses->session_mutex);
3077 /* existing SMB ses has a server reference already */
3080 return ses;
3086 ses = sesInfoAlloc();
3087 if (ses == NULL)
3091 ses->server = server;
3093 sprintf(ses->serverName, "%pI6", &addr6->sin6_addr);
3095 sprintf(ses->serverName, "%pI4", &addr->sin_addr);
3098 ses->user_name = kstrdup(volume_info->username, GFP_KERNEL);
3099 if (!ses->user_name)
3105 ses->password = kstrdup(volume_info->password, GFP_KERNEL);
3106 if (!ses->password)
3110 ses->domainName = kstrdup(volume_info->domainname, GFP_KERNEL);
3111 if (!ses->domainName)
3115 ses->domainAuto = volume_info->domainauto;
3116 ses->cred_uid = volume_info->cred_uid;
3117 ses->linux_uid = volume_info->linux_uid;
3119 ses->sectype = volume_info->sectype;
3120 ses->sign = volume_info->sign;
3121 mutex_lock(&ses->session_mutex);
3124 ses->chans[0].server = server;
3125 ses->chan_count = 1;
3126 ses->chan_max = volume_info->multichannel ? volume_info->max_channels:1;
3128 rc = cifs_negotiate_protocol(xid, ses);
3130 rc = cifs_setup_session(xid, ses, volume_info->local_nls);
3133 memcpy(ses->chans[0].signkey, ses->smb3signingkey,
3134 sizeof(ses->smb3signingkey));
3136 mutex_unlock(&ses->session_mutex);
3142 list_add(&ses->smb_ses_list, &server->smb_ses_list);
3147 cifs_setup_ipc(ses, volume_info);
3149 return ses;
3152 sesInfoFree(ses);
3177 cifs_find_tcon(struct cifs_ses *ses, struct smb_vol *volume_info)
3183 list_for_each(tmp, &ses->tcon_list) {
3203 struct cifs_ses *ses;
3212 ses = tcon->ses;
3224 if (ses->server->ops->tree_disconnect)
3225 ses->server->ops->tree_disconnect(xid, tcon);
3230 cifs_put_smb_ses(ses);
3234 * cifs_get_tcon - get a tcon matching @volume_info data from @ses
3237 * - ses refcount is the number of tcon using the session.
3240 * we already got a session reference (ses refcount +1).
3250 * identical ses refcount (no new tcon). Because of (1) we need to
3251 * decrement the ses refcount.
3254 cifs_get_tcon(struct cifs_ses *ses, struct smb_vol *volume_info)
3259 tcon = cifs_find_tcon(ses, volume_info);
3263 * decrement extra ses reference gotten by caller (case b)
3266 cifs_put_smb_ses(ses);
3270 if (!ses->server->ops->tree_connect) {
3282 if (ses->server->vals->protocol_id == 0) {
3292 if (ses->server->vals->protocol_id == 0) {
3301 tcon->ses = ses;
3311 if (ses->server->vals->protocol_id == 0) {
3316 } else if (tcon->ses->server->capabilities &
3327 if (ses->server->posix_ext_supported) {
3342 rc = ses->server->ops->tree_connect(xid, ses, volume_info->UNC, tcon,
3352 if (ses->server->vals->protocol_id == 0) {
3357 } else if (ses->server->capabilities &
3367 && (ses->server->capabilities & SMB2_GLOBAL_CAP_PERSISTENT_HANDLES)
3372 if (ses->server->vals->protocol_id == 0) {
3390 if (ses->server->vals->protocol_id == 0) {
3406 if (ses->server->capabilities & SMB2_GLOBAL_CAP_DIRECTORY_LEASING)
3415 list_add(&tcon->tcon_list, &ses->tcon_list);
3513 struct cifs_ses *ses;
3527 ses = tcon->ses;
3528 tcp_srv = ses->server;
3533 !match_session(ses, volume_info) ||
4064 struct cifs_ses *ses, struct cifs_tcon *tcon)
4070 else if (ses)
4071 cifs_put_smb_ses(ses);
4078 /* Get connections for tcp, ses and tcon */
4086 struct cifs_ses *ses;
4105 ses = cifs_get_smb_ses(server, vol);
4106 if (IS_ERR(ses)) {
4107 rc = PTR_ERR(ses);
4111 *nses = ses;
4113 if ((vol->persistent == true) && (!(ses->server->capabilities &
4120 tcon = cifs_get_tcon(ses, vol);
4133 if (cap_unix(tcon->ses)) {
4139 if ((tcon->ses->server->tcpStatus == CifsNeedReconnect) &&
4166 static int mount_setup_tlink(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses,
4176 tlink->tl_uid = ses->linux_uid;
4240 expand_dfs_referral(const unsigned int xid, struct cifs_ses *ses,
4255 rc = dfs_cache_find(xid, ses, cifs_sb->local_nls, cifs_remap(cifs_sb),
4320 struct TCP_Server_Info **server, struct cifs_ses **ses,
4354 mount_put_conns(cifs_sb, *xid, *server, *ses, *tcon);
4355 rc = mount_get_conns(&fake_vol, cifs_sb, xid, server, ses,
4357 if (!rc || (*server && *ses)) {
4371 struct TCP_Server_Info **server, struct cifs_ses **ses,
4391 rc = setup_dfs_tgt_conn(path, full_path, tgt_it, cifs_sb, vol, xid, server, ses,
4393 if (!rc || (*server && *ses))
4401 rc = dfs_cache_update_tgthint(*xid, root_ses ? root_ses : *ses,
4563 static void set_root_ses(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses,
4566 if (ses) {
4568 ses->ses_count++;
4569 if (ses->tcon_ipc)
4570 ses->tcon_ipc->remap = cifs_remap(cifs_sb);
4573 *root_ses = ses;
4576 static void put_root_ses(struct cifs_ses *ses)
4578 if (ses)
4579 cifs_put_smb_ses(ses);
4658 struct cifs_ses *ses = NULL, *root_ses = NULL;
4665 rc = mount_get_conns(vol, cifs_sb, &xid, &server, &ses, &tcon);
4673 if (dfs_cache_find(xid, ses, cifs_sb->local_nls, cifs_remap(cifs_sb), vol->UNC + 1, NULL,
4699 set_root_ses(cifs_sb, ses, &root_ses);
4716 mount_put_conns(cifs_sb, xid, server, ses, tcon);
4717 rc = mount_get_conns(vol, cifs_sb, &xid, &server, &ses, &tcon);
4719 if (rc && !server && !ses) {
4722 &server, &ses, &tcon);
4724 if (rc == -EACCES || rc == -EOPNOTSUPP || !server || !ses)
4731 set_root_ses(cifs_sb, ses, &root_ses);
4786 cifs_try_adding_channels(ses);
4787 return mount_setup_tlink(cifs_sb, ses, tcon);
4795 mount_put_conns(cifs_sb, xid, server, ses, tcon);
4803 struct cifs_ses *ses;
4807 rc = mount_get_conns(vol, cifs_sb, &xid, &server, &ses, &tcon);
4821 return mount_setup_tlink(cifs_sb, ses, tcon);
4824 mount_put_conns(cifs_sb, xid, server, ses, tcon);
4833 CIFSTCon(const unsigned int xid, struct cifs_ses *ses,
4846 if (ses == NULL)
4858 smb_buffer->Mid = get_next_mid(ses->server);
4859 smb_buffer->Uid = ses->Suid;
4866 if (tcon->pipe || (ses->server->sec_mode & SECMODE_USER)) {
4881 (ses->sectype == LANMAN))
4882 calc_lanman_hash(tcon->password, ses->server->cryptkey,
4883 ses->server->sec_mode &
4888 rc = SMBNTencrypt(tcon->password, ses->server->cryptkey,
4898 if (ses->capabilities & CAP_UNICODE) {
4905 if (ses->server->sign)
4908 if (ses->capabilities & CAP_STATUS32) {
4911 if (ses->capabilities & CAP_DFS) {
4914 if (ses->capabilities & CAP_UNICODE) {
4933 rc = SendReceive(xid, ses, smb_buffer, smb_buffer_response, &length,
5030 cifs_negotiate_protocol(const unsigned int xid, struct cifs_ses *ses)
5033 struct TCP_Server_Info *server = cifs_ses_server(ses);
5042 rc = server->ops->negotiate(xid, ses);
5056 cifs_setup_session(const unsigned int xid, struct cifs_ses *ses,
5060 struct TCP_Server_Info *server = cifs_ses_server(ses);
5062 if (!ses->binding) {
5063 ses->capabilities = server->capabilities;
5065 ses->capabilities &= (~server->vals->cap_unix);
5067 if (ses->auth_key.response) {
5069 ses->auth_key.response);
5070 kfree(ses->auth_key.response);
5071 ses->auth_key.response = NULL;
5072 ses->auth_key.len = 0;
5080 rc = server->ops->sess_setup(xid, ses, nls_info);
5089 cifs_set_vol_auth(struct smb_vol *vol, struct cifs_ses *ses)
5091 vol->sectype = ses->sectype;
5097 return cifs_set_cifscreds(vol, ses);
5105 struct cifs_ses *ses;
5127 vol_info->sectype = master_tcon->ses->sectype;
5128 vol_info->sign = master_tcon->ses->sign;
5131 rc = cifs_set_vol_auth(vol_info, master_tcon->ses);
5139 ++master_tcon->ses->server->srv_count;
5142 ses = cifs_get_smb_ses(master_tcon->ses->server, vol_info);
5143 if (IS_ERR(ses)) {
5144 tcon = (struct cifs_tcon *)ses;
5145 cifs_put_tcp_session(master_tcon->ses->server, 0);
5149 tcon = cifs_get_tcon(ses, vol_info);
5151 cifs_put_smb_ses(ses);
5155 if (cap_unix(ses))
5353 struct TCP_Server_Info *server = tcon->ses->server;
5374 rc = ops->tree_connect(xid, tcon->ses, tree, tcon, nlsc);
5376 rc = ops->tree_connect(xid, tcon->ses, tcon->treeName, tcon, nlsc);
5422 rc = ops->tree_connect(xid, tcon->ses, tree, tcon, nlsc);
5425 rc = ops->tree_connect(xid, tcon->ses, tree, tcon, nlsc);
5453 const struct smb_version_operations *ops = tcon->ses->server->ops;
5455 return ops->tree_connect(xid, tcon->ses, tcon->treeName, tcon, nlsc);