aboutsummaryrefslogtreecommitdiffstats
path: root/net/vmw_vsock
diff options
context:
space:
mode:
authorAsias He <asias@redhat.com>2013-06-20 05:20:33 -0400
committerDavid S. Miller <davem@davemloft.net>2013-06-24 02:51:48 -0400
commita49dd9dcb50195b35a5e59eb65b8e56584874630 (patch)
treee10f8f64fc4b4d90c0c7c1d5507890f1b87f3e86 /net/vmw_vsock
parent0fc932467688e1c81fc109a93f323cef4993dc24 (diff)
VSOCK: Fix VSOCK_HASH and VSOCK_CONN_HASH
If we mod with VSOCK_HASH_SIZE -1, we get 0, 1, .... 249. Actually, we have vsock_bind_table[0 ... 250] and vsock_connected_table[0 .. 250]. In this case the last entry will never be used. We should mod with VSOCK_HASH_SIZE instead. Signed-off-by: Asias He <asias@redhat.com> Acked-by: Andy King <acking@vmware.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/vmw_vsock')
-rw-r--r--net/vmw_vsock/af_vsock.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index b0b362ad051d..593071dabd1c 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -144,18 +144,18 @@ EXPORT_SYMBOL_GPL(vm_sockets_get_local_cid);
144 * VSOCK_HASH_SIZE + 1 so that vsock_bind_table[0] through 144 * VSOCK_HASH_SIZE + 1 so that vsock_bind_table[0] through
145 * vsock_bind_table[VSOCK_HASH_SIZE - 1] are for bound sockets and 145 * vsock_bind_table[VSOCK_HASH_SIZE - 1] are for bound sockets and
146 * vsock_bind_table[VSOCK_HASH_SIZE] is for unbound sockets. The hash function 146 * vsock_bind_table[VSOCK_HASH_SIZE] is for unbound sockets. The hash function
147 * mods with VSOCK_HASH_SIZE - 1 to ensure this. 147 * mods with VSOCK_HASH_SIZE to ensure this.
148 */ 148 */
149#define VSOCK_HASH_SIZE 251 149#define VSOCK_HASH_SIZE 251
150#define MAX_PORT_RETRIES 24 150#define MAX_PORT_RETRIES 24
151 151
152#define VSOCK_HASH(addr) ((addr)->svm_port % (VSOCK_HASH_SIZE - 1)) 152#define VSOCK_HASH(addr) ((addr)->svm_port % VSOCK_HASH_SIZE)
153#define vsock_bound_sockets(addr) (&vsock_bind_table[VSOCK_HASH(addr)]) 153#define vsock_bound_sockets(addr) (&vsock_bind_table[VSOCK_HASH(addr)])
154#define vsock_unbound_sockets (&vsock_bind_table[VSOCK_HASH_SIZE]) 154#define vsock_unbound_sockets (&vsock_bind_table[VSOCK_HASH_SIZE])
155 155
156/* XXX This can probably be implemented in a better way. */ 156/* XXX This can probably be implemented in a better way. */
157#define VSOCK_CONN_HASH(src, dst) \ 157#define VSOCK_CONN_HASH(src, dst) \
158 (((src)->svm_cid ^ (dst)->svm_port) % (VSOCK_HASH_SIZE - 1)) 158 (((src)->svm_cid ^ (dst)->svm_port) % VSOCK_HASH_SIZE)
159#define vsock_connected_sockets(src, dst) \ 159#define vsock_connected_sockets(src, dst) \
160 (&vsock_connected_table[VSOCK_CONN_HASH(src, dst)]) 160 (&vsock_connected_table[VSOCK_CONN_HASH(src, dst)])
161#define vsock_connected_sockets_vsk(vsk) \ 161#define vsock_connected_sockets_vsk(vsk) \