Skip to content

Commit 57f8620

Browse files
matttbePaolo Abeni
authored andcommitted
mptcp: pm: ADD_ADDR 0 is not a new address
The ADD_ADDR 0 with the address from the initial subflow should not be considered as a new address: this is not something new. If the host receives it, it simply means that the address is available again. When receiving an ADD_ADDR for the ID 0, the PM already doesn't consider it as new by not incrementing the 'add_addr_accepted' counter. But the 'accept_addr' might not be set if the limit has already been reached: this can be bypassed in this case. But before, it is important to check that this ADD_ADDR for the ID 0 is for the same address as the initial subflow. If not, it is not something that should happen, and the ADD_ADDR can be ignored. Note that if an ADD_ADDR is received while there is already a subflow opened using the same address, this ADD_ADDR is ignored as well. It means that if multiple ADD_ADDR for ID 0 are received, there will not be any duplicated subflows created by the client. Fixes: d0876b2 ("mptcp: add the incoming RM_ADDR support") Cc: stable@vger.kernel.org Reviewed-by: Mat Martineau <martineau@kernel.org> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 20ccc7c commit 57f8620

3 files changed

Lines changed: 14 additions & 1 deletion

File tree

net/mptcp/pm.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,9 @@ void mptcp_pm_add_addr_received(const struct sock *ssk,
226226
} else {
227227
__MPTCP_INC_STATS(sock_net((struct sock *)msk), MPTCP_MIB_ADDADDRDROP);
228228
}
229-
} else if (!READ_ONCE(pm->accept_addr)) {
229+
/* id0 should not have a different address */
230+
} else if ((addr->id == 0 && !mptcp_pm_nl_is_init_remote_addr(msk, addr)) ||
231+
(addr->id > 0 && !READ_ONCE(pm->accept_addr))) {
230232
mptcp_pm_announce_addr(msk, addr, true);
231233
mptcp_pm_add_addr_send_ack(msk);
232234
} else if (mptcp_pm_schedule_work(msk, MPTCP_PM_ADD_ADDR_RECEIVED)) {

net/mptcp/pm_netlink.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,15 @@ static void mptcp_pm_nl_add_addr_received(struct mptcp_sock *msk)
760760
}
761761
}
762762

763+
bool mptcp_pm_nl_is_init_remote_addr(struct mptcp_sock *msk,
764+
const struct mptcp_addr_info *remote)
765+
{
766+
struct mptcp_addr_info mpc_remote;
767+
768+
remote_address((struct sock_common *)msk, &mpc_remote);
769+
return mptcp_addresses_equal(&mpc_remote, remote, remote->port);
770+
}
771+
763772
void mptcp_pm_nl_addr_send_ack(struct mptcp_sock *msk)
764773
{
765774
struct mptcp_subflow_context *subflow;

net/mptcp/protocol.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,8 @@ void mptcp_pm_add_addr_received(const struct sock *ssk,
993993
void mptcp_pm_add_addr_echoed(struct mptcp_sock *msk,
994994
const struct mptcp_addr_info *addr);
995995
void mptcp_pm_add_addr_send_ack(struct mptcp_sock *msk);
996+
bool mptcp_pm_nl_is_init_remote_addr(struct mptcp_sock *msk,
997+
const struct mptcp_addr_info *remote);
996998
void mptcp_pm_nl_addr_send_ack(struct mptcp_sock *msk);
997999
void mptcp_pm_rm_addr_received(struct mptcp_sock *msk,
9981000
const struct mptcp_rm_list *rm_list);

0 commit comments

Comments
 (0)