Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Denis Kirjanov <kda@linux-powerpc.org>
To: Yajun Deng <yajun.deng@linux.dev>
Cc: davem@davemloft.net, kuba@kernel.org,
	mathew.j.martineau@linux.intel.com, matthieu.baerts@tessares.net,
	trond.myklebust@hammerspace.com, anna.schumaker@netapp.com,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	bpf@vger.kernel.org, mptcp@lists.linux.dev,
	linux-rdma@vger.kernel.org, rds-devel@oss.oracle.com,
	linux-s390@vger.kernel.org, linux-nfs@vger.kernel.org
Subject: Re: [PATCH net-next] net: Modify sock_set_keepalive() for more scenarios
Date: Tue, 3 Aug 2021 12:44:55 +0300	[thread overview]
Message-ID: <CAOJe8K0_v0SHY913pnCHKZ9WUdNGOJ2nbagsr5t=ytiJ-Y3rrQ@mail.gmail.com> (raw)
In-Reply-To: <20210803082553.25194-1-yajun.deng@linux.dev>

On 8/3/21, Yajun Deng <yajun.deng@linux.dev> wrote:
> Add 2nd parameter in sock_set_keepalive(), let the caller decide
> whether to set. This can be applied to more scenarios.

It makes sense to send the patch within a context of other scenarios

>
> Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
> ---
>  include/net/sock.h    |  2 +-
>  net/core/filter.c     |  4 +---
>  net/core/sock.c       | 10 ++++------
>  net/mptcp/sockopt.c   |  4 +---
>  net/rds/tcp_listen.c  |  2 +-
>  net/smc/af_smc.c      |  2 +-
>  net/sunrpc/xprtsock.c |  2 +-
>  7 files changed, 10 insertions(+), 16 deletions(-)
>
> diff --git a/include/net/sock.h b/include/net/sock.h
> index ff1be7e7e90b..0aae26159549 100644
> --- a/include/net/sock.h
> +++ b/include/net/sock.h
> @@ -2772,7 +2772,7 @@ int sock_set_timestamping(struct sock *sk, int
> optname,
>
>  void sock_enable_timestamps(struct sock *sk);
>  void sock_no_linger(struct sock *sk);
> -void sock_set_keepalive(struct sock *sk);
> +void sock_set_keepalive(struct sock *sk, bool valbool);
>  void sock_set_priority(struct sock *sk, u32 priority);
>  void sock_set_rcvbuf(struct sock *sk, int val);
>  void sock_set_mark(struct sock *sk, u32 val);
> diff --git a/net/core/filter.c b/net/core/filter.c
> index faf29fd82276..41b2bf140b89 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
> @@ -4769,9 +4769,7 @@ static int _bpf_setsockopt(struct sock *sk, int level,
> int optname,
>  			ret = sock_bindtoindex(sk, ifindex, false);
>  			break;
>  		case SO_KEEPALIVE:
> -			if (sk->sk_prot->keepalive)
> -				sk->sk_prot->keepalive(sk, valbool);
> -			sock_valbool_flag(sk, SOCK_KEEPOPEN, valbool);
> +			sock_set_keepalive(sk, !!valbool);
>  			break;
>  		case SO_REUSEPORT:
>  			sk->sk_reuseport = valbool;
> diff --git a/net/core/sock.c b/net/core/sock.c
> index 9671c32e6ef5..7041e6355ae1 100644
> --- a/net/core/sock.c
> +++ b/net/core/sock.c
> @@ -892,12 +892,12 @@ int sock_set_timestamping(struct sock *sk, int
> optname,
>  	return 0;
>  }
>
> -void sock_set_keepalive(struct sock *sk)
> +void sock_set_keepalive(struct sock *sk, bool valbool)
>  {
>  	lock_sock(sk);
>  	if (sk->sk_prot->keepalive)
> -		sk->sk_prot->keepalive(sk, true);
> -	sock_valbool_flag(sk, SOCK_KEEPOPEN, true);
> +		sk->sk_prot->keepalive(sk, valbool);
> +	sock_valbool_flag(sk, SOCK_KEEPOPEN, valbool);
>  	release_sock(sk);
>  }
>  EXPORT_SYMBOL(sock_set_keepalive);
> @@ -1060,9 +1060,7 @@ int sock_setsockopt(struct socket *sock, int level,
> int optname,
>  		break;
>
>  	case SO_KEEPALIVE:
> -		if (sk->sk_prot->keepalive)
> -			sk->sk_prot->keepalive(sk, valbool);
> -		sock_valbool_flag(sk, SOCK_KEEPOPEN, valbool);
> +		sock_set_keepalive(sk, !!valbool);
>  		break;
>
>  	case SO_OOBINLINE:
> diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c
> index 8c03afac5ca0..879b8381055c 100644
> --- a/net/mptcp/sockopt.c
> +++ b/net/mptcp/sockopt.c
> @@ -81,9 +81,7 @@ static void mptcp_sol_socket_sync_intval(struct mptcp_sock
> *msk, int optname, in
>  			sock_valbool_flag(ssk, SOCK_DBG, !!val);
>  			break;
>  		case SO_KEEPALIVE:
> -			if (ssk->sk_prot->keepalive)
> -				ssk->sk_prot->keepalive(ssk, !!val);
> -			sock_valbool_flag(ssk, SOCK_KEEPOPEN, !!val);
> +			sock_set_keepalive(ssk, !!val);
>  			break;
>  		case SO_PRIORITY:
>  			ssk->sk_priority = val;
> diff --git a/net/rds/tcp_listen.c b/net/rds/tcp_listen.c
> index 09cadd556d1e..b69ebb3f424a 100644
> --- a/net/rds/tcp_listen.c
> +++ b/net/rds/tcp_listen.c
> @@ -44,7 +44,7 @@ void rds_tcp_keepalive(struct socket *sock)
>  	int keepidle = 5; /* send a probe 'keepidle' secs after last data */
>  	int keepcnt = 5; /* number of unack'ed probes before declaring dead */
>
> -	sock_set_keepalive(sock->sk);
> +	sock_set_keepalive(sock->sk, true);
>  	tcp_sock_set_keepcnt(sock->sk, keepcnt);
>  	tcp_sock_set_keepidle(sock->sk, keepidle);
>  	/* KEEPINTVL is the interval between successive probes. We follow
> diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
> index 898389611ae8..ad8f4302037f 100644
> --- a/net/smc/af_smc.c
> +++ b/net/smc/af_smc.c
> @@ -68,7 +68,7 @@ static void smc_set_keepalive(struct sock *sk, int val)
>  {
>  	struct smc_sock *smc = smc_sk(sk);
>
> -	smc->clcsock->sk->sk_prot->keepalive(smc->clcsock->sk, val);
> +	sock_set_keepalive(smc->clcsock->sk, !!val);
>  }
>
>  static struct smc_hashinfo smc_v4_hashinfo = {
> diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
> index e573dcecdd66..306a332f8d28 100644
> --- a/net/sunrpc/xprtsock.c
> +++ b/net/sunrpc/xprtsock.c
> @@ -2127,7 +2127,7 @@ static void xs_tcp_set_socket_timeouts(struct rpc_xprt
> *xprt,
>  	spin_unlock(&xprt->transport_lock);
>
>  	/* TCP Keepalive options */
> -	sock_set_keepalive(sock->sk);
> +	sock_set_keepalive(sock->sk, true);
>  	tcp_sock_set_keepidle(sock->sk, keepidle);
>  	tcp_sock_set_keepintvl(sock->sk, keepidle);
>  	tcp_sock_set_keepcnt(sock->sk, keepcnt);
> --
> 2.32.0
>
>

  reply	other threads:[~2021-08-03  9:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-03  8:25 Yajun Deng
2021-08-03  9:44 ` Denis Kirjanov [this message]
2021-08-03 11:28 ` kernel test robot
2021-08-03 11:42 ` yajun.deng
2021-08-03 15:59   ` Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAOJe8K0_v0SHY913pnCHKZ9WUdNGOJ2nbagsr5t=ytiJ-Y3rrQ@mail.gmail.com' \
    --to=kda@linux-powerpc.org \
    --cc=anna.schumaker@netapp.com \
    --cc=bpf@vger.kernel.org \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=mathew.j.martineau@linux.intel.com \
    --cc=matthieu.baerts@tessares.net \
    --cc=mptcp@lists.linux.dev \
    --cc=netdev@vger.kernel.org \
    --cc=rds-devel@oss.oracle.com \
    --cc=trond.myklebust@hammerspace.com \
    --cc=yajun.deng@linux.dev \
    --subject='Re: [PATCH net-next] net: Modify sock_set_keepalive() for more scenarios' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).