Hi Andy, On Wed, Feb 6, 2013 at 7:23 PM, Andy King <acking@xxxxxxxxxx> wrote: > + * Specifically, we initialize the vsock_bind_table array to a size of > + * VSOCK_HASH_SIZE + 1 so that vsock_bind_table[0] through > + * vsock_bind_table[VSOCK_HASH_SIZE - 1] are for bound sockets and > + * vsock_bind_table[VSOCK_HASH_SIZE] is for unbound sockets. The hash function > + * mods with VSOCK_HASH_SIZE - 1 to ensure this. > + */ > +#define VSOCK_HASH_SIZE 251 > +#define MAX_PORT_RETRIES 24 > + > +#define VSOCK_HASH(addr) ((addr)->svm_port % (VSOCK_HASH_SIZE - 1)) > +#define vsock_bound_sockets(addr) (&vsock_bind_table[VSOCK_HASH(addr)]) > +#define vsock_unbound_sockets (&vsock_bind_table[VSOCK_HASH_SIZE]) > + > +/* XXX This can probably be implemented in a better way. */ > +#define VSOCK_CONN_HASH(src, dst) \ > + (((src)->svm_cid ^ (dst)->svm_port) % (VSOCK_HASH_SIZE - 1)) > +#define vsock_connected_sockets(src, dst) \ > + (&vsock_connected_table[VSOCK_CONN_HASH(src, dst)]) > +#define vsock_connected_sockets_vsk(vsk) \ > + vsock_connected_sockets(&(vsk)->remote_addr, &(vsk)->local_addr) > + > +static struct list_head vsock_bind_table[VSOCK_HASH_SIZE + 1]; > +static struct list_head vsock_connected_table[VSOCK_HASH_SIZE]; > +static DEFINE_SPINLOCK(vsock_table_lock); Why isn't it using the kernel's linux/hashtable.h? Thanks, Sasha _______________________________________________ Virtualization mailing list Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx https://lists.linuxfoundation.org/mailman/listinfo/virtualization