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.
Unified · Split
| @@ -16,14 +16,6 @@ · 15 unmodified lines | ||
| 16 | 16 | * Key layout of CIFS server cache index object |
| 17 | 17 | */ |
| 18 | 18 | 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 | − }; | |
| 27 | 19 | __u64 conn_id; |
| 28 | 20 | } __packed; |
| 29 | 21 | |
| @@ -32,11 +24,7 @@ struct cifs_server_key { · 2 unmodified lines | ||
| 32 | 24 | */ |
| 33 | 25 | void cifs_fscache_get_client_cookie(struct TCP_Server_Info *server) |
| 34 | 26 | { |
| 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; | |
| 38 | 27 | struct cifs_server_key key; |
| 39 | − uint16_t key_len = sizeof(key.hdr); | |
| 40 | 28 | |
| 41 | 29 | /* |
| 42 | 30 | * 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 | ||
| 47 | 35 | return; |
| 48 | 36 | |
| 49 | 37 | 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 | − } | |
| 74 | 38 | key.conn_id = server->conn_id; |
| 75 | 39 | |
| 76 | 40 | server->fscache = |
| 77 | 41 | fscache_acquire_cookie(cifs_fscache_netfs.primary_index, |
| 78 | 42 | &cifs_fscache_server_index_def, |
| 79 | − &key, key_len, | |
| 43 | + &key, sizeof(key), | |
| 80 | 44 | NULL, 0, |
| 81 | 45 | server, 0, true); |
| 82 | 46 | cifs_dbg(FYI, "%s: (0x%p/0x%p)\n", |