Re: [PATCH v14 net-next 09/23] net/tcp: Add TCP-AO sign to twsk

From: Eric Dumazet
Date: Wed Oct 11 2023 - 14:10:37 EST


On Tue, Oct 10, 2023 at 1:07 AM Dmitry Safonov <dima@xxxxxxxxxx> wrote:
>
> Add support for sockets in time-wait state.
> ao_info as well as all keys are inherited on transition to time-wait
> socket. The lifetime of ao_info is now protected by ref counter, so
> that tcp_ao_destroy_sock() will destruct it only when the last user is
> gone.
>
> Co-developed-by: Francesco Ruggeri <fruggeri@xxxxxxxxxx>
> Signed-off-by: Francesco Ruggeri <fruggeri@xxxxxxxxxx>
> Co-developed-by: Salam Noureddine <noureddine@xxxxxxxxxx>
> Signed-off-by: Salam Noureddine <noureddine@xxxxxxxxxx>
> Signed-off-by: Dmitry Safonov <dima@xxxxxxxxxx>
> Acked-by: David Ahern <dsahern@xxxxxxxxxx>
> ---
> include/linux/tcp.h | 3 ++
> include/net/tcp_ao.h | 11 ++++-
> net/ipv4/tcp_ao.c | 46 +++++++++++++++++---
> net/ipv4/tcp_ipv4.c | 92 +++++++++++++++++++++++++++++++---------
> net/ipv4/tcp_minisocks.c | 4 +-
> net/ipv4/tcp_output.c | 2 +-
> net/ipv6/tcp_ipv6.c | 72 ++++++++++++++++++++++---------
> 7 files changed, 181 insertions(+), 49 deletions(-)
>
> diff --git a/include/linux/tcp.h b/include/linux/tcp.h
> index c38778b0baa0..51458219be4e 100644
> --- a/include/linux/tcp.h
> +++ b/include/linux/tcp.h
> @@ -512,6 +512,9 @@ struct tcp_timewait_sock {
> #ifdef CONFIG_TCP_MD5SIG
> struct tcp_md5sig_key *tw_md5_key;
> #endif
> +#ifdef CONFIG_TCP_AO
> + struct tcp_ao_info __rcu *ao_info;
> +#endif
> };
>
> static inline struct tcp_timewait_sock *tcp_twsk(const struct sock *sk)
> diff --git a/include/net/tcp_ao.h b/include/net/tcp_ao.h
> index 629ab0365b83..af2caf7e76fc 100644
> --- a/include/net/tcp_ao.h
> +++ b/include/net/tcp_ao.h
> @@ -85,6 +85,7 @@ struct tcp_ao_info {
> __unused :31;
> __be32 lisn;
> __be32 risn;
> + atomic_t refcnt; /* Protects twsk destruction */

This needs to be a refcount_t