2020-03-28 00:48:38 +03:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
/* Multipath TCP
|
|
|
|
*
|
|
|
|
* Copyright (c) 2019, Intel Corporation.
|
|
|
|
*/
|
2020-04-03 12:14:08 +03:00
|
|
|
#define pr_fmt(fmt) "MPTCP: " fmt
|
|
|
|
|
2020-03-28 00:48:38 +03:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <net/tcp.h>
|
|
|
|
#include <net/mptcp.h>
|
|
|
|
#include "protocol.h"
|
|
|
|
|
2021-08-14 01:15:46 +03:00
|
|
|
#include "mib.h"
|
|
|
|
|
2020-03-28 00:48:38 +03:00
|
|
|
/* path manager command handlers */
|
|
|
|
|
|
|
|
int mptcp_pm_announce_addr(struct mptcp_sock *msk,
|
2020-09-24 03:29:50 +03:00
|
|
|
const struct mptcp_addr_info *addr,
|
2021-03-26 21:26:31 +03:00
|
|
|
bool echo)
|
2020-03-28 00:48:38 +03:00
|
|
|
{
|
2020-12-10 02:51:27 +03:00
|
|
|
u8 add_addr = READ_ONCE(msk->pm.addr_signal);
|
2020-11-19 22:45:59 +03:00
|
|
|
|
mptcp: pr_debug: add missing \n at the end
commit cb41b195e634d3f1ecfcd845314e64fd4bb3c7aa upstream.
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>
[ As mentioned above, conflicts were expected, and resolved by using the
'sed' command which is visible above. ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-09-06 11:32:43 +03:00
|
|
|
pr_debug("msk=%p, local_id=%d, echo=%d\n", msk, addr->id, echo);
|
2020-03-28 00:48:41 +03:00
|
|
|
|
2021-02-05 02:23:30 +03:00
|
|
|
lockdep_assert_held(&msk->pm.lock);
|
|
|
|
|
2021-08-24 04:05:40 +03:00
|
|
|
if (add_addr &
|
|
|
|
(echo ? BIT(MPTCP_ADD_ADDR_ECHO) : BIT(MPTCP_ADD_ADDR_SIGNAL))) {
|
|
|
|
pr_warn("addr_signal error, add_addr=%d, echo=%d", add_addr, echo);
|
2020-12-10 02:51:26 +03:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2021-08-24 04:05:40 +03:00
|
|
|
if (echo) {
|
|
|
|
msk->pm.remote = *addr;
|
2020-11-19 22:45:59 +03:00
|
|
|
add_addr |= BIT(MPTCP_ADD_ADDR_ECHO);
|
2021-08-24 04:05:40 +03:00
|
|
|
} else {
|
|
|
|
msk->pm.local = *addr;
|
|
|
|
add_addr |= BIT(MPTCP_ADD_ADDR_SIGNAL);
|
|
|
|
}
|
2020-12-10 02:51:27 +03:00
|
|
|
WRITE_ONCE(msk->pm.addr_signal, add_addr);
|
2020-03-28 00:48:41 +03:00
|
|
|
return 0;
|
2020-03-28 00:48:38 +03:00
|
|
|
}
|
|
|
|
|
2021-03-13 04:16:12 +03:00
|
|
|
int mptcp_pm_remove_addr(struct mptcp_sock *msk, const struct mptcp_rm_list *rm_list)
|
2020-03-28 00:48:38 +03:00
|
|
|
{
|
2020-12-10 02:51:27 +03:00
|
|
|
u8 rm_addr = READ_ONCE(msk->pm.addr_signal);
|
2020-12-10 02:51:26 +03:00
|
|
|
|
mptcp: pr_debug: add missing \n at the end
commit cb41b195e634d3f1ecfcd845314e64fd4bb3c7aa upstream.
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>
[ As mentioned above, conflicts were expected, and resolved by using the
'sed' command which is visible above. ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-09-06 11:32:43 +03:00
|
|
|
pr_debug("msk=%p, rm_list_nr=%d\n", msk, rm_list->nr);
|
2020-09-24 03:29:54 +03:00
|
|
|
|
2020-12-10 02:51:26 +03:00
|
|
|
if (rm_addr) {
|
|
|
|
pr_warn("addr_signal error, rm_addr=%d", rm_addr);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2021-03-13 04:16:12 +03:00
|
|
|
msk->pm.rm_list_tx = *rm_list;
|
2020-12-10 02:51:26 +03:00
|
|
|
rm_addr |= BIT(MPTCP_RM_ADDR_SIGNAL);
|
2020-12-10 02:51:27 +03:00
|
|
|
WRITE_ONCE(msk->pm.addr_signal, rm_addr);
|
2021-03-26 21:26:41 +03:00
|
|
|
mptcp_pm_nl_addr_send_ack(msk);
|
2020-09-24 03:29:54 +03:00
|
|
|
return 0;
|
2020-03-28 00:48:38 +03:00
|
|
|
}
|
|
|
|
|
2021-03-13 04:16:16 +03:00
|
|
|
int mptcp_pm_remove_subflow(struct mptcp_sock *msk, const struct mptcp_rm_list *rm_list)
|
2020-03-28 00:48:38 +03:00
|
|
|
{
|
mptcp: pr_debug: add missing \n at the end
commit cb41b195e634d3f1ecfcd845314e64fd4bb3c7aa upstream.
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>
[ As mentioned above, conflicts were expected, and resolved by using the
'sed' command which is visible above. ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-09-06 11:32:43 +03:00
|
|
|
pr_debug("msk=%p, rm_list_nr=%d\n", msk, rm_list->nr);
|
2020-09-24 03:29:55 +03:00
|
|
|
|
|
|
|
spin_lock_bh(&msk->pm.lock);
|
2021-03-13 04:16:16 +03:00
|
|
|
mptcp_pm_nl_rm_subflow_received(msk, rm_list);
|
2020-09-24 03:29:55 +03:00
|
|
|
spin_unlock_bh(&msk->pm.lock);
|
|
|
|
return 0;
|
2020-03-28 00:48:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* path manager event handlers */
|
|
|
|
|
2021-02-13 02:59:58 +03:00
|
|
|
void mptcp_pm_new_connection(struct mptcp_sock *msk, const struct sock *ssk, int server_side)
|
2020-03-28 00:48:38 +03:00
|
|
|
{
|
|
|
|
struct mptcp_pm_data *pm = &msk->pm;
|
|
|
|
|
mptcp: pr_debug: add missing \n at the end
commit cb41b195e634d3f1ecfcd845314e64fd4bb3c7aa upstream.
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>
[ As mentioned above, conflicts were expected, and resolved by using the
'sed' command which is visible above. ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-09-06 11:32:43 +03:00
|
|
|
pr_debug("msk=%p, token=%u side=%d\n", msk, msk->token, server_side);
|
2020-03-28 00:48:38 +03:00
|
|
|
|
|
|
|
WRITE_ONCE(pm->server_side, server_side);
|
2021-02-13 03:00:01 +03:00
|
|
|
mptcp_event(MPTCP_EVENT_CREATED, msk, ssk, GFP_ATOMIC);
|
2020-03-28 00:48:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool mptcp_pm_allow_new_subflow(struct mptcp_sock *msk)
|
|
|
|
{
|
2020-03-28 00:48:41 +03:00
|
|
|
struct mptcp_pm_data *pm = &msk->pm;
|
2021-02-02 02:09:07 +03:00
|
|
|
unsigned int subflows_max;
|
2020-09-24 03:29:53 +03:00
|
|
|
int ret = 0;
|
2020-03-28 00:48:41 +03:00
|
|
|
|
2021-02-02 02:09:07 +03:00
|
|
|
subflows_max = mptcp_pm_get_subflows_max(msk);
|
|
|
|
|
mptcp: pr_debug: add missing \n at the end
commit cb41b195e634d3f1ecfcd845314e64fd4bb3c7aa upstream.
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>
[ As mentioned above, conflicts were expected, and resolved by using the
'sed' command which is visible above. ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-09-06 11:32:43 +03:00
|
|
|
pr_debug("msk=%p subflows=%d max=%d allow=%d\n", msk, pm->subflows,
|
2021-02-02 02:09:07 +03:00
|
|
|
subflows_max, READ_ONCE(pm->accept_subflow));
|
2020-03-28 00:48:41 +03:00
|
|
|
|
|
|
|
/* try to avoid acquiring the lock below */
|
|
|
|
if (!READ_ONCE(pm->accept_subflow))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
spin_lock_bh(&pm->lock);
|
2020-09-24 03:29:53 +03:00
|
|
|
if (READ_ONCE(pm->accept_subflow)) {
|
2021-02-02 02:09:07 +03:00
|
|
|
ret = pm->subflows < subflows_max;
|
|
|
|
if (ret && ++pm->subflows == subflows_max)
|
2020-09-24 03:29:53 +03:00
|
|
|
WRITE_ONCE(pm->accept_subflow, false);
|
|
|
|
}
|
2020-03-28 00:48:41 +03: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
commit cb41b195e634d3f1ecfcd845314e64fd4bb3c7aa upstream.
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>
[ As mentioned above, conflicts were expected, and resolved by using the
'sed' command which is visible above. ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-09-06 11:32:43 +03:00
|
|
|
pr_debug("msk=%p status=%x new=%lx\n", msk, msk->pm.status,
|
2020-03-28 00:48:41 +03:00
|
|
|
BIT(new_status));
|
|
|
|
if (msk->pm.status & BIT(new_status))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
msk->pm.status |= BIT(new_status);
|
2020-11-16 12:48:05 +03:00
|
|
|
mptcp_schedule_work((struct sock *)msk);
|
2020-03-28 00:48:41 +03:00
|
|
|
return true;
|
2020-03-28 00:48:38 +03:00
|
|
|
}
|
|
|
|
|
2021-02-13 02:59:58 +03:00
|
|
|
void mptcp_pm_fully_established(struct mptcp_sock *msk, const struct sock *ssk, gfp_t gfp)
|
2020-03-28 00:48:38 +03:00
|
|
|
{
|
2020-03-28 00:48:41 +03:00
|
|
|
struct mptcp_pm_data *pm = &msk->pm;
|
2021-02-13 03:00:01 +03:00
|
|
|
bool announce = false;
|
2020-03-28 00:48:41 +03:00
|
|
|
|
mptcp: pr_debug: add missing \n at the end
commit cb41b195e634d3f1ecfcd845314e64fd4bb3c7aa upstream.
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>
[ As mentioned above, conflicts were expected, and resolved by using the
'sed' command which is visible above. ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-09-06 11:32:43 +03:00
|
|
|
pr_debug("msk=%p\n", msk);
|
2020-03-28 00:48:41 +03:00
|
|
|
|
|
|
|
spin_lock_bh(&pm->lock);
|
|
|
|
|
2020-12-09 14:03:29 +03: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-28 00:48:41 +03:00
|
|
|
mptcp_pm_schedule_work(msk, MPTCP_PM_ESTABLISHED);
|
|
|
|
|
2021-02-13 03:00:01 +03:00
|
|
|
if ((msk->pm.status & BIT(MPTCP_PM_ALREADY_ESTABLISHED)) == 0)
|
|
|
|
announce = true;
|
|
|
|
|
|
|
|
msk->pm.status |= BIT(MPTCP_PM_ALREADY_ESTABLISHED);
|
2020-03-28 00:48:41 +03:00
|
|
|
spin_unlock_bh(&pm->lock);
|
2021-02-13 03:00:01 +03:00
|
|
|
|
|
|
|
if (announce)
|
|
|
|
mptcp_event(MPTCP_EVENT_ESTABLISHED, msk, ssk, gfp);
|
2020-03-28 00:48:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void mptcp_pm_connection_closed(struct mptcp_sock *msk)
|
|
|
|
{
|
mptcp: pr_debug: add missing \n at the end
commit cb41b195e634d3f1ecfcd845314e64fd4bb3c7aa upstream.
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>
[ As mentioned above, conflicts were expected, and resolved by using the
'sed' command which is visible above. ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-09-06 11:32:43 +03:00
|
|
|
pr_debug("msk=%p\n", msk);
|
2020-03-28 00:48:38 +03:00
|
|
|
}
|
|
|
|
|
2021-03-26 21:26:33 +03:00
|
|
|
void mptcp_pm_subflow_established(struct mptcp_sock *msk)
|
2020-03-28 00:48:38 +03:00
|
|
|
{
|
2020-03-28 00:48:41 +03:00
|
|
|
struct mptcp_pm_data *pm = &msk->pm;
|
|
|
|
|
mptcp: pr_debug: add missing \n at the end
commit cb41b195e634d3f1ecfcd845314e64fd4bb3c7aa upstream.
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>
[ As mentioned above, conflicts were expected, and resolved by using the
'sed' command which is visible above. ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-09-06 11:32:43 +03:00
|
|
|
pr_debug("msk=%p\n", msk);
|
2020-03-28 00:48:41 +03: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-28 00:48:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void mptcp_pm_subflow_closed(struct mptcp_sock *msk, u8 id)
|
|
|
|
{
|
mptcp: pr_debug: add missing \n at the end
commit cb41b195e634d3f1ecfcd845314e64fd4bb3c7aa upstream.
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>
[ As mentioned above, conflicts were expected, and resolved by using the
'sed' command which is visible above. ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-09-06 11:32:43 +03:00
|
|
|
pr_debug("msk=%p\n", msk);
|
2020-03-28 00:48:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void mptcp_pm_add_addr_received(struct mptcp_sock *msk,
|
|
|
|
const struct mptcp_addr_info *addr)
|
|
|
|
{
|
2020-03-28 00:48:41 +03:00
|
|
|
struct mptcp_pm_data *pm = &msk->pm;
|
|
|
|
|
mptcp: pr_debug: add missing \n at the end
commit cb41b195e634d3f1ecfcd845314e64fd4bb3c7aa upstream.
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>
[ As mentioned above, conflicts were expected, and resolved by using the
'sed' command which is visible above. ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-09-06 11:32:43 +03:00
|
|
|
pr_debug("msk=%p remote_id=%d accept=%d\n", msk, addr->id,
|
2020-03-28 00:48:41 +03:00
|
|
|
READ_ONCE(pm->accept_addr));
|
|
|
|
|
2021-02-13 03:00:01 +03:00
|
|
|
mptcp_event_addr_announced(msk, addr);
|
|
|
|
|
2020-03-28 00:48:41 +03:00
|
|
|
spin_lock_bh(&pm->lock);
|
|
|
|
|
mptcp: pm: ADD_ADDR 0 is not a new address
commit 57f86203b41c98b322119dfdbb1ec54ce5e3369b upstream.
The ADD_ADDR 0 with the address from the initial subflow should not be
considered as a new address: this is not something new. If the host
receives it, it simply means that the address is available again.
When receiving an ADD_ADDR for the ID 0, the PM already doesn't consider
it as new by not incrementing the 'add_addr_accepted' counter. But the
'accept_addr' might not be set if the limit has already been reached:
this can be bypassed in this case. But before, it is important to check
that this ADD_ADDR for the ID 0 is for the same address as the initial
subflow. If not, it is not something that should happen, and the
ADD_ADDR can be ignored.
Note that if an ADD_ADDR is received while there is already a subflow
opened using the same address, this ADD_ADDR is ignored as well. It
means that if multiple ADD_ADDR for ID 0 are received, there will not be
any duplicated subflows created by the client.
Fixes: d0876b2284cf ("mptcp: add the incoming RM_ADDR support")
Cc: stable@vger.kernel.org
Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
[ Conflicts in pm.c, due to commit 4d25247d3ae4 ("mptcp: bypass
in-kernel PM restrictions for non-kernel PMs"), which is not in this
version, and changes the context. The same fix can be applied here by
adding the new check at the same place. Note that addresses_equal()
has been used instead of mptcp_addresses_equal(), renamed in commit
4638de5aefe5 ("mptcp: handle local addrs announced by userspace PMs"),
not in this version. ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-09-06 11:34:55 +03:00
|
|
|
/* id0 should not have a different address */
|
|
|
|
if ((addr->id == 0 && !mptcp_pm_nl_is_init_remote_addr(msk, addr)) ||
|
|
|
|
(addr->id > 0 && !READ_ONCE(pm->accept_addr))) {
|
2021-03-26 21:26:31 +03:00
|
|
|
mptcp_pm_announce_addr(msk, addr, true);
|
2020-11-19 22:46:00 +03:00
|
|
|
mptcp_pm_add_addr_send_ack(msk);
|
|
|
|
} else if (mptcp_pm_schedule_work(msk, MPTCP_PM_ADD_ADDR_RECEIVED)) {
|
2020-03-28 00:48:41 +03:00
|
|
|
pm->remote = *addr;
|
2022-02-19 00:35:42 +03:00
|
|
|
} else {
|
|
|
|
__MPTCP_INC_STATS(sock_net((struct sock *)msk), MPTCP_MIB_ADDADDRDROP);
|
2020-11-19 22:46:00 +03:00
|
|
|
}
|
2020-03-28 00:48:41 +03:00
|
|
|
|
|
|
|
spin_unlock_bh(&pm->lock);
|
2020-11-19 22:46:00 +03:00
|
|
|
}
|
|
|
|
|
2021-03-26 21:26:38 +03:00
|
|
|
void mptcp_pm_add_addr_echoed(struct mptcp_sock *msk,
|
2024-09-06 11:31:52 +03:00
|
|
|
const struct mptcp_addr_info *addr)
|
2021-03-26 21:26:38 +03:00
|
|
|
{
|
|
|
|
struct mptcp_pm_data *pm = &msk->pm;
|
|
|
|
|
mptcp: pr_debug: add missing \n at the end
commit cb41b195e634d3f1ecfcd845314e64fd4bb3c7aa upstream.
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>
[ As mentioned above, conflicts were expected, and resolved by using the
'sed' command which is visible above. ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-09-06 11:32:43 +03:00
|
|
|
pr_debug("msk=%p\n", msk);
|
2021-03-26 21:26:38 +03: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 22:46:00 +03:00
|
|
|
void mptcp_pm_add_addr_send_ack(struct mptcp_sock *msk)
|
|
|
|
{
|
2021-02-02 02:09:09 +03:00
|
|
|
if (!mptcp_pm_should_add_signal(msk))
|
2020-11-19 22:46:00 +03:00
|
|
|
return;
|
|
|
|
|
|
|
|
mptcp_pm_schedule_work(msk, MPTCP_PM_ADD_ADDR_SEND_ACK);
|
2020-03-28 00:48:38 +03:00
|
|
|
}
|
|
|
|
|
2021-03-13 04:16:13 +03:00
|
|
|
void mptcp_pm_rm_addr_received(struct mptcp_sock *msk,
|
|
|
|
const struct mptcp_rm_list *rm_list)
|
2020-09-24 03:29:49 +03:00
|
|
|
{
|
|
|
|
struct mptcp_pm_data *pm = &msk->pm;
|
2021-03-13 04:16:13 +03:00
|
|
|
u8 i;
|
2020-09-24 03:29:49 +03:00
|
|
|
|
mptcp: pr_debug: add missing \n at the end
commit cb41b195e634d3f1ecfcd845314e64fd4bb3c7aa upstream.
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>
[ As mentioned above, conflicts were expected, and resolved by using the
'sed' command which is visible above. ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-09-06 11:32:43 +03:00
|
|
|
pr_debug("msk=%p remote_ids_nr=%d\n", msk, rm_list->nr);
|
2020-09-24 03:29:49 +03:00
|
|
|
|
2021-03-13 04:16:13 +03:00
|
|
|
for (i = 0; i < rm_list->nr; i++)
|
|
|
|
mptcp_event_addr_removed(msk, rm_list->ids[i]);
|
2021-02-13 03:00:01 +03:00
|
|
|
|
2020-09-24 03:29:49 +03:00
|
|
|
spin_lock_bh(&pm->lock);
|
2022-02-19 00:35:42 +03: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 03:29:49 +03:00
|
|
|
spin_unlock_bh(&pm->lock);
|
|
|
|
}
|
|
|
|
|
2021-01-09 03:47:58 +03:00
|
|
|
void mptcp_pm_mp_prio_received(struct sock *sk, u8 bkup)
|
|
|
|
{
|
|
|
|
struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
|
|
|
|
|
|
|
|
pr_debug("subflow->backup=%d, bkup=%d\n", subflow->backup, bkup);
|
|
|
|
subflow->backup = bkup;
|
2021-02-13 03:00:01 +03:00
|
|
|
|
|
|
|
mptcp_event(MPTCP_EVENT_SUB_PRIORITY, mptcp_sk(subflow->conn), sk, GFP_ATOMIC);
|
2021-01-09 03:47:58 +03:00
|
|
|
}
|
|
|
|
|
2021-08-25 02:26:16 +03:00
|
|
|
void mptcp_pm_mp_fail_received(struct sock *sk, u64 fail_seq)
|
|
|
|
{
|
mptcp: pr_debug: add missing \n at the end
commit cb41b195e634d3f1ecfcd845314e64fd4bb3c7aa upstream.
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>
[ As mentioned above, conflicts were expected, and resolved by using the
'sed' command which is visible above. ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-09-06 11:32:43 +03:00
|
|
|
pr_debug("fail_seq=%llu\n", fail_seq);
|
2021-08-25 02:26:16 +03:00
|
|
|
}
|
|
|
|
|
2020-03-28 00:48:38 +03:00
|
|
|
/* path manager helpers */
|
|
|
|
|
2024-09-06 11:31:52 +03:00
|
|
|
bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, const struct sk_buff *skb,
|
2021-08-24 04:05:39 +03:00
|
|
|
unsigned int opt_size, unsigned int remaining,
|
2021-08-24 04:05:42 +03:00
|
|
|
struct mptcp_addr_info *addr, bool *echo,
|
2021-08-24 04:05:39 +03:00
|
|
|
bool *port, bool *drop_other_suboptions)
|
2020-03-28 00:48:38 +03:00
|
|
|
{
|
2020-03-28 00:48:41 +03:00
|
|
|
int ret = false;
|
2021-08-24 04:05:41 +03:00
|
|
|
u8 add_addr;
|
2021-08-24 04:05:42 +03:00
|
|
|
u8 family;
|
2020-03-28 00:48:41 +03:00
|
|
|
|
|
|
|
spin_lock_bh(&msk->pm.lock);
|
|
|
|
|
|
|
|
/* double check after the lock is acquired */
|
2020-09-24 03:29:47 +03:00
|
|
|
if (!mptcp_pm_should_add_signal(msk))
|
2020-03-28 00:48:41 +03:00
|
|
|
goto out_unlock;
|
|
|
|
|
2021-08-24 04:05:39 +03: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 22:45:59 +03:00
|
|
|
*echo = mptcp_pm_should_add_signal_echo(msk);
|
2021-08-24 04:05:43 +03:00
|
|
|
*port = !!(*echo ? msk->pm.remote.port : msk->pm.local.port);
|
2020-10-03 18:36:56 +03:00
|
|
|
|
2021-08-24 04:05:42 +03:00
|
|
|
family = *echo ? msk->pm.remote.family : msk->pm.local.family;
|
|
|
|
if (remaining < mptcp_add_addr_len(family, *echo, *port))
|
2020-03-28 00:48:41 +03:00
|
|
|
goto out_unlock;
|
|
|
|
|
2021-08-24 04:05:42 +03:00
|
|
|
if (*echo) {
|
|
|
|
*addr = msk->pm.remote;
|
2021-08-24 04:05:41 +03:00
|
|
|
add_addr = msk->pm.addr_signal & ~BIT(MPTCP_ADD_ADDR_ECHO);
|
2021-08-24 04:05:42 +03:00
|
|
|
} else {
|
|
|
|
*addr = msk->pm.local;
|
2021-08-24 04:05:41 +03:00
|
|
|
add_addr = msk->pm.addr_signal & ~BIT(MPTCP_ADD_ADDR_SIGNAL);
|
2021-08-24 04:05:42 +03:00
|
|
|
}
|
2021-08-24 04:05:41 +03:00
|
|
|
WRITE_ONCE(msk->pm.addr_signal, add_addr);
|
2020-03-28 00:48:41 +03:00
|
|
|
ret = true;
|
|
|
|
|
|
|
|
out_unlock:
|
|
|
|
spin_unlock_bh(&msk->pm.lock);
|
|
|
|
return ret;
|
2020-03-28 00:48:38 +03:00
|
|
|
}
|
|
|
|
|
2020-09-24 03:29:48 +03:00
|
|
|
bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
|
2021-03-13 04:16:11 +03:00
|
|
|
struct mptcp_rm_list *rm_list)
|
2020-09-24 03:29:48 +03:00
|
|
|
{
|
2021-03-13 04:16:12 +03:00
|
|
|
int ret = false, len;
|
2021-08-24 04:05:41 +03:00
|
|
|
u8 rm_addr;
|
2020-09-24 03:29:48 +03: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 04:05:41 +03:00
|
|
|
rm_addr = msk->pm.addr_signal & ~BIT(MPTCP_RM_ADDR_SIGNAL);
|
2021-03-13 04:16:12 +03:00
|
|
|
len = mptcp_rm_addr_len(&msk->pm.rm_list_tx);
|
|
|
|
if (len < 0) {
|
2021-08-24 04:05:41 +03:00
|
|
|
WRITE_ONCE(msk->pm.addr_signal, rm_addr);
|
2021-03-13 04:16:12 +03:00
|
|
|
goto out_unlock;
|
|
|
|
}
|
|
|
|
if (remaining < len)
|
2020-09-24 03:29:48 +03:00
|
|
|
goto out_unlock;
|
|
|
|
|
2021-03-13 04:16:12 +03:00
|
|
|
*rm_list = msk->pm.rm_list_tx;
|
2021-08-24 04:05:41 +03:00
|
|
|
WRITE_ONCE(msk->pm.addr_signal, rm_addr);
|
2020-09-24 03:29:48 +03:00
|
|
|
ret = true;
|
|
|
|
|
|
|
|
out_unlock:
|
|
|
|
spin_unlock_bh(&msk->pm.lock);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2020-03-28 00:48:38 +03:00
|
|
|
int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc)
|
|
|
|
{
|
2020-03-28 00:48:51 +03:00
|
|
|
return mptcp_pm_nl_get_local_id(msk, skc);
|
2020-03-28 00:48:38 +03:00
|
|
|
}
|
|
|
|
|
mptcp: pm: fix backup support in signal endpoints
commit 6834097fc38c5416701c793da94558cea49c0a1f upstream.
There was a support for signal endpoints, but only when the endpoint's
flag was changed during a connection. If an endpoint with the signal and
backup was already present, the MP_JOIN reply was not containing the
backup flag as expected.
That's confusing to have this inconsistent behaviour. On the other hand,
the infrastructure to set the backup flag in the SYN + ACK + MP_JOIN was
already there, it was just never set before. Now when requesting the
local ID from the path-manager, the backup status is also requested.
Note that when the userspace PM is used, the backup flag can be set if
the local address was already used before with a backup flag, e.g. if
the address was announced with the 'backup' flag, or a subflow was
created with the 'backup' flag.
Fixes: 4596a2c1b7f5 ("mptcp: allow creating non-backup subflows")
Cc: stable@vger.kernel.org
Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/507
Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
[ Conflicts in pm_userspace.c because the context has changed in commit
1e07938e29c5 ("net: mptcp: rename netlink handlers to
mptcp_pm_nl_<blah>_{doit,dumpit}") which is not in this version. This
commit is unrelated to this modification.
Conflicts in protocol.h because the context has changed in commit
9ae7846c4b6b ("mptcp: dump addrs in userspace pm list") which is not
in this version. This commit is unrelated to this modification.
Conflicts in pm.c because the context has changed in commit
f40be0db0b76 ("mptcp: unify pm get_flags_and_ifindex_by_id") which is
not in this version. This commit is unrelated to this modification.
Conflicts in subflow.c, because the commit 4cf86ae84c71 ("mptcp:
strict local address ID selection") is not in this version. It is then
not needed to modify the subflow_chk_local_id() helper, which is not
in this version.
Also, in this version, there is no pm_userspace.c, because this PM has
been added in v5.19, which also causes conflicts in protocol.h, and
pm_netlink.c. Plus the code in pm.c can be simplified, as there is no
userspace PM. And the code in pm_netlink.c needs to use
addresses_equal() instead of mptcp_addresses_equal(), see commit
4638de5aefe5 ("mptcp: handle local addrs announced by userspace PMs").
The code in pm_netlink.c also needs to be adapted because the
pm_nl_get_pernet_from_msk() helper is not in this version, introduced
later in commit c682bf536cf4 ("mptcp: add pm_nl_pernet helpers"). ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-08-09 12:09:14 +03: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);
|
|
|
|
|
|
|
|
return mptcp_pm_nl_is_backup(msk, &skc_local);
|
|
|
|
}
|
|
|
|
|
2021-08-14 01:15:42 +03: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-14 01:15:45 +03:00
|
|
|
mptcp_pm_nl_subflow_chk_stale(msk, ssk);
|
2021-08-14 01:15:42 +03:00
|
|
|
} else {
|
|
|
|
subflow->stale_count = 0;
|
2021-08-14 01:15:45 +03:00
|
|
|
mptcp_subflow_set_active(subflow);
|
2021-08-14 01:15:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-28 00:48:38 +03:00
|
|
|
void mptcp_pm_data_init(struct mptcp_sock *msk)
|
|
|
|
{
|
|
|
|
msk->pm.add_addr_signaled = 0;
|
|
|
|
msk->pm.add_addr_accepted = 0;
|
|
|
|
msk->pm.local_addr_used = 0;
|
|
|
|
msk->pm.subflows = 0;
|
2021-03-13 04:16:12 +03:00
|
|
|
msk->pm.rm_list_tx.nr = 0;
|
2021-03-13 04:16:14 +03:00
|
|
|
msk->pm.rm_list_rx.nr = 0;
|
2020-03-28 00:48:38 +03:00
|
|
|
WRITE_ONCE(msk->pm.work_pending, false);
|
2020-12-10 02:51:27 +03:00
|
|
|
WRITE_ONCE(msk->pm.addr_signal, 0);
|
2020-03-28 00:48:38 +03:00
|
|
|
WRITE_ONCE(msk->pm.accept_addr, false);
|
|
|
|
WRITE_ONCE(msk->pm.accept_subflow, false);
|
2021-06-22 22:25:20 +03:00
|
|
|
WRITE_ONCE(msk->pm.remote_deny_join_id0, false);
|
2020-03-28 00:48:38 +03:00
|
|
|
msk->pm.status = 0;
|
|
|
|
|
|
|
|
spin_lock_init(&msk->pm.lock);
|
2020-09-24 03:29:54 +03:00
|
|
|
INIT_LIST_HEAD(&msk->pm.anno_list);
|
2020-03-28 00:48:51 +03:00
|
|
|
|
|
|
|
mptcp_pm_nl_data_init(msk);
|
2020-03-28 00:48:38 +03:00
|
|
|
}
|
|
|
|
|
2020-06-26 20:29:59 +03:00
|
|
|
void __init mptcp_pm_init(void)
|
2020-03-28 00:48:38 +03:00
|
|
|
{
|
2020-03-28 00:48:51 +03:00
|
|
|
mptcp_pm_nl_init();
|
2020-03-28 00:48:38 +03:00
|
|
|
}
|