Skip to content

Commit 40eec17

Browse files
YonglongLikuba-moo
authored andcommitted
mptcp: pm: update add_addr counters after connect
The creation of new subflows can fail for different reasons. If no subflow have been created using the received ADD_ADDR, the related counters should not be updated, otherwise they will never be decremented for events related to this ID later on. For the moment, the number of accepted ADD_ADDR is only decremented upon the reception of a related RM_ADDR, and only if the remote address ID is currently being used by at least one subflow. In other words, if no subflow can be created with the received address, the counter will not be decremented. In this case, it is then important not to increment pm.add_addr_accepted counter, and not to modify pm.accept_addr bit. Note that this patch does not modify the behaviour in case of failures later on, e.g. if the MP Join is dropped or rejected. The "remove invalid addresses" MP Join subtest has been modified to validate this case. The broadcast IP address is added before the "valid" address that will be used to successfully create a subflow, and the limit is decreased by one: without this patch, it was not possible to create the last subflow, because: - the broadcast address would have been accepted even if it was not usable: the creation of a subflow to this address results in an error, - the limit of 2 accepted ADD_ADDR would have then been reached. Fixes: 01cacb0 ("mptcp: add netlink-based PM") Cc: stable@vger.kernel.org Co-developed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Signed-off-by: YonglongLi <liyonglong@chinatelecom.cn> Reviewed-by: Mat Martineau <martineau@kernel.org> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Link: https://lore.kernel.org/r/20240607-upstream-net-20240607-misc-fixes-v1-3-1ab9ddfa3d00@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 6a09788 commit 40eec17

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

net/mptcp/pm_netlink.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,7 @@ static void mptcp_pm_nl_add_addr_received(struct mptcp_sock *msk)
677677
unsigned int add_addr_accept_max;
678678
struct mptcp_addr_info remote;
679679
unsigned int subflows_max;
680+
bool sf_created = false;
680681
int i, nr;
681682

682683
add_addr_accept_max = mptcp_pm_get_add_addr_accept_max(msk);
@@ -704,15 +705,18 @@ static void mptcp_pm_nl_add_addr_received(struct mptcp_sock *msk)
704705
if (nr == 0)
705706
return;
706707

707-
msk->pm.add_addr_accepted++;
708-
if (msk->pm.add_addr_accepted >= add_addr_accept_max ||
709-
msk->pm.subflows >= subflows_max)
710-
WRITE_ONCE(msk->pm.accept_addr, false);
711-
712708
spin_unlock_bh(&msk->pm.lock);
713709
for (i = 0; i < nr; i++)
714-
__mptcp_subflow_connect(sk, &addrs[i], &remote);
710+
if (__mptcp_subflow_connect(sk, &addrs[i], &remote) == 0)
711+
sf_created = true;
715712
spin_lock_bh(&msk->pm.lock);
713+
714+
if (sf_created) {
715+
msk->pm.add_addr_accepted++;
716+
if (msk->pm.add_addr_accepted >= add_addr_accept_max ||
717+
msk->pm.subflows >= subflows_max)
718+
WRITE_ONCE(msk->pm.accept_addr, false);
719+
}
716720
}
717721

718722
void mptcp_pm_nl_addr_send_ack(struct mptcp_sock *msk)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2249,10 +2249,10 @@ remove_tests()
22492249
if reset "remove invalid addresses"; then
22502250
pm_nl_set_limits $ns1 3 3
22512251
pm_nl_add_endpoint $ns1 10.0.12.1 flags signal
2252-
pm_nl_add_endpoint $ns1 10.0.3.1 flags signal
22532252
# broadcast IP: no packet for this address will be received on ns1
22542253
pm_nl_add_endpoint $ns1 224.0.0.1 flags signal
2255-
pm_nl_set_limits $ns2 3 3
2254+
pm_nl_add_endpoint $ns1 10.0.3.1 flags signal
2255+
pm_nl_set_limits $ns2 2 2
22562256
addr_nr_ns1=-3 speed=10 \
22572257
run_tests $ns1 $ns2 10.0.1.1
22582258
chk_join_nr 1 1 1

0 commit comments

Comments
 (0)