diff options
author | Christoph Hellwig <hch@lst.de> | 2020-05-28 07:12:25 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2020-05-28 11:11:45 -0700 |
commit | 480aeb9639d6a077c611b303a22f9b1e5937d081 (patch) | |
tree | 923c33a2592c8822ab15abc0929df23adda27a9f /net/ipv4 | |
parent | d41ecaac903c9f4658a71d4e7a708673cfb5abba (diff) | |
download | linux-480aeb9639d6a077c611b303a22f9b1e5937d081.tar.bz2 |
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.c | 12 |
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. */ |