2020-03-27 21:48:38 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
/* Multipath TCP
|
|
|
|
*
|
|
|
|
* Copyright (c) 2019, Intel Corporation.
|
|
|
|
*/
|
2020-04-03 09:14:08 +00:00
|
|
|
#define pr_fmt(fmt) "MPTCP: " fmt
|
|
|
|
|
2020-03-27 21:48:38 +00:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <net/mptcp.h>
|
|
|
|
#include "protocol.h"
|
|
|
|
|
2021-08-13 22:15:46 +00:00
|
|
|
#include "mib.h"
|
|
|
|
|
2020-03-27 21:48:38 +00:00
|
|
|
/* path manager command handlers */
|
|
|
|
|
|
|
|
int mptcp_pm_announce_addr(struct mptcp_sock *msk,
|
2020-09-24 00:29:50 +00:00
|
|
|
const struct mptcp_addr_info *addr,
|
2021-03-26 18:26:31 +00:00
|
|
|
bool echo)
|
2020-03-27 21:48:38 +00:00
|
|
|
{
|
2020-12-09 23:51:27 +00:00
|
|
|
u8 add_addr = READ_ONCE(msk->pm.addr_signal);
|
2020-11-19 19:45:59 +00:00
|
|
|
|
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, local_id=%d, echo=%d\n", msk, addr->id, echo);
|
2020-03-27 21:48:41 +00:00
|
|
|
|
2021-02-04 23:23:30 +00:00
|
|
|
lockdep_assert_held(&msk->pm.lock);
|
|
|
|
|
2021-08-24 01:05:40 +00:00
|
|
|
if (add_addr &
|
|
|
|
(echo ? BIT(MPTCP_ADD_ADDR_ECHO) : BIT(MPTCP_ADD_ADDR_SIGNAL))) {
|
2023-05-17 19:16:16 +00:00
|
|
|
MPTCP_INC_STATS(sock_net((struct sock *)msk),
|
|
|
|
echo ? MPTCP_MIB_ECHOADDTXDROP : MPTCP_MIB_ADDADDRTXDROP);
|
2020-12-09 23:51:26 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2021-08-24 01:05:40 +00:00
|
|
|
if (echo) {
|
|
|
|
msk->pm.remote = *addr;
|
2020-11-19 19:45:59 +00:00
|
|
|
add_addr |= BIT(MPTCP_ADD_ADDR_ECHO);
|
2021-08-24 01:05:40 +00:00
|
|
|
} else {
|
|
|
|
msk->pm.local = *addr;
|
|
|
|
add_addr |= BIT(MPTCP_ADD_ADDR_SIGNAL);
|
|
|
|
}
|
2020-12-09 23:51:27 +00:00
|
|
|
WRITE_ONCE(msk->pm.addr_signal, add_addr);
|
2020-03-27 21:48:41 +00:00
|
|
|
return 0;
|
2020-03-27 21:48:38 +00:00
|
|
|
}
|
|
|
|
|
2021-03-13 01:16:12 +00:00
|
|
|
int mptcp_pm_remove_addr(struct mptcp_sock *msk, const struct mptcp_rm_list *rm_list)
|
2020-03-27 21:48:38 +00:00
|
|
|
{
|
2020-12-09 23:51:27 +00:00
|
|
|
u8 rm_addr = READ_ONCE(msk->pm.addr_signal);
|
2020-12-09 23:51:26 +00:00
|
|
|
|
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, rm_list_nr=%d\n", msk, rm_list->nr);
|
2020-09-24 00:29:54 +00:00
|
|
|
|
2020-12-09 23:51:26 +00:00
|
|
|
if (rm_addr) {
|
2023-05-17 19:16:16 +00:00
|
|
|
MPTCP_ADD_STATS(sock_net((struct sock *)msk),
|
|
|
|
MPTCP_MIB_RMADDRTXDROP, rm_list->nr);
|
2020-12-09 23:51:26 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2021-03-13 01:16:12 +00:00
|
|
|
msk->pm.rm_list_tx = *rm_list;
|
2020-12-09 23:51:26 +00:00
|
|
|
rm_addr |= BIT(MPTCP_RM_ADDR_SIGNAL);
|
2020-12-09 23:51:27 +00:00
|
|
|
WRITE_ONCE(msk->pm.addr_signal, rm_addr);
|
2021-03-26 18:26:41 +00:00
|
|
|
mptcp_pm_nl_addr_send_ack(msk);
|
2020-09-24 00:29:54 +00:00
|
|
|
return 0;
|
2020-03-27 21:48:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* path manager event handlers */
|
|
|
|
|
2021-02-12 23:59:58 +00:00
|
|
|
void mptcp_pm_new_connection(struct mptcp_sock *msk, const struct sock *ssk, int server_side)
|
2020-03-27 21:48:38 +00:00
|
|
|
{
|
|
|
|
struct mptcp_pm_data *pm = &msk->pm;
|
|
|
|
|
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, token=%u side=%d\n", msk, READ_ONCE(msk->token), server_side);
|
2020-03-27 21:48:38 +00:00
|
|
|
|
|
|
|
WRITE_ONCE(pm->server_side, server_side);
|
2021-02-13 00:00:01 +00:00
|
|
|
mptcp_event(MPTCP_EVENT_CREATED, msk, ssk, GFP_ATOMIC);
|
2020-03-27 21:48:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool mptcp_pm_allow_new_subflow(struct mptcp_sock *msk)
|
|
|
|
{
|
2020-03-27 21:48:41 +00:00
|
|
|
struct mptcp_pm_data *pm = &msk->pm;
|
2021-02-01 23:09:07 +00:00
|
|
|
unsigned int subflows_max;
|
2020-09-24 00:29:53 +00:00
|
|
|
int ret = 0;
|
2020-03-27 21:48:41 +00:00
|
|
|
|
2023-06-05 03:25:21 +00:00
|
|
|
if (mptcp_pm_is_userspace(msk)) {
|
|
|
|
if (mptcp_userspace_pm_active(msk)) {
|
|
|
|
spin_lock_bh(&pm->lock);
|
|
|
|
pm->subflows++;
|
|
|
|
spin_unlock_bh(&pm->lock);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2022-05-02 20:52:31 +00:00
|
|
|
|
2021-02-01 23:09:07 +00:00
|
|
|
subflows_max = mptcp_pm_get_subflows_max(msk);
|
|
|
|
|
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 subflows=%d max=%d allow=%d\n", msk, pm->subflows,
|
2021-02-01 23:09:07 +00:00
|
|
|
subflows_max, READ_ONCE(pm->accept_subflow));
|
2020-03-27 21:48:41 +00:00
|
|
|
|
|
|
|
/* try to avoid acquiring the lock below */
|
|
|
|
if (!READ_ONCE(pm->accept_subflow))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
spin_lock_bh(&pm->lock);
|
2020-09-24 00:29:53 +00:00
|
|
|
if (READ_ONCE(pm->accept_subflow)) {
|
2021-02-01 23:09:07 +00:00
|
|
|
ret = pm->subflows < subflows_max;
|
|
|
|
if (ret && ++pm->subflows == subflows_max)
|
2020-09-24 00:29:53 +00:00
|
|
|
WRITE_ONCE(pm->accept_subflow, false);
|
|
|
|
}
|
2020-03-27 21:48:41 +00:00
|
|
|
spin_unlock_bh(&pm->lock);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* return true if the new status bit is currently cleared, that is, this event
|
|
|
|
* can be server, eventually by an already scheduled work
|
|
|
|
*/
|
|
|
|
static bool mptcp_pm_schedule_work(struct mptcp_sock *msk,
|
|
|
|
enum mptcp_pm_status new_status)
|
|
|
|
{
|
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 status=%x new=%lx\n", msk, msk->pm.status,
|
2020-03-27 21:48:41 +00:00
|
|
|
BIT(new_status));
|
|
|
|
if (msk->pm.status & BIT(new_status))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
msk->pm.status |= BIT(new_status);
|
2020-11-16 09:48:05 +00:00
|
|
|
mptcp_schedule_work((struct sock *)msk);
|
2020-03-27 21:48:41 +00:00
|
|
|
return true;
|
2020-03-27 21:48:38 +00:00
|
|
|
}
|
|
|
|
|
2023-04-14 14:08:00 +00:00
|
|
|
void mptcp_pm_fully_established(struct mptcp_sock *msk, const struct sock *ssk)
|
2020-03-27 21:48:38 +00:00
|
|
|
{
|
2020-03-27 21:48:41 +00:00
|
|
|
struct mptcp_pm_data *pm = &msk->pm;
|
2021-02-13 00:00:01 +00:00
|
|
|
bool announce = false;
|
2020-03-27 21:48:41 +00:00
|
|
|
|
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\n", msk);
|
2020-03-27 21:48:41 +00:00
|
|
|
|
|
|
|
spin_lock_bh(&pm->lock);
|
|
|
|
|
2020-12-09 11:03:29 +00:00
|
|
|
/* mptcp_pm_fully_established() can be invoked by multiple
|
|
|
|
* racing paths - accept() and check_fully_established()
|
|
|
|
* be sure to serve this event only once.
|
|
|
|
*/
|
|
|
|
if (READ_ONCE(pm->work_pending) &&
|
|
|
|
!(msk->pm.status & BIT(MPTCP_PM_ALREADY_ESTABLISHED)))
|
2020-03-27 21:48:41 +00:00
|
|
|
mptcp_pm_schedule_work(msk, MPTCP_PM_ESTABLISHED);
|
|
|
|
|
2021-02-13 00:00:01 +00:00
|
|
|
if ((msk->pm.status & BIT(MPTCP_PM_ALREADY_ESTABLISHED)) == 0)
|
|
|
|
announce = true;
|
|
|
|
|
|
|
|
msk->pm.status |= BIT(MPTCP_PM_ALREADY_ESTABLISHED);
|
2020-03-27 21:48:41 +00:00
|
|
|
spin_unlock_bh(&pm->lock);
|
2021-02-13 00:00:01 +00:00
|
|
|
|
|
|
|
if (announce)
|
2023-04-14 14:08:00 +00:00
|
|
|
mptcp_event(MPTCP_EVENT_ESTABLISHED, msk, ssk, GFP_ATOMIC);
|
2020-03-27 21:48:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void mptcp_pm_connection_closed(struct mptcp_sock *msk)
|
|
|
|
{
|
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\n", msk);
|
2024-10-21 15:14:05 +00:00
|
|
|
|
|
|
|
if (msk->token)
|
|
|
|
mptcp_event(MPTCP_EVENT_CLOSED, msk, NULL, GFP_KERNEL);
|
2020-03-27 21:48:38 +00:00
|
|
|
}
|
|
|
|
|
2021-03-26 18:26:33 +00:00
|
|
|
void mptcp_pm_subflow_established(struct mptcp_sock *msk)
|
2020-03-27 21:48:38 +00:00
|
|
|
{
|
2020-03-27 21:48:41 +00:00
|
|
|
struct mptcp_pm_data *pm = &msk->pm;
|
|
|
|
|
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\n", msk);
|
2020-03-27 21:48:41 +00:00
|
|
|
|
|
|
|
if (!READ_ONCE(pm->work_pending))
|
|
|
|
return;
|
|
|
|
|
|
|
|
spin_lock_bh(&pm->lock);
|
|
|
|
|
|
|
|
if (READ_ONCE(pm->work_pending))
|
|
|
|
mptcp_pm_schedule_work(msk, MPTCP_PM_SUBFLOW_ESTABLISHED);
|
|
|
|
|
|
|
|
spin_unlock_bh(&pm->lock);
|
2020-03-27 21:48:38 +00:00
|
|
|
}
|
|
|
|
|
2023-10-25 23:37:05 +00:00
|
|
|
void mptcp_pm_subflow_check_next(struct mptcp_sock *msk,
|
2022-01-07 00:20:23 +00:00
|
|
|
const struct mptcp_subflow_context *subflow)
|
2020-03-27 21:48:38 +00:00
|
|
|
{
|
2022-01-07 00:20:23 +00:00
|
|
|
struct mptcp_pm_data *pm = &msk->pm;
|
|
|
|
bool update_subflows;
|
|
|
|
|
2023-06-05 03:25:21 +00:00
|
|
|
update_subflows = subflow->request_join || subflow->mp_join;
|
|
|
|
if (mptcp_pm_is_userspace(msk)) {
|
|
|
|
if (update_subflows) {
|
|
|
|
spin_lock_bh(&pm->lock);
|
|
|
|
pm->subflows--;
|
|
|
|
spin_unlock_bh(&pm->lock);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-01-07 00:20:23 +00:00
|
|
|
if (!READ_ONCE(pm->work_pending) && !update_subflows)
|
|
|
|
return;
|
|
|
|
|
|
|
|
spin_lock_bh(&pm->lock);
|
|
|
|
if (update_subflows)
|
2022-05-12 23:26:41 +00:00
|
|
|
__mptcp_pm_close_subflow(msk);
|
2022-01-07 00:20:23 +00:00
|
|
|
|
|
|
|
/* Even if this subflow is not really established, tell the PM to try
|
|
|
|
* to pick the next ones, if possible.
|
|
|
|
*/
|
|
|
|
if (mptcp_pm_nl_check_work_pending(msk))
|
|
|
|
mptcp_pm_schedule_work(msk, MPTCP_PM_SUBFLOW_ESTABLISHED);
|
|
|
|
|
|
|
|
spin_unlock_bh(&pm->lock);
|
2020-03-27 21:48:38 +00:00
|
|
|
}
|
|
|
|
|
2022-05-02 20:52:34 +00:00
|
|
|
void mptcp_pm_add_addr_received(const struct sock *ssk,
|
2020-03-27 21:48:38 +00:00
|
|
|
const struct mptcp_addr_info *addr)
|
|
|
|
{
|
2022-05-02 20:52:34 +00:00
|
|
|
struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk);
|
|
|
|
struct mptcp_sock *msk = mptcp_sk(subflow->conn);
|
2020-03-27 21:48:41 +00:00
|
|
|
struct mptcp_pm_data *pm = &msk->pm;
|
|
|
|
|
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 remote_id=%d accept=%d\n", msk, addr->id,
|
2020-03-27 21:48:41 +00:00
|
|
|
READ_ONCE(pm->accept_addr));
|
|
|
|
|
2022-05-02 20:52:34 +00:00
|
|
|
mptcp_event_addr_announced(ssk, addr);
|
2021-02-13 00:00:01 +00:00
|
|
|
|
2020-03-27 21:48:41 +00:00
|
|
|
spin_lock_bh(&pm->lock);
|
|
|
|
|
2022-05-02 20:52:31 +00:00
|
|
|
if (mptcp_pm_is_userspace(msk)) {
|
|
|
|
if (mptcp_userspace_pm_active(msk)) {
|
|
|
|
mptcp_pm_announce_addr(msk, addr, true);
|
|
|
|
mptcp_pm_add_addr_send_ack(msk);
|
|
|
|
} else {
|
|
|
|
__MPTCP_INC_STATS(sock_net((struct sock *)msk), MPTCP_MIB_ADDADDRDROP);
|
|
|
|
}
|
2024-08-28 06:14:37 +00:00
|
|
|
/* id0 should not have a different address */
|
|
|
|
} else if ((addr->id == 0 && !mptcp_pm_nl_is_init_remote_addr(msk, addr)) ||
|
|
|
|
(addr->id > 0 && !READ_ONCE(pm->accept_addr))) {
|
2021-03-26 18:26:31 +00:00
|
|
|
mptcp_pm_announce_addr(msk, addr, true);
|
2020-11-19 19:46:00 +00:00
|
|
|
mptcp_pm_add_addr_send_ack(msk);
|
|
|
|
} else if (mptcp_pm_schedule_work(msk, MPTCP_PM_ADD_ADDR_RECEIVED)) {
|
2020-03-27 21:48:41 +00:00
|
|
|
pm->remote = *addr;
|
2022-02-18 21:35:42 +00:00
|
|
|
} else {
|
|
|
|
__MPTCP_INC_STATS(sock_net((struct sock *)msk), MPTCP_MIB_ADDADDRDROP);
|
2020-11-19 19:46:00 +00:00
|
|
|
}
|
2020-03-27 21:48:41 +00:00
|
|
|
|
|
|
|
spin_unlock_bh(&pm->lock);
|
2020-11-19 19:46:00 +00:00
|
|
|
}
|
|
|
|
|
2021-03-26 18:26:38 +00:00
|
|
|
void mptcp_pm_add_addr_echoed(struct mptcp_sock *msk,
|
2022-02-16 02:11:28 +00:00
|
|
|
const struct mptcp_addr_info *addr)
|
2021-03-26 18:26:38 +00:00
|
|
|
{
|
|
|
|
struct mptcp_pm_data *pm = &msk->pm;
|
|
|
|
|
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\n", msk);
|
2021-03-26 18:26:38 +00:00
|
|
|
|
|
|
|
spin_lock_bh(&pm->lock);
|
|
|
|
|
|
|
|
if (mptcp_lookup_anno_list_by_saddr(msk, addr) && READ_ONCE(pm->work_pending))
|
|
|
|
mptcp_pm_schedule_work(msk, MPTCP_PM_SUBFLOW_ESTABLISHED);
|
|
|
|
|
|
|
|
spin_unlock_bh(&pm->lock);
|
|
|
|
}
|
|
|
|
|
2020-11-19 19:46:00 +00:00
|
|
|
void mptcp_pm_add_addr_send_ack(struct mptcp_sock *msk)
|
|
|
|
{
|
2021-02-01 23:09:09 +00:00
|
|
|
if (!mptcp_pm_should_add_signal(msk))
|
2020-11-19 19:46:00 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
mptcp_pm_schedule_work(msk, MPTCP_PM_ADD_ADDR_SEND_ACK);
|
2020-03-27 21:48:38 +00:00
|
|
|
}
|
|
|
|
|
2021-03-13 01:16:13 +00:00
|
|
|
void mptcp_pm_rm_addr_received(struct mptcp_sock *msk,
|
|
|
|
const struct mptcp_rm_list *rm_list)
|
2020-09-24 00:29:49 +00:00
|
|
|
{
|
|
|
|
struct mptcp_pm_data *pm = &msk->pm;
|
2021-03-13 01:16:13 +00:00
|
|
|
u8 i;
|
2020-09-24 00:29:49 +00:00
|
|
|
|
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 remote_ids_nr=%d\n", msk, rm_list->nr);
|
2020-09-24 00:29:49 +00:00
|
|
|
|
2021-03-13 01:16:13 +00:00
|
|
|
for (i = 0; i < rm_list->nr; i++)
|
|
|
|
mptcp_event_addr_removed(msk, rm_list->ids[i]);
|
2021-02-13 00:00:01 +00:00
|
|
|
|
2020-09-24 00:29:49 +00:00
|
|
|
spin_lock_bh(&pm->lock);
|
2022-02-18 21:35:42 +00:00
|
|
|
if (mptcp_pm_schedule_work(msk, MPTCP_PM_RM_ADDR_RECEIVED))
|
|
|
|
pm->rm_list_rx = *rm_list;
|
|
|
|
else
|
|
|
|
__MPTCP_INC_STATS(sock_net((struct sock *)msk), MPTCP_MIB_RMADDRDROP);
|
2020-09-24 00:29:49 +00:00
|
|
|
spin_unlock_bh(&pm->lock);
|
|
|
|
}
|
|
|
|
|
2022-04-08 19:45:55 +00:00
|
|
|
void mptcp_pm_mp_prio_received(struct sock *ssk, u8 bkup)
|
2021-01-09 00:47:58 +00:00
|
|
|
{
|
2022-04-08 19:45:55 +00:00
|
|
|
struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk);
|
|
|
|
struct sock *sk = subflow->conn;
|
|
|
|
struct mptcp_sock *msk;
|
2021-01-09 00:47:58 +00:00
|
|
|
|
|
|
|
pr_debug("subflow->backup=%d, bkup=%d\n", subflow->backup, bkup);
|
2022-04-08 19:45:55 +00:00
|
|
|
msk = mptcp_sk(sk);
|
2023-08-21 22:25:13 +00:00
|
|
|
if (subflow->backup != bkup)
|
2022-04-08 19:45:55 +00:00
|
|
|
subflow->backup = bkup;
|
2021-02-13 00:00:01 +00:00
|
|
|
|
2022-04-08 19:45:55 +00:00
|
|
|
mptcp_event(MPTCP_EVENT_SUB_PRIORITY, msk, ssk, GFP_ATOMIC);
|
2021-01-09 00:47:58 +00:00
|
|
|
}
|
|
|
|
|
2021-08-24 23:26:16 +00:00
|
|
|
void mptcp_pm_mp_fail_received(struct sock *sk, u64 fail_seq)
|
|
|
|
{
|
2022-04-22 21:55:39 +00:00
|
|
|
struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
|
|
|
|
struct mptcp_sock *msk = mptcp_sk(subflow->conn);
|
|
|
|
|
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("fail_seq=%llu\n", fail_seq);
|
2022-04-22 21:55:39 +00:00
|
|
|
|
2022-05-18 22:04:43 +00:00
|
|
|
if (!READ_ONCE(msk->allow_infinite_fallback))
|
2022-04-26 21:57:14 +00:00
|
|
|
return;
|
|
|
|
|
2022-06-28 01:02:37 +00:00
|
|
|
if (!subflow->fail_tout) {
|
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("send MP_FAIL response and infinite map\n");
|
2022-04-26 21:57:14 +00:00
|
|
|
|
|
|
|
subflow->send_mp_fail = 1;
|
2022-04-22 21:55:39 +00:00
|
|
|
subflow->send_infinite_map = 1;
|
2022-06-28 01:02:37 +00:00
|
|
|
tcp_send_ack(sk);
|
|
|
|
} else {
|
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("MP_FAIL response received\n");
|
2022-06-28 01:02:37 +00:00
|
|
|
WRITE_ONCE(subflow->fail_tout, 0);
|
2022-04-26 21:57:14 +00:00
|
|
|
}
|
2021-08-24 23:26:16 +00:00
|
|
|
}
|
|
|
|
|
2020-03-27 21:48:38 +00:00
|
|
|
/* path manager helpers */
|
|
|
|
|
2022-02-16 02:11:28 +00:00
|
|
|
bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, const struct sk_buff *skb,
|
2021-08-24 01:05:39 +00:00
|
|
|
unsigned int opt_size, unsigned int remaining,
|
2021-08-24 01:05:42 +00:00
|
|
|
struct mptcp_addr_info *addr, bool *echo,
|
2022-02-16 02:11:27 +00:00
|
|
|
bool *drop_other_suboptions)
|
2020-03-27 21:48:38 +00:00
|
|
|
{
|
2020-03-27 21:48:41 +00:00
|
|
|
int ret = false;
|
2021-08-24 01:05:41 +00:00
|
|
|
u8 add_addr;
|
2021-08-24 01:05:42 +00:00
|
|
|
u8 family;
|
2022-02-16 02:11:27 +00:00
|
|
|
bool port;
|
2020-03-27 21:48:41 +00:00
|
|
|
|
|
|
|
spin_lock_bh(&msk->pm.lock);
|
|
|
|
|
|
|
|
/* double check after the lock is acquired */
|
2020-09-24 00:29:47 +00:00
|
|
|
if (!mptcp_pm_should_add_signal(msk))
|
2020-03-27 21:48:41 +00:00
|
|
|
goto out_unlock;
|
|
|
|
|
2021-08-24 01:05:39 +00:00
|
|
|
/* always drop every other options for pure ack ADD_ADDR; this is a
|
|
|
|
* plain dup-ack from TCP perspective. The other MPTCP-relevant info,
|
|
|
|
* if any, will be carried by the 'original' TCP ack
|
|
|
|
*/
|
|
|
|
if (skb && skb_is_tcp_pure_ack(skb)) {
|
|
|
|
remaining += opt_size;
|
|
|
|
*drop_other_suboptions = true;
|
|
|
|
}
|
|
|
|
|
2020-11-19 19:45:59 +00:00
|
|
|
*echo = mptcp_pm_should_add_signal_echo(msk);
|
2022-02-16 02:11:27 +00:00
|
|
|
port = !!(*echo ? msk->pm.remote.port : msk->pm.local.port);
|
2020-10-03 15:36:56 +00:00
|
|
|
|
2021-08-24 01:05:42 +00:00
|
|
|
family = *echo ? msk->pm.remote.family : msk->pm.local.family;
|
2022-02-16 02:11:27 +00:00
|
|
|
if (remaining < mptcp_add_addr_len(family, *echo, port))
|
2020-03-27 21:48:41 +00:00
|
|
|
goto out_unlock;
|
|
|
|
|
2021-08-24 01:05:42 +00:00
|
|
|
if (*echo) {
|
|
|
|
*addr = msk->pm.remote;
|
2021-08-24 01:05:41 +00:00
|
|
|
add_addr = msk->pm.addr_signal & ~BIT(MPTCP_ADD_ADDR_ECHO);
|
2021-08-24 01:05:42 +00:00
|
|
|
} else {
|
|
|
|
*addr = msk->pm.local;
|
2021-08-24 01:05:41 +00:00
|
|
|
add_addr = msk->pm.addr_signal & ~BIT(MPTCP_ADD_ADDR_SIGNAL);
|
2021-08-24 01:05:42 +00:00
|
|
|
}
|
2021-08-24 01:05:41 +00:00
|
|
|
WRITE_ONCE(msk->pm.addr_signal, add_addr);
|
2020-03-27 21:48:41 +00:00
|
|
|
ret = true;
|
|
|
|
|
|
|
|
out_unlock:
|
|
|
|
spin_unlock_bh(&msk->pm.lock);
|
|
|
|
return ret;
|
2020-03-27 21:48:38 +00:00
|
|
|
}
|
|
|
|
|
2020-09-24 00:29:48 +00:00
|
|
|
bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
|
2021-03-13 01:16:11 +00:00
|
|
|
struct mptcp_rm_list *rm_list)
|
2020-09-24 00:29:48 +00:00
|
|
|
{
|
2021-03-13 01:16:12 +00:00
|
|
|
int ret = false, len;
|
2021-08-24 01:05:41 +00:00
|
|
|
u8 rm_addr;
|
2020-09-24 00:29:48 +00:00
|
|
|
|
|
|
|
spin_lock_bh(&msk->pm.lock);
|
|
|
|
|
|
|
|
/* double check after the lock is acquired */
|
|
|
|
if (!mptcp_pm_should_rm_signal(msk))
|
|
|
|
goto out_unlock;
|
|
|
|
|
2021-08-24 01:05:41 +00:00
|
|
|
rm_addr = msk->pm.addr_signal & ~BIT(MPTCP_RM_ADDR_SIGNAL);
|
2021-03-13 01:16:12 +00:00
|
|
|
len = mptcp_rm_addr_len(&msk->pm.rm_list_tx);
|
|
|
|
if (len < 0) {
|
2021-08-24 01:05:41 +00:00
|
|
|
WRITE_ONCE(msk->pm.addr_signal, rm_addr);
|
2021-03-13 01:16:12 +00:00
|
|
|
goto out_unlock;
|
|
|
|
}
|
|
|
|
if (remaining < len)
|
2020-09-24 00:29:48 +00:00
|
|
|
goto out_unlock;
|
|
|
|
|
2021-03-13 01:16:12 +00:00
|
|
|
*rm_list = msk->pm.rm_list_tx;
|
2021-08-24 01:05:41 +00:00
|
|
|
WRITE_ONCE(msk->pm.addr_signal, rm_addr);
|
2020-09-24 00:29:48 +00:00
|
|
|
ret = true;
|
|
|
|
|
|
|
|
out_unlock:
|
|
|
|
spin_unlock_bh(&msk->pm.lock);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2020-03-27 21:48:38 +00:00
|
|
|
int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc)
|
|
|
|
{
|
2023-06-08 13:20:50 +00:00
|
|
|
struct mptcp_addr_info skc_local;
|
|
|
|
struct mptcp_addr_info msk_local;
|
|
|
|
|
|
|
|
if (WARN_ON_ONCE(!msk))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* The 0 ID mapping is defined by the first subflow, copied into the msk
|
|
|
|
* addr
|
|
|
|
*/
|
|
|
|
mptcp_local_address((struct sock_common *)msk, &msk_local);
|
|
|
|
mptcp_local_address((struct sock_common *)skc, &skc_local);
|
|
|
|
if (mptcp_addresses_equal(&msk_local, &skc_local, false))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (mptcp_pm_is_userspace(msk))
|
|
|
|
return mptcp_userspace_pm_get_local_id(msk, &skc_local);
|
|
|
|
return mptcp_pm_nl_get_local_id(msk, &skc_local);
|
2020-03-27 21:48:38 +00:00
|
|
|
}
|
|
|
|
|
2024-07-27 10:01:28 +00:00
|
|
|
bool mptcp_pm_is_backup(struct mptcp_sock *msk, struct sock_common *skc)
|
|
|
|
{
|
|
|
|
struct mptcp_addr_info skc_local;
|
|
|
|
|
|
|
|
mptcp_local_address((struct sock_common *)skc, &skc_local);
|
|
|
|
|
|
|
|
if (mptcp_pm_is_userspace(msk))
|
|
|
|
return mptcp_userspace_pm_is_backup(msk, &skc_local);
|
|
|
|
|
|
|
|
return mptcp_pm_nl_is_backup(msk, &skc_local);
|
|
|
|
}
|
|
|
|
|
2024-03-01 18:18:37 +00:00
|
|
|
int mptcp_pm_get_addr(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
|
|
|
if (info->attrs[MPTCP_PM_ATTR_TOKEN])
|
|
|
|
return mptcp_userspace_pm_get_addr(skb, info);
|
|
|
|
return mptcp_pm_nl_get_addr(skb, info);
|
|
|
|
}
|
|
|
|
|
2024-03-01 18:18:29 +00:00
|
|
|
int mptcp_pm_dump_addr(struct sk_buff *msg, struct netlink_callback *cb)
|
|
|
|
{
|
|
|
|
const struct genl_info *info = genl_info_dump(cb);
|
|
|
|
|
|
|
|
if (info->attrs[MPTCP_PM_ATTR_TOKEN])
|
|
|
|
return mptcp_userspace_pm_dump_addr(msg, cb);
|
|
|
|
return mptcp_pm_nl_dump_addr(msg, cb);
|
|
|
|
}
|
|
|
|
|
2024-03-05 11:04:31 +00:00
|
|
|
int mptcp_pm_set_flags(struct sk_buff *skb, struct genl_info *info)
|
2023-06-08 13:20:52 +00:00
|
|
|
{
|
2024-03-05 11:04:31 +00:00
|
|
|
if (info->attrs[MPTCP_PM_ATTR_TOKEN])
|
|
|
|
return mptcp_userspace_pm_set_flags(skb, info);
|
|
|
|
return mptcp_pm_nl_set_flags(skb, info);
|
2023-06-08 13:20:52 +00:00
|
|
|
}
|
|
|
|
|
2021-08-13 22:15:42 +00:00
|
|
|
void mptcp_pm_subflow_chk_stale(const struct mptcp_sock *msk, struct sock *ssk)
|
|
|
|
{
|
|
|
|
struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk);
|
|
|
|
u32 rcv_tstamp = READ_ONCE(tcp_sk(ssk)->rcv_tstamp);
|
|
|
|
|
|
|
|
/* keep track of rtx periods with no progress */
|
|
|
|
if (!subflow->stale_count) {
|
|
|
|
subflow->stale_rcv_tstamp = rcv_tstamp;
|
|
|
|
subflow->stale_count++;
|
|
|
|
} else if (subflow->stale_rcv_tstamp == rcv_tstamp) {
|
|
|
|
if (subflow->stale_count < U8_MAX)
|
|
|
|
subflow->stale_count++;
|
2021-08-13 22:15:45 +00:00
|
|
|
mptcp_pm_nl_subflow_chk_stale(msk, ssk);
|
2021-08-13 22:15:42 +00:00
|
|
|
} else {
|
|
|
|
subflow->stale_count = 0;
|
2021-08-13 22:15:45 +00:00
|
|
|
mptcp_subflow_set_active(subflow);
|
2021-08-13 22:15:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-12 17:42:52 +00:00
|
|
|
/* if sk is ipv4 or ipv6_only allows only same-family local and remote addresses,
|
|
|
|
* otherwise allow any matching local/remote pair
|
|
|
|
*/
|
|
|
|
bool mptcp_pm_addr_families_match(const struct sock *sk,
|
|
|
|
const struct mptcp_addr_info *loc,
|
|
|
|
const struct mptcp_addr_info *rem)
|
|
|
|
{
|
|
|
|
bool mptcp_is_v4 = sk->sk_family == AF_INET;
|
|
|
|
|
|
|
|
#if IS_ENABLED(CONFIG_MPTCP_IPV6)
|
|
|
|
bool loc_is_v4 = loc->family == AF_INET || ipv6_addr_v4mapped(&loc->addr6);
|
|
|
|
bool rem_is_v4 = rem->family == AF_INET || ipv6_addr_v4mapped(&rem->addr6);
|
|
|
|
|
|
|
|
if (mptcp_is_v4)
|
|
|
|
return loc_is_v4 && rem_is_v4;
|
|
|
|
|
|
|
|
if (ipv6_only_sock(sk))
|
|
|
|
return !loc_is_v4 && !rem_is_v4;
|
|
|
|
|
|
|
|
return loc_is_v4 == rem_is_v4;
|
|
|
|
#else
|
|
|
|
return mptcp_is_v4 && loc->family == AF_INET && rem->family == AF_INET;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-01-07 00:20:16 +00:00
|
|
|
void mptcp_pm_data_reset(struct mptcp_sock *msk)
|
2020-03-27 21:48:38 +00:00
|
|
|
{
|
2022-04-27 22:50:01 +00:00
|
|
|
u8 pm_type = mptcp_get_pm_type(sock_net((struct sock *)msk));
|
2022-04-27 22:49:57 +00:00
|
|
|
struct mptcp_pm_data *pm = &msk->pm;
|
2020-03-27 21:48:38 +00:00
|
|
|
|
2022-04-27 22:49:57 +00:00
|
|
|
pm->add_addr_signaled = 0;
|
|
|
|
pm->add_addr_accepted = 0;
|
|
|
|
pm->local_addr_used = 0;
|
|
|
|
pm->subflows = 0;
|
|
|
|
pm->rm_list_tx.nr = 0;
|
|
|
|
pm->rm_list_rx.nr = 0;
|
2022-04-27 22:50:01 +00:00
|
|
|
WRITE_ONCE(pm->pm_type, pm_type);
|
|
|
|
|
|
|
|
if (pm_type == MPTCP_PM_TYPE_KERNEL) {
|
|
|
|
bool subflows_allowed = !!mptcp_pm_get_subflows_max(msk);
|
|
|
|
|
|
|
|
/* pm->work_pending must be only be set to 'true' when
|
|
|
|
* pm->pm_type is set to MPTCP_PM_TYPE_KERNEL
|
|
|
|
*/
|
|
|
|
WRITE_ONCE(pm->work_pending,
|
|
|
|
(!!mptcp_pm_get_local_addr_max(msk) &&
|
|
|
|
subflows_allowed) ||
|
|
|
|
!!mptcp_pm_get_add_addr_signal_max(msk));
|
|
|
|
WRITE_ONCE(pm->accept_addr,
|
|
|
|
!!mptcp_pm_get_add_addr_accept_max(msk) &&
|
|
|
|
subflows_allowed);
|
|
|
|
WRITE_ONCE(pm->accept_subflow, subflows_allowed);
|
|
|
|
} else {
|
|
|
|
WRITE_ONCE(pm->work_pending, 0);
|
|
|
|
WRITE_ONCE(pm->accept_addr, 0);
|
|
|
|
WRITE_ONCE(pm->accept_subflow, 0);
|
|
|
|
}
|
|
|
|
|
2022-04-27 22:49:57 +00:00
|
|
|
WRITE_ONCE(pm->addr_signal, 0);
|
|
|
|
WRITE_ONCE(pm->remote_deny_join_id0, false);
|
|
|
|
pm->status = 0;
|
|
|
|
bitmap_fill(msk->pm.id_avail_bitmap, MPTCP_PM_MAX_ADDR_ID + 1);
|
2022-01-07 00:20:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void mptcp_pm_data_init(struct mptcp_sock *msk)
|
|
|
|
{
|
2020-03-27 21:48:38 +00:00
|
|
|
spin_lock_init(&msk->pm.lock);
|
2020-09-24 00:29:54 +00:00
|
|
|
INIT_LIST_HEAD(&msk->pm.anno_list);
|
2022-05-04 02:38:49 +00:00
|
|
|
INIT_LIST_HEAD(&msk->pm.userspace_pm_local_addr_list);
|
2022-01-07 00:20:16 +00:00
|
|
|
mptcp_pm_data_reset(msk);
|
2020-03-27 21:48:38 +00:00
|
|
|
}
|
|
|
|
|
2020-06-26 17:29:59 +00:00
|
|
|
void __init mptcp_pm_init(void)
|
2020-03-27 21:48:38 +00:00
|
|
|
{
|
2020-03-27 21:48:51 +00:00
|
|
|
mptcp_pm_nl_init();
|
2020-03-27 21:48:38 +00:00
|
|
|
}
|