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

tcp: add tcp_sock_set_syncnt

Add a helper to directly set the TCP_SYNCNT sockopt from kernel space
without going through a fake uaccess.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Acked-by: default avatarSagi Grimberg <sagi@grimberg.me>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ddd061b8
......@@ -1336,14 +1336,7 @@ static int nvme_tcp_alloc_queue(struct nvme_ctrl *nctrl,
}
/* Single syn retry */
opt = 1;
ret = kernel_setsockopt(queue->sock, IPPROTO_TCP, TCP_SYNCNT,
(char *)&opt, sizeof(opt));
if (ret) {
dev_err(nctrl->device,
"failed to set TCP_SYNCNT sock opt %d\n", ret);
goto err_sock;
}
tcp_sock_set_syncnt(queue->sock->sk, 1);
/* Set TCP no delay */
tcp_sock_set_nodelay(queue->sock->sk);
......
......@@ -500,5 +500,6 @@ 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_nodelay(struct sock *sk);
void tcp_sock_set_quickack(struct sock *sk, int val);
int tcp_sock_set_syncnt(struct sock *sk, int val);
#endif /* _LINUX_TCP_H */
......@@ -2881,6 +2881,18 @@ void tcp_sock_set_quickack(struct sock *sk, int val)
}
EXPORT_SYMBOL(tcp_sock_set_quickack);
int tcp_sock_set_syncnt(struct sock *sk, int val)
{
if (val < 1 || val > MAX_TCP_SYNCNT)
return -EINVAL;
lock_sock(sk);
inet_csk(sk)->icsk_syn_retries = val;
release_sock(sk);
return 0;
}
EXPORT_SYMBOL(tcp_sock_set_syncnt);
/*
* Socket option code for TCP.
*/
......
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