af_unix: Include the whole hash table size in UNIX_HASH_SIZE.
authorKuniyuki Iwashima <kuniyu@amazon.com>
Tue, 21 Jun 2022 17:19:09 +0000 (10:19 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 22 Jun 2022 11:59:43 +0000 (12:59 +0100)
commitf302d180c6d430ea99643b9b2b3407aedaa36703
tree986eaa808366960626098ce15fd901f29716be6c
parent340c3d337119ea177a98338be2e3bc62ee87ac80
af_unix: Include the whole hash table size in UNIX_HASH_SIZE.

Currently, the size of AF_UNIX hash table is UNIX_HASH_SIZE * 2,
the first half for bind()ed sockets and the second half for unbound
ones.  UNIX_HASH_SIZE * 2 is used to define the table and iterate
over it.

In some places, we use ARRAY_SIZE(unix_socket_table) instead of
UNIX_HASH_SIZE * 2.  However, we cannot use it anymore because we
will allocate the hash table dynamically.  Then, we would have to
add UNIX_HASH_SIZE * 2 in many places, which would be troublesome.

This patch adapts the UNIX_HASH_SIZE definition to include bound
and unbound sockets and defines a new UNIX_HASH_MOD macro to ease
calculations.

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/af_unix.h
net/unix/af_unix.c
net/unix/diag.c