aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2020-05-28 07:12:25 +0200
committerDavid S. Miller <davem@davemloft.net>2020-05-28 11:11:45 -0700
commit480aeb9639d6a077c611b303a22f9b1e5937d081 (patch)
tree923c33a2592c8822ab15abc0929df23adda27a9f /net/ipv4
parenttcp: add tcp_sock_set_keepintvl (diff)
downloadlinux-dev-480aeb9639d6a077c611b303a22f9b1e5937d081.tar.xz
linux-dev-480aeb9639d6a077c611b303a22f9b1e5937d081.zip
tcp: add tcp_sock_set_keepcnt
Add a helper to directly set the TCP_KEEPCNT sockopt from kernel space without going through a fake uaccess. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/tcp.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 7eb083e09786..15d47d5e7951 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2946,6 +2946,18 @@ int tcp_sock_set_keepintvl(struct sock *sk, int val)
}
EXPORT_SYMBOL(tcp_sock_set_keepintvl);
+int tcp_sock_set_keepcnt(struct sock *sk, int val)
+{
+ if (val < 1 || val > MAX_TCP_KEEPCNT)
+ return -EINVAL;
+
+ lock_sock(sk);
+ tcp_sk(sk)->keepalive_probes = val;
+ release_sock(sk);
+ return 0;
+}
+EXPORT_SYMBOL(tcp_sock_set_keepcnt);
+
/*
* Socket option code for TCP.
*/