mptcp: fix duplicate subflow creation
authorPaolo Abeni <pabeni@redhat.com>
Thu, 15 Feb 2024 18:25:33 +0000 (19:25 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sun, 18 Feb 2024 10:25:00 +0000 (10:25 +0000)
commit045e9d812868a2d80b7a57b224ce8009444b7bbc
tree838a2c95f03ab290043a54cd3fd1e921aebbfea5
parent967d3c27127e71a10ff5c083583a038606431b61
mptcp: fix duplicate subflow creation

Fullmesh endpoints could end-up unexpectedly generating duplicate
subflows - same local and remote addresses - when multiple incoming
ADD_ADDR are processed before the PM creates the subflow for the local
endpoints.

Address the issue explicitly checking for duplicates at subflow
creation time.

To avoid a quadratic computational complexity, track the unavailable
remote address ids in a temporary bitmap and initialize such bitmap
with the remote ids of all the existing subflows matching the local
address currently processed.

The above allows additionally replacing the existing code checking
for duplicate entry in the current set with a simple bit test
operation.

Fixes: 2843ff6f36db ("mptcp: remote addresses fullmesh")
Cc: stable@vger.kernel.org
Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/435
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/mptcp/pm_netlink.c