mptcp: pm: inc RmAddr MIB counter once per RM_ADDR ID

commit 6a09788c1a66e3d8b04b3b3e7618cc817bb60ae9 upstream.

The RmAddr MIB counter is supposed to be incremented once when a valid
RM_ADDR has been received. Before this patch, it could have been
incremented as many times as the number of subflows connected to the
linked address ID, so it could have been 0, 1 or more than 1.

The "RmSubflow" is incremented after a local operation. In this case,
it is normal to tied it with the number of subflows that have been
actually removed.

The "remove invalid addresses" MP Join subtest has been modified to
validate this case. A broadcast IP address is now used instead: the
client will not be able to create a subflow to this address. The
consequence is that when receiving the RM_ADDR with the ID attached to
this broadcast IP address, no subflow linked to this ID will be found.

Fixes: 7a7e52e38a ("mptcp: add RM_ADDR related mibs")
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>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://lore.kernel.org/r/20240607-upstream-net-20240607-misc-fixes-v1-2-1ab9ddfa3d00@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
[ Conflicts in pm_netlink.c because the context has changed later in
  multiple commits linked to new features, e.g. commit 86e39e0448
  ("mptcp: keep track of local endpoint still available for each msk"),
  commit a88c9e4969 ("mptcp: do not block subflows creation on errors")
  and commit 3ad14f54bd ("mptcp: more accurate MPC endpoint tracking"),
  but the independent lines that needed to be modified were still there.
  Conflicts in the selftests, because many features modifying the whole
  file have been added later, e.g. commit ae7bd9ccec ("selftests:
  mptcp: join: option to execute specific tests"). The same
  modifications have been reported to the old code: simply changing the
  IP address and add a new comment. ]
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
YonglongLi 2024-06-07 17:01:49 +02:00 коммит произвёл Greg Kroah-Hartman
Родитель f571c8ab18
Коммит 9c2ed72112
2 изменённых файлов: 6 добавлений и 2 удалений

Просмотреть файл

@ -757,8 +757,11 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk,
removed = true;
msk->pm.subflows--;
__MPTCP_INC_STATS(sock_net(sk), rm_type);
if (rm_type == MPTCP_MIB_RMSUBFLOW)
__MPTCP_INC_STATS(sock_net(sk), rm_type);
}
if (rm_type == MPTCP_MIB_RMADDR)
__MPTCP_INC_STATS(sock_net(sk), rm_type);
if (!removed)
continue;

Просмотреть файл

@ -1307,7 +1307,8 @@ remove_tests()
ip netns exec $ns1 ./pm_nl_ctl limits 3 3
ip netns exec $ns1 ./pm_nl_ctl add 10.0.12.1 flags signal
ip netns exec $ns1 ./pm_nl_ctl add 10.0.3.1 flags signal
ip netns exec $ns1 ./pm_nl_ctl add 10.0.14.1 flags signal
# broadcast IP: no packet for this address will be received on ns1
ip netns exec $ns1 ./pm_nl_ctl add 224.0.0.1 flags signal
ip netns exec $ns2 ./pm_nl_ctl limits 3 3
run_tests $ns1 $ns2 10.0.1.1 0 -3 0 slow
chk_join_nr "remove invalid addresses" 1 1 1