tcp: add tcp_sock_set_quickack
Add a helper to directly set the TCP_QUICKACK sockopt from kernel space without going through a fake uaccess. Cleanup the callers to avoid pointless wrappers now that this is a simple function call. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
12abc5ee78
commit
ddd061b8da
@@ -2856,6 +2856,31 @@ void tcp_sock_set_nodelay(struct sock *sk)
|
||||
}
|
||||
EXPORT_SYMBOL(tcp_sock_set_nodelay);
|
||||
|
||||
static void __tcp_sock_set_quickack(struct sock *sk, int val)
|
||||
{
|
||||
if (!val) {
|
||||
inet_csk_enter_pingpong_mode(sk);
|
||||
return;
|
||||
}
|
||||
|
||||
inet_csk_exit_pingpong_mode(sk);
|
||||
if ((1 << sk->sk_state) & (TCPF_ESTABLISHED | TCPF_CLOSE_WAIT) &&
|
||||
inet_csk_ack_scheduled(sk)) {
|
||||
inet_csk(sk)->icsk_ack.pending |= ICSK_ACK_PUSHED;
|
||||
tcp_cleanup_rbuf(sk, 1);
|
||||
if (!(val & 1))
|
||||
inet_csk_enter_pingpong_mode(sk);
|
||||
}
|
||||
}
|
||||
|
||||
void tcp_sock_set_quickack(struct sock *sk, int val)
|
||||
{
|
||||
lock_sock(sk);
|
||||
__tcp_sock_set_quickack(sk, val);
|
||||
release_sock(sk);
|
||||
}
|
||||
EXPORT_SYMBOL(tcp_sock_set_quickack);
|
||||
|
||||
/*
|
||||
* Socket option code for TCP.
|
||||
*/
|
||||
@@ -3096,19 +3121,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
|
||||
break;
|
||||
|
||||
case TCP_QUICKACK:
|
||||
if (!val) {
|
||||
inet_csk_enter_pingpong_mode(sk);
|
||||
} else {
|
||||
inet_csk_exit_pingpong_mode(sk);
|
||||
if ((1 << sk->sk_state) &
|
||||
(TCPF_ESTABLISHED | TCPF_CLOSE_WAIT) &&
|
||||
inet_csk_ack_scheduled(sk)) {
|
||||
icsk->icsk_ack.pending |= ICSK_ACK_PUSHED;
|
||||
tcp_cleanup_rbuf(sk, 1);
|
||||
if (!(val & 1))
|
||||
inet_csk_enter_pingpong_mode(sk);
|
||||
}
|
||||
}
|
||||
__tcp_sock_set_quickack(sk, val);
|
||||
break;
|
||||
|
||||
#ifdef CONFIG_TCP_MD5SIG
|
||||
|
Reference in New Issue
Block a user