Skip to content

Commit a0c1d0e

Browse files
cpaaschdavem330
authored andcommitted
mptcp: Use 32-bit DATA_ACK when possible
RFC8684 allows to send 32-bit DATA_ACKs as long as the peer is not sending 64-bit data-sequence numbers. The 64-bit DSN is only there for extreme scenarios when a very high throughput subflow is combined with a long-RTT subflow such that the high-throughput subflow wraps around the 32-bit sequence number space within an RTT of the high-RTT subflow. It is thus a rare scenario and we should try to use the 32-bit DATA_ACK instead as long as possible. It allows to reduce the TCP-option overhead by 4 bytes, thus makes space for an additional SACK-block. It also makes tcpdumps much easier to read when the DSN and DATA_ACK are both either 32 or 64-bit. Signed-off-by: Christoph Paasch <cpaasch@apple.com> Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 9efd6a3 commit a0c1d0e

4 files changed

Lines changed: 31 additions & 10 deletions

File tree

‎include/net/mptcp.h‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ struct seq_file;
1616

1717
/* MPTCP sk_buff extension data */
1818
struct mptcp_ext {
19-
u64 data_ack;
19+
union {
20+
u64 data_ack;
21+
u32 data_ack32;
22+
};
2023
u64 data_seq;
2124
u32 subflow_seq;
2225
u16 data_len;

‎net/mptcp/options.c‎

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -516,18 +516,23 @@ static bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb,
516516
return ret;
517517
}
518518

519-
ack_size = TCPOLEN_MPTCP_DSS_ACK64;
519+
if (subflow->use_64bit_ack) {
520+
ack_size = TCPOLEN_MPTCP_DSS_ACK64;
521+
opts->ext_copy.data_ack = msk->ack_seq;
522+
opts->ext_copy.ack64 = 1;
523+
} else {
524+
ack_size = TCPOLEN_MPTCP_DSS_ACK32;
525+
opts->ext_copy.data_ack32 = (uint32_t)(msk->ack_seq);
526+
opts->ext_copy.ack64 = 0;
527+
}
528+
opts->ext_copy.use_ack = 1;
520529

521530
/* Add kind/length/subtype/flag overhead if mapping is not populated */
522531
if (dss_size == 0)
523532
ack_size += TCPOLEN_MPTCP_DSS_BASE;
524533

525534
dss_size += ack_size;
526535

527-
opts->ext_copy.data_ack = msk->ack_seq;
528-
opts->ext_copy.ack64 = 1;
529-
opts->ext_copy.use_ack = 1;
530-
531536
*size = ALIGN(dss_size, 4);
532537
return true;
533538
}
@@ -986,8 +991,13 @@ void mptcp_write_options(__be32 *ptr, struct mptcp_out_options *opts)
986991
u8 flags = 0;
987992

988993
if (mpext->use_ack) {
989-
len += TCPOLEN_MPTCP_DSS_ACK64;
990-
flags = MPTCP_DSS_HAS_ACK | MPTCP_DSS_ACK64;
994+
flags = MPTCP_DSS_HAS_ACK;
995+
if (mpext->ack64) {
996+
len += TCPOLEN_MPTCP_DSS_ACK64;
997+
flags |= MPTCP_DSS_ACK64;
998+
} else {
999+
len += TCPOLEN_MPTCP_DSS_ACK32;
1000+
}
9911001
}
9921002

9931003
if (mpext->use_map) {
@@ -1004,8 +1014,13 @@ void mptcp_write_options(__be32 *ptr, struct mptcp_out_options *opts)
10041014
*ptr++ = mptcp_option(MPTCPOPT_DSS, len, 0, flags);
10051015

10061016
if (mpext->use_ack) {
1007-
put_unaligned_be64(mpext->data_ack, ptr);
1008-
ptr += 2;
1017+
if (mpext->ack64) {
1018+
put_unaligned_be64(mpext->data_ack, ptr);
1019+
ptr += 2;
1020+
} else {
1021+
put_unaligned_be32(mpext->data_ack32, ptr);
1022+
ptr += 1;
1023+
}
10091024
}
10101025

10111026
if (mpext->use_map) {

‎net/mptcp/protocol.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ struct mptcp_subflow_context {
290290
data_avail : 1,
291291
rx_eof : 1,
292292
data_fin_tx_enable : 1,
293+
use_64bit_ack : 1, /* Set when we received a 64-bit DSN */
293294
can_ack : 1; /* only after processing the remote a key */
294295
u64 data_fin_tx_seq;
295296
u32 remote_nonce;

‎net/mptcp/subflow.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,9 +667,11 @@ static enum mapping_status get_mapping_status(struct sock *ssk)
667667
if (!mpext->dsn64) {
668668
map_seq = expand_seq(subflow->map_seq, subflow->map_data_len,
669669
mpext->data_seq);
670+
subflow->use_64bit_ack = 0;
670671
pr_debug("expanded seq=%llu", subflow->map_seq);
671672
} else {
672673
map_seq = mpext->data_seq;
674+
subflow->use_64bit_ack = 1;
673675
}
674676

675677
if (subflow->map_valid) {

0 commit comments

Comments
 (0)