Skip to content

Commit ae70b61

Browse files
yuchungchenggregkh
authored andcommitted
tcp: do not delay ACK in DCTCP upon CE status change
[ Upstream commit a0496ef ] Per DCTCP RFC8257 (Section 3.2) the ACK reflecting the CE status change has to be sent immediately so the sender can respond quickly: """ When receiving packets, the CE codepoint MUST be processed as follows: 1. If the CE codepoint is set and DCTCP.CE is false, set DCTCP.CE to true and send an immediate ACK. 2. If the CE codepoint is not set and DCTCP.CE is true, set DCTCP.CE to false and send an immediate ACK. """ Previously DCTCP implementation may continue to delay the ACK. This patch fixes that to implement the RFC by forcing an immediate ACK. Tested with this packetdrill script provided by Larry Brakmo 0.000 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3 0.000 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 0.000 setsockopt(3, SOL_TCP, TCP_CONGESTION, "dctcp", 5) = 0 0.000 bind(3, ..., ...) = 0 0.000 listen(3, 1) = 0 0.100 < [ect0] SEW 0:0(0) win 32792 <mss 1000,sackOK,nop,nop,nop,wscale 7> 0.100 > SE. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK,nop,wscale 8> 0.110 < [ect0] . 1:1(0) ack 1 win 257 0.200 accept(3, ..., ...) = 4 +0 setsockopt(4, SOL_SOCKET, SO_DEBUG, [1], 4) = 0 0.200 < [ect0] . 1:1001(1000) ack 1 win 257 0.200 > [ect01] . 1:1(0) ack 1001 0.200 write(4, ..., 1) = 1 0.200 > [ect01] P. 1:2(1) ack 1001 0.200 < [ect0] . 1001:2001(1000) ack 2 win 257 +0.005 < [ce] . 2001:3001(1000) ack 2 win 257 +0.000 > [ect01] . 2:2(0) ack 2001 // Previously the ACK below would be delayed by 40ms +0.000 > [ect01] E. 2:2(0) ack 3001 +0.500 < F. 9501:9501(0) ack 4 win 257 Signed-off-by: Yuchung Cheng <ycheng@google.com> Acked-by: Neal Cardwell <ncardwell@google.com> Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 7863617 commit ae70b61

3 files changed

Lines changed: 21 additions & 13 deletions

File tree

‎include/net/tcp.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ ssize_t tcp_splice_read(struct socket *sk, loff_t *ppos,
372372
struct pipe_inode_info *pipe, size_t len,
373373
unsigned int flags);
374374

375+
void tcp_enter_quickack_mode(struct sock *sk);
375376
static inline void tcp_dec_quickack_mode(struct sock *sk,
376377
const unsigned int pkts)
377378
{

‎net/ipv4/tcp_dctcp.c‎

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,15 @@ static void dctcp_ce_state_0_to_1(struct sock *sk)
131131
struct dctcp *ca = inet_csk_ca(sk);
132132
struct tcp_sock *tp = tcp_sk(sk);
133133

134-
/* State has changed from CE=0 to CE=1 and delayed
135-
* ACK has not sent yet.
136-
*/
137-
if (!ca->ce_state &&
138-
inet_csk(sk)->icsk_ack.pending & ICSK_ACK_TIMER)
139-
__tcp_send_ack(sk, ca->prior_rcv_nxt);
134+
if (!ca->ce_state) {
135+
/* State has changed from CE=0 to CE=1, force an immediate
136+
* ACK to reflect the new CE state. If an ACK was delayed,
137+
* send that first to reflect the prior CE state.
138+
*/
139+
if (inet_csk(sk)->icsk_ack.pending & ICSK_ACK_TIMER)
140+
__tcp_send_ack(sk, ca->prior_rcv_nxt);
141+
tcp_enter_quickack_mode(sk);
142+
}
140143

141144
ca->prior_rcv_nxt = tp->rcv_nxt;
142145
ca->ce_state = 1;
@@ -149,12 +152,15 @@ static void dctcp_ce_state_1_to_0(struct sock *sk)
149152
struct dctcp *ca = inet_csk_ca(sk);
150153
struct tcp_sock *tp = tcp_sk(sk);
151154

152-
/* State has changed from CE=1 to CE=0 and delayed
153-
* ACK has not sent yet.
154-
*/
155-
if (ca->ce_state &&
156-
inet_csk(sk)->icsk_ack.pending & ICSK_ACK_TIMER)
157-
__tcp_send_ack(sk, ca->prior_rcv_nxt);
155+
if (ca->ce_state) {
156+
/* State has changed from CE=1 to CE=0, force an immediate
157+
* ACK to reflect the new CE state. If an ACK was delayed,
158+
* send that first to reflect the prior CE state.
159+
*/
160+
if (inet_csk(sk)->icsk_ack.pending & ICSK_ACK_TIMER)
161+
__tcp_send_ack(sk, ca->prior_rcv_nxt);
162+
tcp_enter_quickack_mode(sk);
163+
}
158164

159165
ca->prior_rcv_nxt = tp->rcv_nxt;
160166
ca->ce_state = 0;

‎net/ipv4/tcp_input.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,14 @@ static void tcp_incr_quickack(struct sock *sk)
209209
icsk->icsk_ack.quick = min(quickacks, TCP_MAX_QUICKACKS);
210210
}
211211

212-
static void tcp_enter_quickack_mode(struct sock *sk)
212+
void tcp_enter_quickack_mode(struct sock *sk)
213213
{
214214
struct inet_connection_sock *icsk = inet_csk(sk);
215215
tcp_incr_quickack(sk);
216216
icsk->icsk_ack.pingpong = 0;
217217
icsk->icsk_ack.ato = TCP_ATO_MIN;
218218
}
219+
EXPORT_SYMBOL(tcp_enter_quickack_mode);
219220

220221
/* Send ACKs quickly, if "quick" count is not exhausted
221222
* and the session is not interactive.

0 commit comments

Comments
 (0)