Re: [PATCH v1 net-next 06/13] tcp: Set NULL to sk->sk_prot->h.hashinfo.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Aug 25, 2022 at 5:07 PM Kuniyuki Iwashima <kuniyu@xxxxxxxxxx> wrote:
>
> We will soon introduce an optional per-netns ehash.
>
> This means we cannot use the global sk->sk_prot->h.hashinfo
> to fetch a TCP hashinfo.
>
> Instead, set NULL to sk->sk_prot->h.hashinfo for TCP and get
> a proper hashinfo from net->ipv4.tcp_death_row->hashinfo.
>
> Note that we need not use sk->sk_prot->h.hashinfo if DCCP is
> disabled.
>
> Signed-off-by: Kuniyuki Iwashima <kuniyu@xxxxxxxxxx>
> ---
>  include/net/inet_hashtables.h   | 10 ++++++++++
>  net/ipv4/af_inet.c              |  2 +-
>  net/ipv4/inet_connection_sock.c |  6 +++---
>  net/ipv4/inet_hashtables.c      | 14 +++++++-------
>  net/ipv4/tcp_ipv4.c             |  2 +-
>  net/ipv6/tcp_ipv6.c             |  2 +-
>  6 files changed, 23 insertions(+), 13 deletions(-)
>
> diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h
> index 44a419b9e3d5..2c866112433e 100644
> --- a/include/net/inet_hashtables.h
> +++ b/include/net/inet_hashtables.h
> @@ -170,6 +170,16 @@ struct inet_hashinfo {
>         struct inet_listen_hashbucket   *lhash2;
>  };
>
> +static inline struct inet_hashinfo *inet_get_hashinfo(const struct sock *sk)
> +{
> +#if IS_ENABLED(CONFIG_IP_DCCP)
> +       return sk->sk_prot->h.hashinfo ? :
> +               sock_net(sk)->ipv4.tcp_death_row->hashinfo;
> +#else
> +       return sock_net(sk)->ipv4.tcp_death_row->hashinfo;
> +#endif
> +}
>

If the sk_prot->h.hashinfo must disappear, I would rather add a new
inet->hashinfo field

return inet_sk(sk)->hashinfo

Conceptually, the pointer no longer belongs to sk_prot, and not in struct net,
otherwise you should name this helper   tcp_or_dccp_get_hashinfo() to avoid
any temptation to use it for other inet protocol.



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux