Skip to content

Commit 4e456b3

Browse files
sprasad-microsoftsmfrench
authored andcommitted
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. This also contains the fix for a build issue identified by Intel bot. Reported-by: kernel test robot <lkp@intel.com> Signed-off-by: Shyam Prasad N <sprasad@microsoft.com> Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz> Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com> CC: <stable@vger.kernel.org> # 5.11+ Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent e49d033 commit 4e456b3

3 files changed

Lines changed: 20 additions & 5 deletions

File tree

fs/cifs/Kconfig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ config CIFS
1818
select CRYPTO_AES
1919
select CRYPTO_LIB_DES
2020
select KEYS
21+
select DNS_RESOLVER
2122
help
2223
This is the client VFS module for the SMB3 family of NAS protocols,
2324
(including support for the most recent, most secure dialect SMB3.1.1)
@@ -112,7 +113,6 @@ config CIFS_WEAK_PW_HASH
112113
config CIFS_UPCALL
113114
bool "Kerberos/SPNEGO advanced session setup"
114115
depends on CIFS
115-
select DNS_RESOLVER
116116
help
117117
Enables an upcall mechanism for CIFS which accesses userspace helper
118118
utilities to provide SPNEGO packaged (RFC 4178) Kerberos tickets
@@ -179,7 +179,6 @@ config CIFS_DEBUG_DUMP_KEYS
179179
config CIFS_DFS_UPCALL
180180
bool "DFS feature support"
181181
depends on CIFS
182-
select DNS_RESOLVER
183182
help
184183
Distributed File System (DFS) support is used to access shares
185184
transparently in an enterprise name space, even if the share

fs/cifs/Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ cifs-y := trace.o cifsfs.o cifssmb.o cifs_debug.o connect.o dir.o file.o \
1010
cifs_unicode.o nterr.o cifsencrypt.o \
1111
readdir.o ioctl.o sess.o export.o smb1ops.o unc.o winucase.o \
1212
smb2ops.o smb2maperror.o smb2transport.o \
13-
smb2misc.o smb2pdu.o smb2inode.o smb2file.o cifsacl.o fs_context.o
13+
smb2misc.o smb2pdu.o smb2inode.o smb2file.o cifsacl.o fs_context.o \
14+
dns_resolve.o
1415

1516
cifs-$(CONFIG_CIFS_XATTR) += xattr.o
1617

1718
cifs-$(CONFIG_CIFS_UPCALL) += cifs_spnego.o
1819

19-
cifs-$(CONFIG_CIFS_DFS_UPCALL) += dns_resolve.o cifs_dfs_ref.o dfs_cache.o
20+
cifs-$(CONFIG_CIFS_DFS_UPCALL) += cifs_dfs_ref.o dfs_cache.o
2021

2122
cifs-$(CONFIG_CIFS_SWN_UPCALL) += netlink.o cifs_swn.o
2223

fs/cifs/connect.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ static void cifs_prune_tlinks(struct work_struct *work);
8787
*
8888
* This should be called with server->srv_mutex held.
8989
*/
90-
#ifdef CONFIG_CIFS_DFS_UPCALL
9190
static int reconn_set_ipaddr_from_hostname(struct TCP_Server_Info *server)
9291
{
9392
int rc;
@@ -124,6 +123,7 @@ static int reconn_set_ipaddr_from_hostname(struct TCP_Server_Info *server)
124123
return !rc ? -1 : 0;
125124
}
126125

126+
#ifdef CONFIG_CIFS_DFS_UPCALL
127127
/* These functions must be called with server->srv_mutex held */
128128
static void reconn_set_next_dfs_target(struct TCP_Server_Info *server,
129129
struct cifs_sb_info *cifs_sb,
@@ -321,14 +321,29 @@ cifs_reconnect(struct TCP_Server_Info *server)
321321
#endif
322322

323323
#ifdef CONFIG_CIFS_DFS_UPCALL
324+
if (cifs_sb && cifs_sb->origin_fullpath)
324325
/*
325326
* Set up next DFS target server (if any) for reconnect. If DFS
326327
* feature is disabled, then we will retry last server we
327328
* connected to before.
328329
*/
329330
reconn_set_next_dfs_target(server, cifs_sb, &tgt_list, &tgt_it);
331+
else {
332+
#endif
333+
/*
334+
* Resolve the hostname again to make sure that IP address is up-to-date.
335+
*/
336+
rc = reconn_set_ipaddr_from_hostname(server);
337+
if (rc) {
338+
cifs_dbg(FYI, "%s: failed to resolve hostname: %d\n",
339+
__func__, rc);
340+
}
341+
342+
#ifdef CONFIG_CIFS_DFS_UPCALL
343+
}
330344
#endif
331345

346+
332347
#ifdef CONFIG_CIFS_SWN_UPCALL
333348
}
334349
#endif

0 commit comments

Comments
 (0)