Commit bbb9db5e authored by Shyam Prasad N's avatar Shyam Prasad N Committed by Steve French

cifs: avoid use of dstaddr as key for fscache client cookie

server->dstaddr can change when the DNS mapping for the
server hostname changes. But conn_id is a u64 counter
that is incremented each time a new TCP connection
is setup. So use only that as a key.
Signed-off-by: default avatarShyam Prasad N <sprasad@microsoft.com>
Reviewed-by: default avatarPaulo Alcantara (SUSE) <pc@cjr.nz>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 2adc8200
...@@ -16,14 +16,6 @@ ...@@ -16,14 +16,6 @@
* Key layout of CIFS server cache index object * Key layout of CIFS server cache index object
*/ */
struct cifs_server_key { struct cifs_server_key {
struct {
uint16_t family; /* address family */
__be16 port; /* IP port */
} hdr;
union {
struct in_addr ipv4_addr;
struct in6_addr ipv6_addr;
};
__u64 conn_id; __u64 conn_id;
} __packed; } __packed;
...@@ -32,11 +24,7 @@ struct cifs_server_key { ...@@ -32,11 +24,7 @@ struct cifs_server_key {
*/ */
void cifs_fscache_get_client_cookie(struct TCP_Server_Info *server) void cifs_fscache_get_client_cookie(struct TCP_Server_Info *server)
{ {
const struct sockaddr *sa = (struct sockaddr *) &server->dstaddr;
const struct sockaddr_in *addr = (struct sockaddr_in *) sa;
const struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *) sa;
struct cifs_server_key key; struct cifs_server_key key;
uint16_t key_len = sizeof(key.hdr);
/* /*
* Check if cookie was already initialized so don't reinitialize it. * Check if cookie was already initialized so don't reinitialize it.
...@@ -47,36 +35,12 @@ void cifs_fscache_get_client_cookie(struct TCP_Server_Info *server) ...@@ -47,36 +35,12 @@ void cifs_fscache_get_client_cookie(struct TCP_Server_Info *server)
return; return;
memset(&key, 0, sizeof(key)); memset(&key, 0, sizeof(key));
/*
* Should not be a problem as sin_family/sin6_family overlays
* sa_family field
*/
key.hdr.family = sa->sa_family;
switch (sa->sa_family) {
case AF_INET:
key.hdr.port = addr->sin_port;
key.ipv4_addr = addr->sin_addr;
key_len += sizeof(key.ipv4_addr);
break;
case AF_INET6:
key.hdr.port = addr6->sin6_port;
key.ipv6_addr = addr6->sin6_addr;
key_len += sizeof(key.ipv6_addr);
break;
default:
cifs_dbg(VFS, "Unknown network family '%d'\n", sa->sa_family);
server->fscache = NULL;
return;
}
key.conn_id = server->conn_id; key.conn_id = server->conn_id;
server->fscache = server->fscache =
fscache_acquire_cookie(cifs_fscache_netfs.primary_index, fscache_acquire_cookie(cifs_fscache_netfs.primary_index,
&cifs_fscache_server_index_def, &cifs_fscache_server_index_def,
&key, key_len, &key, sizeof(key),
NULL, 0, NULL, 0,
server, 0, true); server, 0, true);
cifs_dbg(FYI, "%s: (0x%p/0x%p)\n", cifs_dbg(FYI, "%s: (0x%p/0x%p)\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment