Commit 039564d2 authored by David S. Miller's avatar David S. Miller

Merge branch 'mptcp-endpoint-readd-fixes' into main

Matthieu Baerts says:

====================
mptcp: fix signal endpoint readd

Issue #501 [1] showed that the Netlink PM currently doesn't correctly
support removal and re-add of signal endpoints.

Patches 1 and 2 address the issue: the first one in the userspace path-
manager, introduced in v5.19 ; and the second one in the in-kernel path-
manager, introduced in v5.7.

Patch 3 introduces a related selftest. There is no 'Fixes' tag, because
it might be hard to backport it automatically, as missing helpers in
Bash will not be caught when compiling the kernel or the selftests.

The last two patches address two small issues in the MPTCP selftests,
one introduced in v6.6., and the other one in v5.17.

Link: https://github.com/multipath-tcp/mptcp_net-next/issues/501 [1]
====================
Signed-off-by: default avatarMatthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 9415d375 7c70bcc2
...@@ -1401,6 +1401,7 @@ static bool mptcp_pm_remove_anno_addr(struct mptcp_sock *msk, ...@@ -1401,6 +1401,7 @@ static bool mptcp_pm_remove_anno_addr(struct mptcp_sock *msk,
ret = remove_anno_list_by_saddr(msk, addr); ret = remove_anno_list_by_saddr(msk, addr);
if (ret || force) { if (ret || force) {
spin_lock_bh(&msk->pm.lock); spin_lock_bh(&msk->pm.lock);
msk->pm.add_addr_signaled -= ret;
mptcp_pm_remove_addr(msk, &list); mptcp_pm_remove_addr(msk, &list);
spin_unlock_bh(&msk->pm.lock); spin_unlock_bh(&msk->pm.lock);
} }
...@@ -1534,16 +1535,25 @@ void mptcp_pm_remove_addrs(struct mptcp_sock *msk, struct list_head *rm_list) ...@@ -1534,16 +1535,25 @@ void mptcp_pm_remove_addrs(struct mptcp_sock *msk, struct list_head *rm_list)
{ {
struct mptcp_rm_list alist = { .nr = 0 }; struct mptcp_rm_list alist = { .nr = 0 };
struct mptcp_pm_addr_entry *entry; struct mptcp_pm_addr_entry *entry;
int anno_nr = 0;
list_for_each_entry(entry, rm_list, list) { list_for_each_entry(entry, rm_list, list) {
if ((remove_anno_list_by_saddr(msk, &entry->addr) || if (alist.nr >= MPTCP_RM_IDS_MAX)
lookup_subflow_by_saddr(&msk->conn_list, &entry->addr)) && break;
alist.nr < MPTCP_RM_IDS_MAX)
alist.ids[alist.nr++] = entry->addr.id; /* only delete if either announced or matching a subflow */
if (remove_anno_list_by_saddr(msk, &entry->addr))
anno_nr++;
else if (!lookup_subflow_by_saddr(&msk->conn_list,
&entry->addr))
continue;
alist.ids[alist.nr++] = entry->addr.id;
} }
if (alist.nr) { if (alist.nr) {
spin_lock_bh(&msk->pm.lock); spin_lock_bh(&msk->pm.lock);
msk->pm.add_addr_signaled -= anno_nr;
mptcp_pm_remove_addr(msk, &alist); mptcp_pm_remove_addr(msk, &alist);
spin_unlock_bh(&msk->pm.lock); spin_unlock_bh(&msk->pm.lock);
} }
...@@ -1556,17 +1566,18 @@ static void mptcp_pm_remove_addrs_and_subflows(struct mptcp_sock *msk, ...@@ -1556,17 +1566,18 @@ static void mptcp_pm_remove_addrs_and_subflows(struct mptcp_sock *msk,
struct mptcp_pm_addr_entry *entry; struct mptcp_pm_addr_entry *entry;
list_for_each_entry(entry, rm_list, list) { list_for_each_entry(entry, rm_list, list) {
if (lookup_subflow_by_saddr(&msk->conn_list, &entry->addr) && if (slist.nr < MPTCP_RM_IDS_MAX &&
slist.nr < MPTCP_RM_IDS_MAX) lookup_subflow_by_saddr(&msk->conn_list, &entry->addr))
slist.ids[slist.nr++] = entry->addr.id; slist.ids[slist.nr++] = entry->addr.id;
if (remove_anno_list_by_saddr(msk, &entry->addr) && if (alist.nr < MPTCP_RM_IDS_MAX &&
alist.nr < MPTCP_RM_IDS_MAX) remove_anno_list_by_saddr(msk, &entry->addr))
alist.ids[alist.nr++] = entry->addr.id; alist.ids[alist.nr++] = entry->addr.id;
} }
if (alist.nr) { if (alist.nr) {
spin_lock_bh(&msk->pm.lock); spin_lock_bh(&msk->pm.lock);
msk->pm.add_addr_signaled -= alist.nr;
mptcp_pm_remove_addr(msk, &alist); mptcp_pm_remove_addr(msk, &alist);
spin_unlock_bh(&msk->pm.lock); spin_unlock_bh(&msk->pm.lock);
} }
......
...@@ -1115,11 +1115,11 @@ int main_loop_s(int listensock) ...@@ -1115,11 +1115,11 @@ int main_loop_s(int listensock)
return 1; return 1;
} }
if (--cfg_repeat > 0) { if (cfg_input)
if (cfg_input) close(fd);
close(fd);
if (--cfg_repeat > 0)
goto again; goto again;
}
return 0; return 0;
} }
......
...@@ -661,7 +661,7 @@ pm_nl_check_endpoint() ...@@ -661,7 +661,7 @@ pm_nl_check_endpoint()
done done
if [ -z "${id}" ]; then if [ -z "${id}" ]; then
test_fail "bad test - missing endpoint id" fail_test "bad test - missing endpoint id"
return return
fi fi
...@@ -3526,6 +3526,35 @@ endpoint_tests() ...@@ -3526,6 +3526,35 @@ endpoint_tests()
chk_mptcp_info subflows 1 subflows 1 chk_mptcp_info subflows 1 subflows 1
mptcp_lib_kill_wait $tests_pid mptcp_lib_kill_wait $tests_pid
fi fi
# remove and re-add
if reset "delete re-add signal" &&
mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then
pm_nl_set_limits $ns1 1 1
pm_nl_set_limits $ns2 1 1
pm_nl_add_endpoint $ns1 10.0.2.1 id 1 flags signal
test_linkfail=4 speed=20 \
run_tests $ns1 $ns2 10.0.1.1 &
local tests_pid=$!
wait_mpj $ns2
pm_nl_check_endpoint "creation" \
$ns1 10.0.2.1 id 1 flags signal
chk_subflow_nr "before delete" 2
chk_mptcp_info subflows 1 subflows 1
pm_nl_del_endpoint $ns1 1 10.0.2.1
sleep 0.5
chk_subflow_nr "after delete" 1
chk_mptcp_info subflows 0 subflows 0
pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
wait_mpj $ns2
chk_subflow_nr "after re-add" 2
chk_mptcp_info subflows 1 subflows 1
mptcp_lib_kill_wait $tests_pid
fi
} }
# [$1: error message] # [$1: error message]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment