net/mptcp/pm_netlink.c | 16 ++++++++++------ tools/testing/selftests/net/mptcp/mptcp_join.sh | 4 ++-- 2 files changed, 12 insertions(+), 8 deletions(-)
From: YonglongLi <liyonglong@chinatelecom.cn>
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: 01cacb00b35c ("mptcp: add netlink-based PM")
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>
---
v2 (from Matt):
- Clarify the commit message
- Replace the Fixes tag
- No new line after the Fixes tag
- Use 'sf_created' instead 'subflow_added'
- Use '__mptcp_subflow_connect() == 0' instead of '!__mptcp_subflow_connect'
- Validate the modification in the selftests
- Added my Co-dev tag
- Link to v1: https://lore.kernel.org/mptcp/1716543865-37448-1-git-send-email-liyonglong@chinatelecom.cn
---
net/mptcp/pm_netlink.c | 16 ++++++++++------
tools/testing/selftests/net/mptcp/mptcp_join.sh | 4 ++--
2 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
index 766a8409fa67..ea9e5817b9e9 100644
--- a/net/mptcp/pm_netlink.c
+++ b/net/mptcp/pm_netlink.c
@@ -677,6 +677,7 @@ static void mptcp_pm_nl_add_addr_received(struct mptcp_sock *msk)
unsigned int add_addr_accept_max;
struct mptcp_addr_info remote;
unsigned int subflows_max;
+ bool sf_created = false;
int i, nr;
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)
if (nr == 0)
return;
- msk->pm.add_addr_accepted++;
- if (msk->pm.add_addr_accepted >= add_addr_accept_max ||
- msk->pm.subflows >= subflows_max)
- WRITE_ONCE(msk->pm.accept_addr, false);
-
spin_unlock_bh(&msk->pm.lock);
for (i = 0; i < nr; i++)
- __mptcp_subflow_connect(sk, &addrs[i], &remote);
+ if (__mptcp_subflow_connect(sk, &addrs[i], &remote) == 0)
+ sf_created = true;
spin_lock_bh(&msk->pm.lock);
+
+ if (sf_created) {
+ msk->pm.add_addr_accepted++;
+ if (msk->pm.add_addr_accepted >= add_addr_accept_max ||
+ msk->pm.subflows >= subflows_max)
+ WRITE_ONCE(msk->pm.accept_addr, false);
+ }
}
void mptcp_pm_nl_addr_send_ack(struct mptcp_sock *msk)
diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index aea314d140c9..108aeeb84ef1 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -2249,10 +2249,10 @@ remove_tests()
if reset "remove invalid addresses"; then
pm_nl_set_limits $ns1 3 3
pm_nl_add_endpoint $ns1 10.0.12.1 flags signal
- pm_nl_add_endpoint $ns1 10.0.3.1 flags signal
# broadcast IP: no packet for this address will be received on ns1
pm_nl_add_endpoint $ns1 224.0.0.1 flags signal
- pm_nl_set_limits $ns2 3 3
+ pm_nl_add_endpoint $ns1 10.0.3.1 flags signal
+ pm_nl_set_limits $ns2 2 2
addr_nr_ns1=-3 speed=10 \
run_tests $ns1 $ns2 10.0.1.1
chk_join_nr 1 1 1
---
base-commit: 91419da702aaa1ad2b0110a07fd50a1a38bade6c
change-id: 20240606-mptcp-pm-inc-cnt-sf-create-dfc49d798f13
Best regards,
--
Matthieu Baerts (NGI0) <matttbe@kernel.org>
Hi Yonglong Li, Mat, On 06/06/2024 19:16, Matthieu Baerts (NGI0) wrote: > From: YonglongLi <liyonglong@chinatelecom.cn> > > 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. Thank you for the original patch, and the review! Now in our tree (fixes for -net): New patches for t/upstream-net and t/upstream: - 98857efdda00: mptcp: pm: update add_addr counters after connect - Results: a39272cab4d2..773de679718d (export-net) - Results: 4dce5dfd2129..ce1f2fbad3db (export) Tests are now in progress: - export-net: https://github.com/multipath-tcp/mptcp_net-next/commit/af11f42fc788bc4832e56eac10228a31d8fb0764/checks - export: https://github.com/multipath-tcp/mptcp_net-next/commit/0bcdbf97432494747dd13cec8d264f2e670e1bb6/checks Cheers, Matt -- Sponsored by the NGI0 Core fund.
On Thu, 6 Jun 2024, Matthieu Baerts (NGI0) wrote: > From: YonglongLi <liyonglong@chinatelecom.cn> > > 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: 01cacb00b35c ("mptcp: add netlink-based PM") > 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> > --- > v2 (from Matt): > - Clarify the commit message > - Replace the Fixes tag > - No new line after the Fixes tag > - Use 'sf_created' instead 'subflow_added' > - Use '__mptcp_subflow_connect() == 0' instead of '!__mptcp_subflow_connect' > - Validate the modification in the selftests > - Added my Co-dev tag > - Link to v1: https://lore.kernel.org/mptcp/1716543865-37448-1-git-send-email-liyonglong@chinatelecom.cn v2 lgtm, thanks Matthieu and Yonglong Li: Reviewed-by: Mat Martineau <martineau@kernel.org> > --- > net/mptcp/pm_netlink.c | 16 ++++++++++------ > tools/testing/selftests/net/mptcp/mptcp_join.sh | 4 ++-- > 2 files changed, 12 insertions(+), 8 deletions(-) > > diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c > index 766a8409fa67..ea9e5817b9e9 100644 > --- a/net/mptcp/pm_netlink.c > +++ b/net/mptcp/pm_netlink.c > @@ -677,6 +677,7 @@ static void mptcp_pm_nl_add_addr_received(struct mptcp_sock *msk) > unsigned int add_addr_accept_max; > struct mptcp_addr_info remote; > unsigned int subflows_max; > + bool sf_created = false; > int i, nr; > > 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) > if (nr == 0) > return; > > - msk->pm.add_addr_accepted++; > - if (msk->pm.add_addr_accepted >= add_addr_accept_max || > - msk->pm.subflows >= subflows_max) > - WRITE_ONCE(msk->pm.accept_addr, false); > - > spin_unlock_bh(&msk->pm.lock); > for (i = 0; i < nr; i++) > - __mptcp_subflow_connect(sk, &addrs[i], &remote); > + if (__mptcp_subflow_connect(sk, &addrs[i], &remote) == 0) > + sf_created = true; > spin_lock_bh(&msk->pm.lock); > + > + if (sf_created) { > + msk->pm.add_addr_accepted++; > + if (msk->pm.add_addr_accepted >= add_addr_accept_max || > + msk->pm.subflows >= subflows_max) > + WRITE_ONCE(msk->pm.accept_addr, false); > + } > } > > void mptcp_pm_nl_addr_send_ack(struct mptcp_sock *msk) > diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh > index aea314d140c9..108aeeb84ef1 100755 > --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh > +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh > @@ -2249,10 +2249,10 @@ remove_tests() > if reset "remove invalid addresses"; then > pm_nl_set_limits $ns1 3 3 > pm_nl_add_endpoint $ns1 10.0.12.1 flags signal > - pm_nl_add_endpoint $ns1 10.0.3.1 flags signal > # broadcast IP: no packet for this address will be received on ns1 > pm_nl_add_endpoint $ns1 224.0.0.1 flags signal > - pm_nl_set_limits $ns2 3 3 > + pm_nl_add_endpoint $ns1 10.0.3.1 flags signal > + pm_nl_set_limits $ns2 2 2 > addr_nr_ns1=-3 speed=10 \ > run_tests $ns1 $ns2 10.0.1.1 > chk_join_nr 1 1 1 > > --- > base-commit: 91419da702aaa1ad2b0110a07fd50a1a38bade6c > change-id: 20240606-mptcp-pm-inc-cnt-sf-create-dfc49d798f13 > > Best regards, > -- > Matthieu Baerts (NGI0) <matttbe@kernel.org> > > >
© 2016 - 2024 Red Hat, Inc.