[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACSApvaXx+aogteaxFr+D-1zhZ6nrF+DNmuA=hicpaUf-2w45A@mail.gmail.com>
Date: Fri, 4 Aug 2023 11:50:22 -0400
From: Soheil Hassas Yeganeh <soheil@...gle.com>
To: Eric Dumazet <edumazet@...gle.com>
Cc: "David S . Miller" <davem@...emloft.net>, Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>, netdev@...r.kernel.org, eric.dumazet@...il.com
Subject: Re: [PATCH net-next 3/6] tcp: set TCP_KEEPINTVL locklessly
On Fri, Aug 4, 2023 at 10:46 AM Eric Dumazet <edumazet@...gle.com> wrote:
>
> tp->keepalive_intvl can be set locklessly, readers
> are already taking care of this field being potentially
> set by other threads.
>
> Signed-off-by: Eric Dumazet <edumazet@...gle.com>
Acked-by: Soheil Hassas Yeganeh <soheil@...gle.com>
> ---
> net/ipv4/tcp.c | 10 ++--------
> 1 file changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
> index 34c2a40b024779866216402e1d1de1802f8dfde4..75d6359ee5750d8a867fb36ec2de960869d8c76a 100644
> --- a/net/ipv4/tcp.c
> +++ b/net/ipv4/tcp.c
> @@ -3348,9 +3348,7 @@ int tcp_sock_set_keepintvl(struct sock *sk, int val)
> if (val < 1 || val > MAX_TCP_KEEPINTVL)
> return -EINVAL;
>
> - lock_sock(sk);
> WRITE_ONCE(tcp_sk(sk)->keepalive_intvl, val * HZ);
> - release_sock(sk);
> return 0;
> }
> EXPORT_SYMBOL(tcp_sock_set_keepintvl);
> @@ -3471,6 +3469,8 @@ int do_tcp_setsockopt(struct sock *sk, int level, int optname,
> return tcp_sock_set_syncnt(sk, val);
> case TCP_USER_TIMEOUT:
> return tcp_sock_set_user_timeout(sk, val);
> + case TCP_KEEPINTVL:
> + return tcp_sock_set_keepintvl(sk, val);
> }
>
> sockopt_lock_sock(sk);
> @@ -3568,12 +3568,6 @@ int do_tcp_setsockopt(struct sock *sk, int level, int optname,
> case TCP_KEEPIDLE:
> err = tcp_sock_set_keepidle_locked(sk, val);
> break;
> - case TCP_KEEPINTVL:
> - if (val < 1 || val > MAX_TCP_KEEPINTVL)
> - err = -EINVAL;
> - else
> - WRITE_ONCE(tp->keepalive_intvl, val * HZ);
> - break;
> case TCP_KEEPCNT:
> if (val < 1 || val > MAX_TCP_KEEPCNT)
> err = -EINVAL;
> --
> 2.41.0.640.ga95def55d0-goog
>
Powered by blists - more mailing lists