Skip to content

Commit

Permalink
Merge branch 'mptcp-endpoint-readd-fixes' into main
Browse files Browse the repository at this point in the history
Matthieu Baerts says:

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

Issue torvalds#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: multipath-tcp/mptcp_net-next#501 [1]
====================

Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
davem330 committed Jul 29, 2024
2 parents 9415d37 + 7c70bcc commit 039564d
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 13 deletions.
27 changes: 19 additions & 8 deletions net/mptcp/pm_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -1401,6 +1401,7 @@ static bool mptcp_pm_remove_anno_addr(struct mptcp_sock *msk,
ret = remove_anno_list_by_saddr(msk, addr);
if (ret || force) {
spin_lock_bh(&msk->pm.lock);
msk->pm.add_addr_signaled -= ret;
mptcp_pm_remove_addr(msk, &list);
spin_unlock_bh(&msk->pm.lock);
}
Expand Down Expand Up @@ -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_pm_addr_entry *entry;
int anno_nr = 0;

list_for_each_entry(entry, rm_list, list) {
if ((remove_anno_list_by_saddr(msk, &entry->addr) ||
lookup_subflow_by_saddr(&msk->conn_list, &entry->addr)) &&
alist.nr < MPTCP_RM_IDS_MAX)
alist.ids[alist.nr++] = entry->addr.id;
if (alist.nr >= MPTCP_RM_IDS_MAX)
break;

/* 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) {
spin_lock_bh(&msk->pm.lock);
msk->pm.add_addr_signaled -= anno_nr;
mptcp_pm_remove_addr(msk, &alist);
spin_unlock_bh(&msk->pm.lock);
}
Expand All @@ -1556,17 +1566,18 @@ static void mptcp_pm_remove_addrs_and_subflows(struct mptcp_sock *msk,
struct mptcp_pm_addr_entry *entry;

list_for_each_entry(entry, rm_list, list) {
if (lookup_subflow_by_saddr(&msk->conn_list, &entry->addr) &&
slist.nr < MPTCP_RM_IDS_MAX)
if (slist.nr < MPTCP_RM_IDS_MAX &&
lookup_subflow_by_saddr(&msk->conn_list, &entry->addr))
slist.ids[slist.nr++] = entry->addr.id;

if (remove_anno_list_by_saddr(msk, &entry->addr) &&
alist.nr < MPTCP_RM_IDS_MAX)
if (alist.nr < MPTCP_RM_IDS_MAX &&
remove_anno_list_by_saddr(msk, &entry->addr))
alist.ids[alist.nr++] = entry->addr.id;
}

if (alist.nr) {
spin_lock_bh(&msk->pm.lock);
msk->pm.add_addr_signaled -= alist.nr;
mptcp_pm_remove_addr(msk, &alist);
spin_unlock_bh(&msk->pm.lock);
}
Expand Down
8 changes: 4 additions & 4 deletions tools/testing/selftests/net/mptcp/mptcp_connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -1115,11 +1115,11 @@ int main_loop_s(int listensock)
return 1;
}

if (--cfg_repeat > 0) {
if (cfg_input)
close(fd);
if (cfg_input)
close(fd);

if (--cfg_repeat > 0)
goto again;
}

return 0;
}
Expand Down
31 changes: 30 additions & 1 deletion tools/testing/selftests/net/mptcp/mptcp_join.sh
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ pm_nl_check_endpoint()
done

if [ -z "${id}" ]; then
test_fail "bad test - missing endpoint id"
fail_test "bad test - missing endpoint id"
return
fi

Expand Down Expand Up @@ -3526,6 +3526,35 @@ endpoint_tests()
chk_mptcp_info subflows 1 subflows 1
mptcp_lib_kill_wait $tests_pid
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]
Expand Down

0 comments on commit 039564d

Please sign in to comment.