Skip to content

Commit 119768c

Browse files
committed
Merge branch 'tcp-ECN-quickack'
Eric Dumazet says: ==================== tcp: reduce quickack pressure for ECN Small patch series changing TCP behavior vs quickack and ECN First patch is a refactoring, adding parameter to tcp_incr_quickack() and tcp_enter_quickack_mode() helpers. Second patch implements the change, lowering number of ACK packets sent after an ECN event. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 290aa0a + 522040e commit 119768c

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

net/ipv4/tcp_input.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -203,21 +203,23 @@ static void tcp_measure_rcv_mss(struct sock *sk, const struct sk_buff *skb)
203203
}
204204
}
205205

206-
static void tcp_incr_quickack(struct sock *sk)
206+
static void tcp_incr_quickack(struct sock *sk, unsigned int max_quickacks)
207207
{
208208
struct inet_connection_sock *icsk = inet_csk(sk);
209209
unsigned int quickacks = tcp_sk(sk)->rcv_wnd / (2 * icsk->icsk_ack.rcv_mss);
210210

211211
if (quickacks == 0)
212212
quickacks = 2;
213+
quickacks = min(quickacks, max_quickacks);
213214
if (quickacks > icsk->icsk_ack.quick)
214-
icsk->icsk_ack.quick = min(quickacks, TCP_MAX_QUICKACKS);
215+
icsk->icsk_ack.quick = quickacks;
215216
}
216217

217-
static void tcp_enter_quickack_mode(struct sock *sk)
218+
static void tcp_enter_quickack_mode(struct sock *sk, unsigned int max_quickacks)
218219
{
219220
struct inet_connection_sock *icsk = inet_csk(sk);
220-
tcp_incr_quickack(sk);
221+
222+
tcp_incr_quickack(sk, max_quickacks);
221223
icsk->icsk_ack.pingpong = 0;
222224
icsk->icsk_ack.ato = TCP_ATO_MIN;
223225
}
@@ -261,15 +263,15 @@ static void __tcp_ecn_check_ce(struct tcp_sock *tp, const struct sk_buff *skb)
261263
* it is probably a retransmit.
262264
*/
263265
if (tp->ecn_flags & TCP_ECN_SEEN)
264-
tcp_enter_quickack_mode((struct sock *)tp);
266+
tcp_enter_quickack_mode((struct sock *)tp, 1);
265267
break;
266268
case INET_ECN_CE:
267269
if (tcp_ca_needs_ecn((struct sock *)tp))
268270
tcp_ca_event((struct sock *)tp, CA_EVENT_ECN_IS_CE);
269271

270272
if (!(tp->ecn_flags & TCP_ECN_DEMAND_CWR)) {
271273
/* Better not delay acks, sender can have a very low cwnd */
272-
tcp_enter_quickack_mode((struct sock *)tp);
274+
tcp_enter_quickack_mode((struct sock *)tp, 1);
273275
tp->ecn_flags |= TCP_ECN_DEMAND_CWR;
274276
}
275277
tp->ecn_flags |= TCP_ECN_SEEN;
@@ -686,7 +688,7 @@ static void tcp_event_data_recv(struct sock *sk, struct sk_buff *skb)
686688
/* The _first_ data packet received, initialize
687689
* delayed ACK engine.
688690
*/
689-
tcp_incr_quickack(sk);
691+
tcp_incr_quickack(sk, TCP_MAX_QUICKACKS);
690692
icsk->icsk_ack.ato = TCP_ATO_MIN;
691693
} else {
692694
int m = now - icsk->icsk_ack.lrcvtime;
@@ -702,7 +704,7 @@ static void tcp_event_data_recv(struct sock *sk, struct sk_buff *skb)
702704
/* Too long gap. Apparently sender failed to
703705
* restart window, so that we send ACKs quickly.
704706
*/
705-
tcp_incr_quickack(sk);
707+
tcp_incr_quickack(sk, TCP_MAX_QUICKACKS);
706708
sk_mem_reclaim(sk);
707709
}
708710
}
@@ -4179,7 +4181,7 @@ static void tcp_send_dupack(struct sock *sk, const struct sk_buff *skb)
41794181
if (TCP_SKB_CB(skb)->end_seq != TCP_SKB_CB(skb)->seq &&
41804182
before(TCP_SKB_CB(skb)->seq, tp->rcv_nxt)) {
41814183
NET_INC_STATS(sock_net(sk), LINUX_MIB_DELAYEDACKLOST);
4182-
tcp_enter_quickack_mode(sk);
4184+
tcp_enter_quickack_mode(sk, TCP_MAX_QUICKACKS);
41834185

41844186
if (tcp_is_sack(tp) && sock_net(sk)->ipv4.sysctl_tcp_dsack) {
41854187
u32 end_seq = TCP_SKB_CB(skb)->end_seq;
@@ -4706,7 +4708,7 @@ static void tcp_data_queue(struct sock *sk, struct sk_buff *skb)
47064708
tcp_dsack_set(sk, TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->end_seq);
47074709

47084710
out_of_window:
4709-
tcp_enter_quickack_mode(sk);
4711+
tcp_enter_quickack_mode(sk, TCP_MAX_QUICKACKS);
47104712
inet_csk_schedule_ack(sk);
47114713
drop:
47124714
tcp_drop(sk, skb);
@@ -5790,7 +5792,7 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb,
57905792
* to stand against the temptation 8) --ANK
57915793
*/
57925794
inet_csk_schedule_ack(sk);
5793-
tcp_enter_quickack_mode(sk);
5795+
tcp_enter_quickack_mode(sk, TCP_MAX_QUICKACKS);
57945796
inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK,
57955797
TCP_DELACK_MAX, TCP_RTO_MAX);
57965798

0 commit comments

Comments
 (0)