summaryrefslogtreecommitdiff
path: root/fs/cifs/netmisc.c
diff options
context:
space:
mode:
authorRoberto Bergantinos Corpas <rbergant@redhat.com>2020-07-03 11:29:32 +0200
committerSteve French <stfrench@microsoft.com>2020-08-02 18:00:25 -0500
commita3713ec3d775ff9da2e46f6652b23ff598c3ed36 (patch)
tree5c1fa23d25a7dac7423b5a42a53c2fa14329d9e2 /fs/cifs/netmisc.c
parent66a4bbc327e740c65b19a471fb9911f7f4b876fb (diff)
cifs`: handle ERRBaduid for SMB1
If server returns ERRBaduid but does not reset transport connection, we'll keep sending command with a non-valid UID for the server as long as transport is healthy, without actually recovering. This have been observed on the field. This patch adds ERRBaduid handling so that we set CifsNeedReconnect. map_and_check_smb_error() can be modified to extend use cases. Signed-off-by: Roberto Bergantinos Corpas <rbergant@redhat.com> Signed-off-by: Steve French <stfrench@microsoft.com> Reviewed-by: Ronnie Sahlberg <lsahlber@redhat.com>
Diffstat (limited to 'fs/cifs/netmisc.c')
-rw-r--r--fs/cifs/netmisc.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c
index b7ca4960d4ca..0e728aac67e9 100644
--- a/fs/cifs/netmisc.c
+++ b/fs/cifs/netmisc.c
@@ -881,6 +881,33 @@ map_smb_to_linux_error(char *buf, bool logErr)
return rc;
}
+int
+map_and_check_smb_error(struct mid_q_entry *mid, bool logErr)
+{
+ int rc;
+ struct smb_hdr *smb = (struct smb_hdr *)mid->resp_buf;
+
+ rc = map_smb_to_linux_error((char *)smb, logErr);
+ if (rc == -EACCES && !(smb->Flags2 & SMBFLG2_ERR_STATUS)) {
+ /* possible ERRBaduid */
+ __u8 class = smb->Status.DosError.ErrorClass;
+ __u16 code = le16_to_cpu(smb->Status.DosError.Error);
+
+ /* switch can be used to handle different errors */
+ if (class == ERRSRV && code == ERRbaduid) {
+ cifs_dbg(FYI, "Server returned 0x%x, reconnecting session...\n",
+ code);
+ spin_lock(&GlobalMid_Lock);
+ if (mid->server->tcpStatus != CifsExiting)
+ mid->server->tcpStatus = CifsNeedReconnect;
+ spin_unlock(&GlobalMid_Lock);
+ }
+ }
+
+ return rc;
+}
+
+
/*
* calculate the size of the SMB message based on the fixed header
* portion, the number of word parameters and the data portion of the message