Skip to content

Commit f86834d

Browse files
geliangtangsmb49
authored andcommitted
mptcp: check addrs list in userspace_pm_get_local_id
BugLink: https://bugs.launchpad.net/bugs/2061814 commit f012d79 upstream. Before adding a new entry in mptcp_userspace_pm_get_local_id(), it's better to check whether this address is already in userspace pm local address list. If it's in the list, no need to add a new entry, just return it's address ID and use this address. Fixes: 8b20137 ("mptcp: read attributes of addr entries managed by userspace PMs") Cc: [email protected] Signed-off-by: Geliang Tang <[email protected]> Reviewed-by: Mat Martineau <[email protected]> Signed-off-by: Matthieu Baerts (NGI0) <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Portia Stephens <[email protected]> Signed-off-by: Roxana Nicolescu <[email protected]>
1 parent 6d56a6c commit f86834d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

net/mptcp/pm_userspace.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,21 @@ int mptcp_userspace_pm_get_flags_and_ifindex_by_id(struct mptcp_sock *msk,
130130
int mptcp_userspace_pm_get_local_id(struct mptcp_sock *msk,
131131
struct mptcp_addr_info *skc)
132132
{
133-
struct mptcp_pm_addr_entry new_entry;
133+
struct mptcp_pm_addr_entry *entry = NULL, *e, new_entry;
134134
__be16 msk_sport = ((struct inet_sock *)
135135
inet_sk((struct sock *)msk))->inet_sport;
136136

137+
spin_lock_bh(&msk->pm.lock);
138+
list_for_each_entry(e, &msk->pm.userspace_pm_local_addr_list, list) {
139+
if (mptcp_addresses_equal(&e->addr, skc, false)) {
140+
entry = e;
141+
break;
142+
}
143+
}
144+
spin_unlock_bh(&msk->pm.lock);
145+
if (entry)
146+
return entry->addr.id;
147+
137148
memset(&new_entry, 0, sizeof(struct mptcp_pm_addr_entry));
138149
new_entry.addr = *skc;
139150
new_entry.addr.id = 0;

0 commit comments

Comments
 (0)