summaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2020-05-28 07:12:10 +0200
committerDavid S. Miller <davem@davemloft.net>2020-05-28 11:11:44 -0700
commitc433594c07457d2b2e41a87014bfad9bec279abf (patch)
tree2c878b9ba357b4a52aec683daa19a1c3cf759cec /net/core
parentb58f0e8f38c0a44afa59601a115bd231f23471e1 (diff)
downloadlinux-c433594c07457d2b2e41a87014bfad9bec279abf.tar.bz2
net: add sock_no_linger
Add a helper to directly set the SO_LINGER sockopt from kernel space with onoff set to true and a linger time of 0 without going through a fake uaccess. Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Sagi Grimberg <sagi@grimberg.me> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/sock.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/net/core/sock.c b/net/core/sock.c
index 18eb84fdf5fb..f0f09524911c 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -720,6 +720,15 @@ void sock_set_reuseaddr(struct sock *sk)
}
EXPORT_SYMBOL(sock_set_reuseaddr);
+void sock_no_linger(struct sock *sk)
+{
+ lock_sock(sk);
+ sk->sk_lingertime = 0;
+ sock_set_flag(sk, SOCK_LINGER);
+ release_sock(sk);
+}
+EXPORT_SYMBOL(sock_no_linger);
+
/*
* This is meant for all protocols to use and covers goings on
* at the socket level. Everything here is generic.