smb3: do not log confusing message when server returns no network interfaces
authorSteve French <stfrench@microsoft.com>
Sat, 1 Oct 2022 16:44:08 +0000 (11:44 -0500)
committerSteve French <stfrench@microsoft.com>
Wed, 5 Oct 2022 22:40:41 +0000 (17:40 -0500)
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: <stable@vger.kernel.org>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifs/cifsproto.h
fs/cifs/connect.c
fs/cifs/smb2ops.c

index 3bc94bcc7177eb7471b35606e4961bfc554aa001..71386978858eb81866264983b335842493c17eb0 100644 (file)
@@ -639,7 +639,7 @@ cifs_chan_is_iface_active(struct cifs_ses *ses,
 int
 cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server);
 int
-SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon);
+SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon, bool in_mount);
 
 void extract_unc_hostname(const char *unc, const char **h, size_t *len);
 int copy_path_name(char *dst, const char *src);
index ad81d7d43eafbfb7a47585a33659927cc85b9041..93e59b3b36c73cde308db3c0ba053dd173016585 100644 (file)
@@ -155,7 +155,7 @@ static void smb2_query_server_interfaces(struct work_struct *work)
        /*
         * query server network interfaces, in case they change
         */
-       rc = SMB3_request_interfaces(0, tcon);
+       rc = SMB3_request_interfaces(0, tcon, false);
        if (rc) {
                cifs_dbg(FYI, "%s: failed to query server interfaces: %d\n",
                                __func__, rc);
index f590a9cb6a1a24c96121bfd599631546062ba382..10f9ef68e510c60dfa12e86c415fbfaf46567be5 100644 (file)
@@ -512,8 +512,7 @@ smb3_negotiate_rsize(struct cifs_tcon *tcon, struct smb3_fs_context *ctx)
 
 static int
 parse_server_interfaces(struct network_interface_info_ioctl_rsp *buf,
-                       size_t buf_len,
-                       struct cifs_ses *ses)
+                       size_t buf_len, struct cifs_ses *ses, bool in_mount)
 {
        struct network_interface_info_ioctl_rsp *p;
        struct sockaddr_in *addr4;
@@ -543,6 +542,20 @@ parse_server_interfaces(struct network_interface_info_ioctl_rsp *buf,
        }
        spin_unlock(&ses->iface_lock);
 
+       /*
+        * Samba server e.g. can return an empty interface list in some cases,
+        * which would only be a problem if we were requesting multichannel
+        */
+       if (bytes_left == 0) {
+               /* avoid spamming logs every 10 minutes, so log only in mount */
+               if ((ses->chan_max > 1) && in_mount)
+                       cifs_dbg(VFS,
+                                "empty network interface list returned by server %s\n",
+                                ses->server->hostname);
+               rc = -EINVAL;
+               goto out;
+       }
+
        while (bytes_left >= sizeof(*p)) {
                memset(&tmp_iface, 0, sizeof(tmp_iface));
                tmp_iface.speed = le64_to_cpu(p->LinkSpeed);
@@ -673,7 +686,7 @@ out:
 }
 
 int
-SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon)
+SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon, bool in_mount)
 {
        int rc;
        unsigned int ret_data_len = 0;
@@ -693,7 +706,7 @@ SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon)
                goto out;
        }
 
-       rc = parse_server_interfaces(out_buf, ret_data_len, ses);
+       rc = parse_server_interfaces(out_buf, ret_data_len, ses, in_mount);
        if (rc)
                goto out;
 
@@ -729,7 +742,7 @@ smb3_qfs_tcon(const unsigned int xid, struct cifs_tcon *tcon,
        if (rc)
                return;
 
-       SMB3_request_interfaces(xid, tcon);
+       SMB3_request_interfaces(xid, tcon, true /* called during  mount */);
 
        SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid,
                        FS_ATTRIBUTE_INFORMATION);