aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp.c
diff options
context:
space:
mode:
authorWei Wang <weiwan@google.com>2019-01-25 13:53:19 -0500
committerDavid S. Miller <davem@davemloft.net>2019-01-27 16:29:43 -0500
commit31954cd8bb667030b1c0d3d77f28fe71f06999f9 (patch)
treef00b43f2669ac70db625d8babe06e89cd0a731e2 /net/ipv4/tcp.c
parentfb1b69999130e9800c4e341a2b0f0991cdd8fcfc (diff)
tcp: Refactor pingpong code
Instead of using pingpong as a single bit information, we refactor the code to treat it as a counter. When interactive session is detected, we set pingpong count to TCP_PINGPONG_THRESH. And when pingpong count is >= TCP_PINGPONG_THRESH, we consider the session in pingpong mode. This patch is a pure refactor and sets foundation for the next patch. This patch itself does not change any pingpong logic. Signed-off-by: Wei Wang <weiwan@google.com> Signed-off-by: Yuchung Cheng <ycheng@google.com> Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/tcp.c')
-rw-r--r--net/ipv4/tcp.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 12ba21433dd0..6f8d292ad501 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -1551,7 +1551,7 @@ static void tcp_cleanup_rbuf(struct sock *sk, int copied)
1551 (copied > 0 && 1551 (copied > 0 &&
1552 ((icsk->icsk_ack.pending & ICSK_ACK_PUSHED2) || 1552 ((icsk->icsk_ack.pending & ICSK_ACK_PUSHED2) ||
1553 ((icsk->icsk_ack.pending & ICSK_ACK_PUSHED) && 1553 ((icsk->icsk_ack.pending & ICSK_ACK_PUSHED) &&
1554 !icsk->icsk_ack.pingpong)) && 1554 !inet_csk_in_pingpong_mode(sk))) &&
1555 !atomic_read(&sk->sk_rmem_alloc))) 1555 !atomic_read(&sk->sk_rmem_alloc)))
1556 time_to_ack = true; 1556 time_to_ack = true;
1557 } 1557 }
@@ -2984,16 +2984,16 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
2984 2984
2985 case TCP_QUICKACK: 2985 case TCP_QUICKACK:
2986 if (!val) { 2986 if (!val) {
2987 icsk->icsk_ack.pingpong = 1; 2987 inet_csk_enter_pingpong_mode(sk);
2988 } else { 2988 } else {
2989 icsk->icsk_ack.pingpong = 0; 2989 inet_csk_exit_pingpong_mode(sk);
2990 if ((1 << sk->sk_state) & 2990 if ((1 << sk->sk_state) &
2991 (TCPF_ESTABLISHED | TCPF_CLOSE_WAIT) && 2991 (TCPF_ESTABLISHED | TCPF_CLOSE_WAIT) &&
2992 inet_csk_ack_scheduled(sk)) { 2992 inet_csk_ack_scheduled(sk)) {
2993 icsk->icsk_ack.pending |= ICSK_ACK_PUSHED; 2993 icsk->icsk_ack.pending |= ICSK_ACK_PUSHED;
2994 tcp_cleanup_rbuf(sk, 1); 2994 tcp_cleanup_rbuf(sk, 1);
2995 if (!(val & 1)) 2995 if (!(val & 1))
2996 icsk->icsk_ack.pingpong = 1; 2996 inet_csk_enter_pingpong_mode(sk);
2997 } 2997 }
2998 } 2998 }
2999 break; 2999 break;
@@ -3407,7 +3407,7 @@ static int do_tcp_getsockopt(struct sock *sk, int level,
3407 return 0; 3407 return 0;
3408 } 3408 }
3409 case TCP_QUICKACK: 3409 case TCP_QUICKACK:
3410 val = !icsk->icsk_ack.pingpong; 3410 val = !inet_csk_in_pingpong_mode(sk);
3411 break; 3411 break;
3412 3412
3413 case TCP_CONGESTION: 3413 case TCP_CONGESTION: