2022-11-25 22:29:50 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
/* MPTCP Fast Open Mechanism
|
|
|
|
*
|
|
|
|
* Copyright (c) 2021-2022, Dmytro SHYTYI
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "protocol.h"
|
|
|
|
|
2022-11-25 22:29:51 +00:00
|
|
|
void mptcp_fastopen_subflow_synack_set_params(struct mptcp_subflow_context *subflow,
|
|
|
|
struct request_sock *req)
|
|
|
|
{
|
2023-04-11 20:42:11 +00:00
|
|
|
struct sock *sk, *ssk;
|
2022-11-25 22:29:51 +00:00
|
|
|
struct sk_buff *skb;
|
|
|
|
struct tcp_sock *tp;
|
|
|
|
|
2023-04-11 20:42:11 +00:00
|
|
|
/* on early fallback the subflow context is deleted by
|
|
|
|
* subflow_syn_recv_sock()
|
|
|
|
*/
|
|
|
|
if (!subflow)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ssk = subflow->tcp_sock;
|
|
|
|
sk = subflow->conn;
|
2022-11-25 22:29:51 +00:00
|
|
|
tp = tcp_sk(ssk);
|
|
|
|
|
|
|
|
subflow->is_mptfo = 1;
|
|
|
|
|
|
|
|
skb = skb_peek(&ssk->sk_receive_queue);
|
|
|
|
if (WARN_ON_ONCE(!skb))
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* dequeue the skb from sk receive queue */
|
|
|
|
__skb_unlink(skb, &ssk->sk_receive_queue);
|
|
|
|
skb_ext_reset(skb);
|
|
|
|
skb_orphan(skb);
|
|
|
|
|
|
|
|
/* We copy the fastopen data, but that don't belong to the mptcp sequence
|
|
|
|
* space, need to offset it in the subflow sequence, see mptcp_subflow_get_map_offset()
|
|
|
|
*/
|
|
|
|
tp->copied_seq += skb->len;
|
|
|
|
subflow->ssn_offset += skb->len;
|
|
|
|
|
|
|
|
/* initialize a dummy sequence number, we will update it at MPC
|
|
|
|
* completion, if needed
|
|
|
|
*/
|
|
|
|
MPTCP_SKB_CB(skb)->map_seq = -skb->len;
|
|
|
|
MPTCP_SKB_CB(skb)->end_seq = 0;
|
|
|
|
MPTCP_SKB_CB(skb)->offset = 0;
|
|
|
|
MPTCP_SKB_CB(skb)->has_rxtstamp = TCP_SKB_CB(skb)->has_rxtstamp;
|
|
|
|
|
|
|
|
mptcp_data_lock(sk);
|
|
|
|
|
|
|
|
mptcp_set_owner_r(skb, sk);
|
|
|
|
__skb_queue_tail(&sk->sk_receive_queue, skb);
|
2023-10-23 20:44:35 +00:00
|
|
|
mptcp_sk(sk)->bytes_received += skb->len;
|
2022-11-25 22:29:51 +00:00
|
|
|
|
|
|
|
sk->sk_data_ready(sk);
|
|
|
|
|
|
|
|
mptcp_data_unlock(sk);
|
|
|
|
}
|
|
|
|
|
2024-02-08 18:03:52 +00:00
|
|
|
void __mptcp_fastopen_gen_msk_ackseq(struct mptcp_sock *msk, struct mptcp_subflow_context *subflow,
|
|
|
|
const struct mptcp_options_received *mp_opt)
|
2022-11-25 22:29:50 +00:00
|
|
|
{
|
|
|
|
struct sock *sk = (struct sock *)msk;
|
|
|
|
struct sk_buff *skb;
|
|
|
|
|
|
|
|
skb = skb_peek_tail(&sk->sk_receive_queue);
|
|
|
|
if (skb) {
|
|
|
|
WARN_ON_ONCE(MPTCP_SKB_CB(skb)->end_seq);
|
mptcp: pr_debug: add missing \n at the end
pr_debug() have been added in various places in MPTCP code to help
developers to debug some situations. With the dynamic debug feature, it
is easy to enable all or some of them, and asks users to reproduce
issues with extra debug.
Many of these pr_debug() don't end with a new line, while no 'pr_cont()'
are used in MPTCP code. So the goal was not to display multiple debug
messages on one line: they were then not missing the '\n' on purpose.
Not having the new line at the end causes these messages to be printed
with a delay, when something else needs to be printed. This issue is not
visible when many messages need to be printed, but it is annoying and
confusing when only specific messages are expected, e.g.
# echo "func mptcp_pm_add_addr_echoed +fmp" \
> /sys/kernel/debug/dynamic_debug/control
# ./mptcp_join.sh "signal address"; \
echo "$(awk '{print $1}' /proc/uptime) - end"; \
sleep 5s; \
echo "$(awk '{print $1}' /proc/uptime) - restart"; \
./mptcp_join.sh "signal address"
013 signal address
(...)
10.75 - end
15.76 - restart
013 signal address
[ 10.367935] mptcp:mptcp_pm_add_addr_echoed: MPTCP: msk=(...)
(...)
=> a delay of 5 seconds: printed with a 10.36 ts, but after 'restart'
which was printed at the 15.76 ts.
The 'Fixes' tag here below points to the first pr_debug() used without
'\n' in net/mptcp. This patch could be split in many small ones, with
different Fixes tag, but it doesn't seem worth it, because it is easy to
re-generate this patch with this simple 'sed' command:
git grep -l pr_debug -- net/mptcp |
xargs sed -i "s/\(pr_debug(\".*[^n]\)\(\"[,)]\)/\1\\\n\2/g"
So in case of conflicts, simply drop the modifications, and launch this
command.
Fixes: f870fa0b5768 ("mptcp: Add MPTCP socket stubs")
Cc: stable@vger.kernel.org
Reviewed-by: Geliang Tang <geliang@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://patch.msgid.link/20240826-net-mptcp-close-extra-sf-fin-v1-4-905199fe1172@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2024-08-26 17:11:21 +00:00
|
|
|
pr_debug("msk %p moving seq %llx -> %llx end_seq %llx -> %llx\n", sk,
|
2022-11-25 22:29:50 +00:00
|
|
|
MPTCP_SKB_CB(skb)->map_seq, MPTCP_SKB_CB(skb)->map_seq + msk->ack_seq,
|
|
|
|
MPTCP_SKB_CB(skb)->end_seq, MPTCP_SKB_CB(skb)->end_seq + msk->ack_seq);
|
|
|
|
MPTCP_SKB_CB(skb)->map_seq += msk->ack_seq;
|
|
|
|
MPTCP_SKB_CB(skb)->end_seq += msk->ack_seq;
|
|
|
|
}
|
|
|
|
|
mptcp: pr_debug: add missing \n at the end
pr_debug() have been added in various places in MPTCP code to help
developers to debug some situations. With the dynamic debug feature, it
is easy to enable all or some of them, and asks users to reproduce
issues with extra debug.
Many of these pr_debug() don't end with a new line, while no 'pr_cont()'
are used in MPTCP code. So the goal was not to display multiple debug
messages on one line: they were then not missing the '\n' on purpose.
Not having the new line at the end causes these messages to be printed
with a delay, when something else needs to be printed. This issue is not
visible when many messages need to be printed, but it is annoying and
confusing when only specific messages are expected, e.g.
# echo "func mptcp_pm_add_addr_echoed +fmp" \
> /sys/kernel/debug/dynamic_debug/control
# ./mptcp_join.sh "signal address"; \
echo "$(awk '{print $1}' /proc/uptime) - end"; \
sleep 5s; \
echo "$(awk '{print $1}' /proc/uptime) - restart"; \
./mptcp_join.sh "signal address"
013 signal address
(...)
10.75 - end
15.76 - restart
013 signal address
[ 10.367935] mptcp:mptcp_pm_add_addr_echoed: MPTCP: msk=(...)
(...)
=> a delay of 5 seconds: printed with a 10.36 ts, but after 'restart'
which was printed at the 15.76 ts.
The 'Fixes' tag here below points to the first pr_debug() used without
'\n' in net/mptcp. This patch could be split in many small ones, with
different Fixes tag, but it doesn't seem worth it, because it is easy to
re-generate this patch with this simple 'sed' command:
git grep -l pr_debug -- net/mptcp |
xargs sed -i "s/\(pr_debug(\".*[^n]\)\(\"[,)]\)/\1\\\n\2/g"
So in case of conflicts, simply drop the modifications, and launch this
command.
Fixes: f870fa0b5768 ("mptcp: Add MPTCP socket stubs")
Cc: stable@vger.kernel.org
Reviewed-by: Geliang Tang <geliang@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://patch.msgid.link/20240826-net-mptcp-close-extra-sf-fin-v1-4-905199fe1172@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2024-08-26 17:11:21 +00:00
|
|
|
pr_debug("msk=%p ack_seq=%llx\n", msk, msk->ack_seq);
|
2022-11-25 22:29:50 +00:00
|
|
|
}
|