Skip to content

Commit 4659f01

Browse files
author
Steve French
committed
smb3: do not log confusing message when server returns no network interfaces
Some servers can return an empty network interface list so, unless multichannel is requested, no need to log an error for this, and when multichannel is requested on mount but no interfaces, log something less confusing. For this case change parse_server_interfaces: malformed interface info to empty network interface list returned by server localhost Also do not relog this error every ten minutes (only log on mount, once) Cc: <[email protected]> Reviewed-by: Paulo Alcantara (SUSE) <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 3afdfb0 commit 4659f01

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

fs/cifs/cifsproto.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ cifs_chan_is_iface_active(struct cifs_ses *ses,
639639
int
640640
cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server);
641641
int
642-
SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon);
642+
SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon, bool in_mount);
643643

644644
void extract_unc_hostname(const char *unc, const char **h, size_t *len);
645645
int copy_path_name(char *dst, const char *src);

fs/cifs/connect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ static void smb2_query_server_interfaces(struct work_struct *work)
155155
/*
156156
* query server network interfaces, in case they change
157157
*/
158-
rc = SMB3_request_interfaces(0, tcon);
158+
rc = SMB3_request_interfaces(0, tcon, false);
159159
if (rc) {
160160
cifs_dbg(FYI, "%s: failed to query server interfaces: %d\n",
161161
__func__, rc);

fs/cifs/smb2ops.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,7 @@ smb3_negotiate_rsize(struct cifs_tcon *tcon, struct smb3_fs_context *ctx)
512512

513513
static int
514514
parse_server_interfaces(struct network_interface_info_ioctl_rsp *buf,
515-
size_t buf_len,
516-
struct cifs_ses *ses)
515+
size_t buf_len, struct cifs_ses *ses, bool in_mount)
517516
{
518517
struct network_interface_info_ioctl_rsp *p;
519518
struct sockaddr_in *addr4;
@@ -543,6 +542,20 @@ parse_server_interfaces(struct network_interface_info_ioctl_rsp *buf,
543542
}
544543
spin_unlock(&ses->iface_lock);
545544

545+
/*
546+
* Samba server e.g. can return an empty interface list in some cases,
547+
* which would only be a problem if we were requesting multichannel
548+
*/
549+
if (bytes_left == 0) {
550+
/* avoid spamming logs every 10 minutes, so log only in mount */
551+
if ((ses->chan_max > 1) && in_mount)
552+
cifs_dbg(VFS,
553+
"empty network interface list returned by server %s\n",
554+
ses->server->hostname);
555+
rc = -EINVAL;
556+
goto out;
557+
}
558+
546559
while (bytes_left >= sizeof(*p)) {
547560
memset(&tmp_iface, 0, sizeof(tmp_iface));
548561
tmp_iface.speed = le64_to_cpu(p->LinkSpeed);
@@ -673,7 +686,7 @@ parse_server_interfaces(struct network_interface_info_ioctl_rsp *buf,
673686
}
674687

675688
int
676-
SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon)
689+
SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon, bool in_mount)
677690
{
678691
int rc;
679692
unsigned int ret_data_len = 0;
@@ -693,7 +706,7 @@ SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon)
693706
goto out;
694707
}
695708

696-
rc = parse_server_interfaces(out_buf, ret_data_len, ses);
709+
rc = parse_server_interfaces(out_buf, ret_data_len, ses, in_mount);
697710
if (rc)
698711
goto out;
699712

@@ -729,7 +742,7 @@ smb3_qfs_tcon(const unsigned int xid, struct cifs_tcon *tcon,
729742
if (rc)
730743
return;
731744

732-
SMB3_request_interfaces(xid, tcon);
745+
SMB3_request_interfaces(xid, tcon, true /* called during mount */);
733746

734747
SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid,
735748
FS_ATTRIBUTE_INFORMATION);

0 commit comments

Comments
 (0)