All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cifs: On cifs_reconnect, resolve the hostname again.
@ 2021-04-05 15:33 Shyam Prasad N
  2021-04-05 15:54 ` Paulo Alcantara
  0 siblings, 1 reply; 10+ messages in thread
From: Shyam Prasad N @ 2021-04-05 15:33 UTC (permalink / raw)
  To: Steve French, Paulo Alcantara, CIFS

[-- Attachment #1: Type: text/plain, Size: 1236 bytes --]

Hi Steve,

Please consider the attached patch for performing the DNS query again
on reconnect.
This is important when connecting to Azure file shares. The UNC
generally contains the server name as a FQDN, and the IP address which
the name resolves to can change over time.

After our last conversation about this, I discovered that for the
non-DFS scenario, we never do DNS resolutions in cifs.ko, since
mount.cifs already resolves the name and passes the "addr=" arg during
mount.

Hi Paulo,

I noticed that you had a patch for this long back. But I don't see
that call happening in the latest code. Any idea why that was done?

========================
commit 28eb24ff75c5ac130eb326b3b4d0dcecfc0f427d
Author: Paulo Alcantara <paulo@paulo.ac>
Date:   Tue Nov 20 15:16:36 2018 -0200

    cifs: Always resolve hostname before reconnecting

    In case a hostname resolves to a different IP address (e.g. long
    running mounts), make sure to resolve it every time prior to calling
    generic_ip_connect() in reconnect.

    Suggested-by: Steve French <stfrench@microsoft.com>
    Signed-off-by: Paulo Alcantara <palcantara@suse.de>
    Signed-off-by: Steve French <stfrench@microsoft.com>
=========================

-- 
Regards,
Shyam

[-- Attachment #2: 0001-cifs-On-cifs_reconnect-resolve-the-hostname-again.patch --]
[-- Type: application/octet-stream, Size: 1393 bytes --]

From 289f7f0fa229ea181094821c309a2ba9358791a3 Mon Sep 17 00:00:00 2001
From: Shyam Prasad N <sprasad@microsoft.com>
Date: Wed, 31 Mar 2021 14:35:24 +0000
Subject: [PATCH] cifs: On cifs_reconnect, resolve the hostname again.

On cifs_reconnect, make sure that DNS resolution happens again.
It could be the cause of connection to go dead in the first place.

Signed-off-by: Shyam Prasad N <sprasad@microsoft.com>
---
 fs/cifs/connect.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index eec8a2052da2..3db3006bbb47 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -321,14 +321,29 @@ cifs_reconnect(struct TCP_Server_Info *server)
 #endif
 
 #ifdef CONFIG_CIFS_DFS_UPCALL
+		if (cifs_sb && cifs_sb->origin_fullpath)
 			/*
 			 * Set up next DFS target server (if any) for reconnect. If DFS
 			 * feature is disabled, then we will retry last server we
 			 * connected to before.
 			 */
 			reconn_set_next_dfs_target(server, cifs_sb, &tgt_list, &tgt_it);
+		else {
+#endif
+			/*
+			 * Resolve the hostname again to make sure that IP address is up-to-date.
+			 */
+			rc = reconn_set_ipaddr_from_hostname(server);
+			if (rc) {
+				cifs_dbg(FYI, "%s: failed to resolve hostname: %d\n",
+						__func__, rc);
+			}
+
+#ifdef CONFIG_CIFS_DFS_UPCALL
+		}
 #endif
 
+
 #ifdef CONFIG_CIFS_SWN_UPCALL
 		}
 #endif
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-04-08 10:51 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-05 15:33 [PATCH] cifs: On cifs_reconnect, resolve the hostname again Shyam Prasad N
2021-04-05 15:54 ` Paulo Alcantara
2021-04-05 16:06   ` Shyam Prasad N
2021-04-06 16:34     ` Pavel Shilovsky
2021-04-07  3:43       ` Steve French
2021-04-07 17:43         ` Shyam Prasad N
2021-04-07 19:00           ` Steve French
2021-04-08  2:25             ` Steve French
2021-04-08  8:41           ` Aurélien Aptel
2021-04-08 10:50             ` Shyam Prasad N

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.