aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWei Wang <weiwan@google.com>2019-01-25 13:53:20 -0500
committerDavid S. Miller <davem@davemloft.net>2019-01-27 16:29:43 -0500
commit4a41f453bedfd5e9cd040bad509d9da49feb3e2c (patch)
treef0afde54fb516f0293e849ade6c738ece48f16c1
parent31954cd8bb667030b1c0d3d77f28fe71f06999f9 (diff)
tcp: change pingpong threshold to 3
In order to be more confident about an on-going interactive session, we increment pingpong count by 1 for every interactive transaction and we adjust TCP_PINGPONG_THRESH to 3. This means, we only consider a session in pingpong mode after we see 3 interactive transactions, and start to activate delayed acks in quick ack mode. And in order to not over-count the credits, we only increase pingpong count for the first packet sent in response for the previous received packet. This is mainly to prevent delaying the ack immediately after some handshake protocol but no real interactive traffic pattern afterwards. 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>
-rw-r--r--include/net/inet_connection_sock.h10
-rw-r--r--net/ipv4/tcp_output.c15
2 files changed, 18 insertions, 7 deletions
diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
index 179609d1d1ea..ff40e1d08157 100644
--- a/include/net/inet_connection_sock.h
+++ b/include/net/inet_connection_sock.h
@@ -315,7 +315,7 @@ int inet_csk_compat_setsockopt(struct sock *sk, int level, int optname,
315 315
316struct dst_entry *inet_csk_update_pmtu(struct sock *sk, u32 mtu); 316struct dst_entry *inet_csk_update_pmtu(struct sock *sk, u32 mtu);
317 317
318#define TCP_PINGPONG_THRESH 1 318#define TCP_PINGPONG_THRESH 3
319 319
320static inline void inet_csk_enter_pingpong_mode(struct sock *sk) 320static inline void inet_csk_enter_pingpong_mode(struct sock *sk)
321{ 321{
@@ -331,4 +331,12 @@ static inline bool inet_csk_in_pingpong_mode(struct sock *sk)
331{ 331{
332 return inet_csk(sk)->icsk_ack.pingpong >= TCP_PINGPONG_THRESH; 332 return inet_csk(sk)->icsk_ack.pingpong >= TCP_PINGPONG_THRESH;
333} 333}
334
335static inline void inet_csk_inc_pingpong_cnt(struct sock *sk)
336{
337 struct inet_connection_sock *icsk = inet_csk(sk);
338
339 if (icsk->icsk_ack.pingpong < U8_MAX)
340 icsk->icsk_ack.pingpong++;
341}
334#endif /* _INET_CONNECTION_SOCK_H */ 342#endif /* _INET_CONNECTION_SOCK_H */
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 06228e2d010e..96bdb8eae9bb 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -165,13 +165,16 @@ static void tcp_event_data_sent(struct tcp_sock *tp,
165 if (tcp_packets_in_flight(tp) == 0) 165 if (tcp_packets_in_flight(tp) == 0)
166 tcp_ca_event(sk, CA_EVENT_TX_START); 166 tcp_ca_event(sk, CA_EVENT_TX_START);
167 167
168 tp->lsndtime = now; 168 /* If this is the first data packet sent in response to the
169 169 * previous received data,
170 /* If it is a reply for ato after last received 170 * and it is a reply for ato after last received packet,
171 * packet, enter pingpong mode. 171 * increase pingpong count.
172 */ 172 */
173 if ((u32)(now - icsk->icsk_ack.lrcvtime) < icsk->icsk_ack.ato) 173 if (before(tp->lsndtime, icsk->icsk_ack.lrcvtime) &&
174 inet_csk_enter_pingpong_mode(sk); 174 (u32)(now - icsk->icsk_ack.lrcvtime) < icsk->icsk_ack.ato)
175 inet_csk_inc_pingpong_cnt(sk);
176
177 tp->lsndtime = now;
175} 178}
176 179
177/* Account for an ACK we sent. */ 180/* Account for an ACK we sent. */