History

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.

Shyam Prasad N committed 4 years ago

Commit bbb9db51 parent 2adc8201 file · +1 −37Browse files

Unified · Split

fs/cifs/fscache.c+1−37
@@ -16,14 +16,6 @@ · 15 unmodified lines
1616 * Key layout of CIFS server cache index object
1717 */
1818 struct cifs_server_key {
19− struct {
20− uint16_t family; /* address family */
21− __be16 port; /* IP port */
22− } hdr;
23− union {
24− struct in_addr ipv4_addr;
25− struct in6_addr ipv6_addr;
26− };
2719 __u64 conn_id;
2820 } __packed;
2921
@@ -32,11 +24,7 @@ struct cifs_server_key { · 2 unmodified lines
3224 */
3325 void cifs_fscache_get_client_cookie(struct TCP_Server_Info *server)
3426 {
35− const struct sockaddr *sa = (struct sockaddr *) &server->dstaddr;
36− const struct sockaddr_in *addr = (struct sockaddr_in *) sa;
37− const struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *) sa;
3827 struct cifs_server_key key;
39− uint16_t key_len = sizeof(key.hdr);
4028
4129 /*
4230 * 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) · 4 unmodified lines
4735 return;
4836
4937 memset(&key, 0, sizeof(key));
50−
51− /*
52− * Should not be a problem as sin_family/sin6_family overlays
53− * sa_family field
54− */
55− key.hdr.family = sa->sa_family;
56− switch (sa->sa_family) {
57− case AF_INET:
58− key.hdr.port = addr->sin_port;
59− key.ipv4_addr = addr->sin_addr;
60− key_len += sizeof(key.ipv4_addr);
61− break;
62−
63− case AF_INET6:
64− key.hdr.port = addr6->sin6_port;
65− key.ipv6_addr = addr6->sin6_addr;
66− key_len += sizeof(key.ipv6_addr);
67− break;
68−
69− default:
70− cifs_dbg(VFS, "Unknown network family '%d'\n", sa->sa_family);
71− server->fscache = NULL;
72− return;
73− }
7438 key.conn_id = server->conn_id;
7539
7640 server->fscache =
7741 fscache_acquire_cookie(cifs_fscache_netfs.primary_index,
7842 &cifs_fscache_server_index_def,
79− &key, key_len,
43+ &key, sizeof(key),
8044 NULL, 0,
8145 server, 0, true);
8246 cifs_dbg(FYI, "%s: (0x%p/0x%p)\n",

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t