Skip to content

Commit 039564d

Browse files
committed
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: multipath-tcp/mptcp_net-next#501 [1] ==================== Signed-off-by: Matthieu Baerts (NGI0) <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2 parents 9415d37 + 7c70bcc commit 039564d

File tree

3 files changed

+53
-13
lines changed

3 files changed

+53
-13
lines changed

net/mptcp/pm_netlink.c

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,6 +1401,7 @@ static bool mptcp_pm_remove_anno_addr(struct mptcp_sock *msk,
14011401
ret = remove_anno_list_by_saddr(msk, addr);
14021402
if (ret || force) {
14031403
spin_lock_bh(&msk->pm.lock);
1404+
msk->pm.add_addr_signaled -= ret;
14041405
mptcp_pm_remove_addr(msk, &list);
14051406
spin_unlock_bh(&msk->pm.lock);
14061407
}
@@ -1534,16 +1535,25 @@ void mptcp_pm_remove_addrs(struct mptcp_sock *msk, struct list_head *rm_list)
15341535
{
15351536
struct mptcp_rm_list alist = { .nr = 0 };
15361537
struct mptcp_pm_addr_entry *entry;
1538+
int anno_nr = 0;
15371539

15381540
list_for_each_entry(entry, rm_list, list) {
1539-
if ((remove_anno_list_by_saddr(msk, &entry->addr) ||
1540-
lookup_subflow_by_saddr(&msk->conn_list, &entry->addr)) &&
1541-
alist.nr < MPTCP_RM_IDS_MAX)
1542-
alist.ids[alist.nr++] = entry->addr.id;
1541+
if (alist.nr >= MPTCP_RM_IDS_MAX)
1542+
break;
1543+
1544+
/* only delete if either announced or matching a subflow */
1545+
if (remove_anno_list_by_saddr(msk, &entry->addr))
1546+
anno_nr++;
1547+
else if (!lookup_subflow_by_saddr(&msk->conn_list,
1548+
&entry->addr))
1549+
continue;
1550+
1551+
alist.ids[alist.nr++] = entry->addr.id;
15431552
}
15441553

15451554
if (alist.nr) {
15461555
spin_lock_bh(&msk->pm.lock);
1556+
msk->pm.add_addr_signaled -= anno_nr;
15471557
mptcp_pm_remove_addr(msk, &alist);
15481558
spin_unlock_bh(&msk->pm.lock);
15491559
}
@@ -1556,17 +1566,18 @@ static void mptcp_pm_remove_addrs_and_subflows(struct mptcp_sock *msk,
15561566
struct mptcp_pm_addr_entry *entry;
15571567

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

1563-
if (remove_anno_list_by_saddr(msk, &entry->addr) &&
1564-
alist.nr < MPTCP_RM_IDS_MAX)
1573+
if (alist.nr < MPTCP_RM_IDS_MAX &&
1574+
remove_anno_list_by_saddr(msk, &entry->addr))
15651575
alist.ids[alist.nr++] = entry->addr.id;
15661576
}
15671577

15681578
if (alist.nr) {
15691579
spin_lock_bh(&msk->pm.lock);
1580+
msk->pm.add_addr_signaled -= alist.nr;
15701581
mptcp_pm_remove_addr(msk, &alist);
15711582
spin_unlock_bh(&msk->pm.lock);
15721583
}

tools/testing/selftests/net/mptcp/mptcp_connect.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,11 +1115,11 @@ int main_loop_s(int listensock)
11151115
return 1;
11161116
}
11171117

1118-
if (--cfg_repeat > 0) {
1119-
if (cfg_input)
1120-
close(fd);
1118+
if (cfg_input)
1119+
close(fd);
1120+
1121+
if (--cfg_repeat > 0)
11211122
goto again;
1122-
}
11231123

11241124
return 0;
11251125
}

tools/testing/selftests/net/mptcp/mptcp_join.sh

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ pm_nl_check_endpoint()
661661
done
662662

663663
if [ -z "${id}" ]; then
664-
test_fail "bad test - missing endpoint id"
664+
fail_test "bad test - missing endpoint id"
665665
return
666666
fi
667667

@@ -3526,6 +3526,35 @@ endpoint_tests()
35263526
chk_mptcp_info subflows 1 subflows 1
35273527
mptcp_lib_kill_wait $tests_pid
35283528
fi
3529+
3530+
# remove and re-add
3531+
if reset "delete re-add signal" &&
3532+
mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then
3533+
pm_nl_set_limits $ns1 1 1
3534+
pm_nl_set_limits $ns2 1 1
3535+
pm_nl_add_endpoint $ns1 10.0.2.1 id 1 flags signal
3536+
test_linkfail=4 speed=20 \
3537+
run_tests $ns1 $ns2 10.0.1.1 &
3538+
local tests_pid=$!
3539+
3540+
wait_mpj $ns2
3541+
pm_nl_check_endpoint "creation" \
3542+
$ns1 10.0.2.1 id 1 flags signal
3543+
chk_subflow_nr "before delete" 2
3544+
chk_mptcp_info subflows 1 subflows 1
3545+
3546+
pm_nl_del_endpoint $ns1 1 10.0.2.1
3547+
sleep 0.5
3548+
chk_subflow_nr "after delete" 1
3549+
chk_mptcp_info subflows 0 subflows 0
3550+
3551+
pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
3552+
wait_mpj $ns2
3553+
chk_subflow_nr "after re-add" 2
3554+
chk_mptcp_info subflows 1 subflows 1
3555+
mptcp_lib_kill_wait $tests_pid
3556+
fi
3557+
35293558
}
35303559

35313560
# [$1: error message]

0 commit comments

Comments
 (0)