From 809d4ffb7b96de4f79c66bb3875aefbae4bc7de3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Finfe?= Date: Tue, 18 Jul 2017 00:33:31 +0200 Subject: [PATCH] mptcp: change MP_FASTCLOSE retransmissions limit to const MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MP_FASTCLOSE retransmissions limit is defined by the sysctl net.ipv4.tcp_retries2. Its default value is 15. This value also influences the timeout of an alive TCP connection, when RTO retransmissions remain unacknowledged. RFC 1122 recommends at least 100 s for the timeout, which corresponds to a value of at least 8. RFC 6824 (section 3.5) recommends a limit of 3 retransmissions. These requirements are not compatible. The limit of MP_FASTCLOSE retransmissions should not be shared with net.ipv4.tcp_retries2 but rather uses its own limit. Moreover, the limit of MP_FASTCLOSE retransmissions is implemented via a timeout (time limit), where the RFC 6824 specifies it as a count of retransmissions. This patch defines the limitations of MP_FASTCLOSE retransmissions as a constant (MPTCP_FASTCLOSE_RETRIES), replacing the sysctl tcp_retries2. The limitation of retransmissions is implemented via a count of retransmissions instead of a timeout. Exponential backoff reverting on ICMP destination unreachable is also preventively disabled on the socket used for sending MP_FASTCLOSE. It may happen that when the first MP_FASTCLOSE is sent, the retransmission counter of the socket (icsk_retransmits) is not null, due to a previous unacknowledged tcp retransmission. After the first MP_FASTCLOSE transmission, icsk_retransmits counts the number MP_FASTCLOSE retransmissions. This patch clears icsk_retransmits when the first MP_FASTCLOSE is sent, to properly count the number of MP_FASTCLOSE retransmissions. Thanks to Christoph Paasch for this suggestion. Fixes: 8248fb288e (Support sending/receiving of MPTCP_RST) Signed-off-by: François Finfe Signed-off-by: Christoph Paasch (cherry picked from commit d9a6284c64d66513adf057ce1a8d5cd324f8fcd7) Signed-off-by: Christoph Paasch --- include/net/mptcp.h | 3 +++ net/ipv4/tcp_timer.c | 4 +++- net/mptcp/mptcp_output.c | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/net/mptcp.h b/include/net/mptcp.h index 1147d1f57fed5a..b868c5383d9e04 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -429,6 +429,9 @@ struct mptcp_cb { #define OPTION_MPTCP (1 << 5) +/* Max number of fastclose retransmissions */ +#define MPTCP_FASTCLOSE_RETRIES 3 + #ifdef CONFIG_MPTCP /* Used for checking if the mptcp initialization has been successful */ diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c index cd6ceb7bca5937..d34a39a941d77a 100644 --- a/net/ipv4/tcp_timer.c +++ b/net/ipv4/tcp_timer.c @@ -621,8 +621,10 @@ static void tcp_keepalive_timer (unsigned long data) if (!tp->retrans_stamp) tp->retrans_stamp = tcp_time_stamp ? : 1; - if (tcp_write_timeout(sk)) + if (icsk->icsk_retransmits >= MPTCP_FASTCLOSE_RETRIES) { + tcp_write_err(sk); goto out; + } tcp_send_ack(sk); icsk->icsk_retransmits++; diff --git a/net/mptcp/mptcp_output.c b/net/mptcp/mptcp_output.c index b8560e1affd770..3861c4afac012d 100644 --- a/net/mptcp/mptcp_output.c +++ b/net/mptcp/mptcp_output.c @@ -1314,6 +1314,10 @@ void mptcp_send_active_reset(struct sock *meta_sk, gfp_t priority) inet_csk_reset_keepalive_timer(sk, inet_csk(sk)->icsk_rto); meta_tp->send_mp_fclose = 1; + inet_csk(sk)->icsk_retransmits = 0; + + /* Prevent exp backoff reverting on ICMP dest unreachable */ + inet_csk(sk)->icsk_backoff = 0; MPTCP_INC_STATS(sock_net(meta_sk), MPTCP_MIB_FASTCLOSETX); }