tcp_current_mss() calls mptcp_established_options() without skb, to
know the size of the options. A pending RM_ADDR was then taken: its
signal bit was cleared, and RmAddrTx was incremented, but it was not
sent. The peer then never learnt that the address was not valid any
more. An ADD_ADDR is not affected: it is only sent with a pure ACK.
Without skb, only reserve the size of the RM_ADDR, and keep it pending
for the packet that will be sent.
This issue has been reported by Clashiko, while reviewing commit
"mptcp: pm: don't drop an RM_ADDR because of an ADD_ADDR", and
confirmed with a script: data was sent while the RM_ADDR was pending.
RmAddrTx was then 1 on the sender, but RmAddr 0 on the receiver.
Fixes: 5cb104ae55e9 ("mptcp: add the outgoing RM_ADDR support")
Signed-off-by: Matthieu Baerts (NGI0) <matt…@kernel.org>
---
net/mptcp/options.c | 12 +++++++++---
net/mptcp/pm.c | 8 ++++++--
net/mptcp/protocol.h | 3 ++-
3 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/net/mptcp/options.c b/net/mptcp/options.c
index 617358ff7f99..3b10884526b0 100644
--- a/net/mptcp/options.c
+++ b/net/mptcp/options.c
@@ -762,7 +762,8 @@ static bool mptcp_established_options_add_addr(struct sock *sk,
return true;
}
-static bool mptcp_established_options_rm_addr(struct sock *sk, int *size,
+static bool mptcp_established_options_rm_addr(struct sock *sk,
+ struct sk_buff *skb, int *size,
unsigned int remaining,
struct mptcp_out_options *opts)
{
@@ -772,9 +773,13 @@ static bool mptcp_established_options_rm_addr(struct sock *sk, int *size,
int i;
if (!mptcp_pm_should_rm_signal(msk) ||
- !(mptcp_pm_rm_addr_signal(msk, remaining, &rm_list, size)))
+ !(mptcp_pm_rm_addr_signal(msk, remaining, &rm_list, size, !skb)))
return false;
+ /* without skb, only the size is needed: keep it for the next packet */
+ if (!skb)
+ return true;
+
opts->suboptions |= OPTION_MPTCP_RM_ADDR;
opts->rm_list = rm_list;
@@ -933,7 +938,8 @@ int mptcp_established_options(struct sock *sk, struct sk_buff *skb,
total_size += opt_size;
remaining -= opt_size;
ret = true;
- } else if (mptcp_established_options_rm_addr(sk, &opt_size, remaining, opts)) {
+ } else if (mptcp_established_options_rm_addr(sk, skb, &opt_size,
+ remaining, opts)) {
total_size += opt_size;
remaining -= opt_size;
ret = true;
diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c
index f12a8bfbb2a9..1d114e3b3284 100644
--- a/net/mptcp/pm.c
+++ b/net/mptcp/pm.c
@@ -1016,7 +1016,8 @@ static int mptcp_rm_addr_len(const struct mptcp_rm_list *rm_list)
}
bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
- struct mptcp_rm_list *rm_list, int *size)
+ struct mptcp_rm_list *rm_list, int *size,
+ bool size_only)
{
int ret = false, len;
u8 rm_addr;
@@ -1037,9 +1038,12 @@ bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
goto out_unlock;
*size = len;
+ ret = true;
+ if (size_only)
+ goto out_unlock;
+
*rm_list = msk->pm.rm_list_tx;
WRITE_ONCE(msk->pm.addr_signal, rm_addr);
- ret = true;
out_unlock:
spin_unlock_bh(&msk->pm.lock);
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index 7644651f01a8..255b2e761f7d 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -1243,7 +1243,8 @@ bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, int *size, int remaining,
struct mptcp_addr_info *addr, bool *echo,
bool *drop_ts);
bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
- struct mptcp_rm_list *rm_list, int *len);
+ struct mptcp_rm_list *rm_list, int *len,
+ bool size_only);
int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc);
int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk,
struct mptcp_pm_addr_entry *skc);
--
2.55.0