Commit d41ecaac authored by Christoph Hellwig's avatar Christoph Hellwig Committed by David S. Miller

tcp: add tcp_sock_set_keepintvl

Add a helper to directly set the TCP_KEEPINTVL sockopt from kernel space
without going through a fake uaccess.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 71c48eb8
...@@ -499,6 +499,7 @@ int tcp_skb_shift(struct sk_buff *to, struct sk_buff *from, int pcount, ...@@ -499,6 +499,7 @@ int tcp_skb_shift(struct sk_buff *to, struct sk_buff *from, int pcount,
void tcp_sock_set_cork(struct sock *sk, bool on); void tcp_sock_set_cork(struct sock *sk, bool on);
int tcp_sock_set_keepidle(struct sock *sk, int val); int tcp_sock_set_keepidle(struct sock *sk, int val);
int tcp_sock_set_keepintvl(struct sock *sk, int val);
void tcp_sock_set_nodelay(struct sock *sk); void tcp_sock_set_nodelay(struct sock *sk);
void tcp_sock_set_quickack(struct sock *sk, int val); void tcp_sock_set_quickack(struct sock *sk, int val);
int tcp_sock_set_syncnt(struct sock *sk, int val); int tcp_sock_set_syncnt(struct sock *sk, int val);
......
...@@ -2934,6 +2934,18 @@ int tcp_sock_set_keepidle(struct sock *sk, int val) ...@@ -2934,6 +2934,18 @@ int tcp_sock_set_keepidle(struct sock *sk, int val)
} }
EXPORT_SYMBOL(tcp_sock_set_keepidle); EXPORT_SYMBOL(tcp_sock_set_keepidle);
int tcp_sock_set_keepintvl(struct sock *sk, int val)
{
if (val < 1 || val > MAX_TCP_KEEPINTVL)
return -EINVAL;
lock_sock(sk);
tcp_sk(sk)->keepalive_intvl = val * HZ;
release_sock(sk);
return 0;
}
EXPORT_SYMBOL(tcp_sock_set_keepintvl);
/* /*
* Socket option code for TCP. * Socket option code for TCP.
*/ */
......
...@@ -53,12 +53,10 @@ int rds_tcp_keepalive(struct socket *sock) ...@@ -53,12 +53,10 @@ int rds_tcp_keepalive(struct socket *sock)
goto bail; goto bail;
tcp_sock_set_keepidle(sock->sk, keepidle); tcp_sock_set_keepidle(sock->sk, keepidle);
/* KEEPINTVL is the interval between successive probes. We follow /* KEEPINTVL is the interval between successive probes. We follow
* the model in xs_tcp_finish_connecting() and re-use keepidle. * the model in xs_tcp_finish_connecting() and re-use keepidle.
*/ */
ret = kernel_setsockopt(sock, IPPROTO_TCP, TCP_KEEPINTVL, tcp_sock_set_keepintvl(sock->sk, keepidle);
(char *)&keepidle, sizeof(keepidle));
bail: bail:
return ret; return ret;
} }
......
...@@ -2108,8 +2108,7 @@ static void xs_tcp_set_socket_timeouts(struct rpc_xprt *xprt, ...@@ -2108,8 +2108,7 @@ static void xs_tcp_set_socket_timeouts(struct rpc_xprt *xprt,
/* TCP Keepalive options */ /* TCP Keepalive options */
sock_set_keepalive(sock->sk); sock_set_keepalive(sock->sk);
tcp_sock_set_keepidle(sock->sk, keepidle); tcp_sock_set_keepidle(sock->sk, keepidle);
kernel_setsockopt(sock, SOL_TCP, TCP_KEEPINTVL, tcp_sock_set_keepintvl(sock->sk, keepidle);
(char *)&keepidle, sizeof(keepidle));
kernel_setsockopt(sock, SOL_TCP, TCP_KEEPCNT, kernel_setsockopt(sock, SOL_TCP, TCP_KEEPCNT,
(char *)&keepcnt, sizeof(keepcnt)); (char *)&keepcnt, sizeof(keepcnt));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment