mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
mptcp: local addresses fullmesh
In mptcp_pm_nl_add_addr_received(), fill a temporary allocate array of all local address corresponding to the fullmesh endpoint. If such array is empty, keep the current behavior. Elsewhere loop on such array and create a subflow for each local address towards the given remote address Suggested-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Geliang Tang <geliangtang@xiaomi.com> Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
2843ff6f36
commit
1a0d6136c5
1 changed files with 63 additions and 10 deletions
|
@ -534,13 +534,67 @@ static void mptcp_pm_nl_subflow_established(struct mptcp_sock *msk)
|
||||||
mptcp_pm_create_subflow_or_signal_addr(msk);
|
mptcp_pm_create_subflow_or_signal_addr(msk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Fill all the local addresses into the array addrs[],
|
||||||
|
* and return the array size.
|
||||||
|
*/
|
||||||
|
static unsigned int fill_local_addresses_vec(struct mptcp_sock *msk,
|
||||||
|
struct mptcp_addr_info *addrs)
|
||||||
|
{
|
||||||
|
struct sock *sk = (struct sock *)msk;
|
||||||
|
struct mptcp_pm_addr_entry *entry;
|
||||||
|
struct mptcp_addr_info local;
|
||||||
|
struct pm_nl_pernet *pernet;
|
||||||
|
unsigned int subflows_max;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
pernet = net_generic(sock_net(sk), pm_nl_pernet_id);
|
||||||
|
subflows_max = mptcp_pm_get_subflows_max(msk);
|
||||||
|
|
||||||
|
rcu_read_lock();
|
||||||
|
__mptcp_flush_join_list(msk);
|
||||||
|
list_for_each_entry_rcu(entry, &pernet->local_addr_list, list) {
|
||||||
|
if (!(entry->flags & MPTCP_PM_ADDR_FLAG_FULLMESH))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (entry->addr.family != sk->sk_family) {
|
||||||
|
#if IS_ENABLED(CONFIG_MPTCP_IPV6)
|
||||||
|
if ((entry->addr.family == AF_INET &&
|
||||||
|
!ipv6_addr_v4mapped(&sk->sk_v6_daddr)) ||
|
||||||
|
(sk->sk_family == AF_INET &&
|
||||||
|
!ipv6_addr_v4mapped(&entry->addr.addr6)))
|
||||||
|
#endif
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msk->pm.subflows < subflows_max) {
|
||||||
|
msk->pm.subflows++;
|
||||||
|
addrs[i++] = entry->addr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rcu_read_unlock();
|
||||||
|
|
||||||
|
/* If the array is empty, fill in the single
|
||||||
|
* 'IPADDRANY' local address
|
||||||
|
*/
|
||||||
|
if (!i) {
|
||||||
|
memset(&local, 0, sizeof(local));
|
||||||
|
local.family = msk->pm.remote.family;
|
||||||
|
|
||||||
|
msk->pm.subflows++;
|
||||||
|
addrs[i++] = local;
|
||||||
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
static void mptcp_pm_nl_add_addr_received(struct mptcp_sock *msk)
|
static void mptcp_pm_nl_add_addr_received(struct mptcp_sock *msk)
|
||||||
{
|
{
|
||||||
|
struct mptcp_addr_info addrs[MPTCP_PM_ADDR_MAX];
|
||||||
struct sock *sk = (struct sock *)msk;
|
struct sock *sk = (struct sock *)msk;
|
||||||
unsigned int add_addr_accept_max;
|
unsigned int add_addr_accept_max;
|
||||||
struct mptcp_addr_info remote;
|
struct mptcp_addr_info remote;
|
||||||
struct mptcp_addr_info local;
|
|
||||||
unsigned int subflows_max;
|
unsigned int subflows_max;
|
||||||
|
int i, nr;
|
||||||
|
|
||||||
add_addr_accept_max = mptcp_pm_get_add_addr_accept_max(msk);
|
add_addr_accept_max = mptcp_pm_get_add_addr_accept_max(msk);
|
||||||
subflows_max = mptcp_pm_get_subflows_max(msk);
|
subflows_max = mptcp_pm_get_subflows_max(msk);
|
||||||
|
@ -552,23 +606,22 @@ static void mptcp_pm_nl_add_addr_received(struct mptcp_sock *msk)
|
||||||
if (lookup_subflow_by_daddr(&msk->conn_list, &msk->pm.remote))
|
if (lookup_subflow_by_daddr(&msk->conn_list, &msk->pm.remote))
|
||||||
goto add_addr_echo;
|
goto add_addr_echo;
|
||||||
|
|
||||||
msk->pm.add_addr_accepted++;
|
|
||||||
msk->pm.subflows++;
|
|
||||||
if (msk->pm.add_addr_accepted >= add_addr_accept_max ||
|
|
||||||
msk->pm.subflows >= subflows_max)
|
|
||||||
WRITE_ONCE(msk->pm.accept_addr, false);
|
|
||||||
|
|
||||||
/* connect to the specified remote address, using whatever
|
/* connect to the specified remote address, using whatever
|
||||||
* local address the routing configuration will pick.
|
* local address the routing configuration will pick.
|
||||||
*/
|
*/
|
||||||
remote = msk->pm.remote;
|
remote = msk->pm.remote;
|
||||||
if (!remote.port)
|
if (!remote.port)
|
||||||
remote.port = sk->sk_dport;
|
remote.port = sk->sk_dport;
|
||||||
memset(&local, 0, sizeof(local));
|
nr = fill_local_addresses_vec(msk, addrs);
|
||||||
local.family = remote.family;
|
|
||||||
|
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);
|
spin_unlock_bh(&msk->pm.lock);
|
||||||
__mptcp_subflow_connect(sk, &local, &remote);
|
for (i = 0; i < nr; i++)
|
||||||
|
__mptcp_subflow_connect(sk, &addrs[i], &remote);
|
||||||
spin_lock_bh(&msk->pm.lock);
|
spin_lock_bh(&msk->pm.lock);
|
||||||
|
|
||||||
add_addr_echo:
|
add_addr_echo:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue