Content-Type: multipart/mixed; boundary="===============6384594268347677133==" MIME-Version: 1.0 From: Mat Martineau To: mptcp at lists.01.org Subject: [MPTCP] [PATCH net-next v2 03/15] mptcp: create subflow or signal addr for newly added address Date: Mon, 01 Feb 2021 15:09:08 -0800 Message-ID: <20210201230920.66027-4-mathew.j.martineau@linux.intel.com> In-Reply-To: 20210201230920.66027-1-mathew.j.martineau@linux.intel.com X-Status: X-Keywords: X-UID: 7559 --===============6384594268347677133== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Geliang Tang Currently, when a new MPTCP endpoint is added, the existing MPTCP sockets are not affected. This patch implements a new function mptcp_nl_add_subflow_or_signal_addr, invoked when an address is added from PM netlink. This function traverses the MPTCP sockets list and invokes mptcp_pm_create_subflow_or_signal_addr to try to create a subflow or signal an address for the newly added address, if local constraint allows that. Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/19 Signed-off-by: Geliang Tang Signed-off-by: Mat Martineau --- net/mptcp/pm_netlink.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 6aeadcaef8ae..f1eb3a512fcb 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -850,6 +850,31 @@ static struct pm_nl_pernet *genl_info_pm_nl(struct gen= l_info *info) return net_generic(genl_info_net(info), pm_nl_pernet_id); } = +static int mptcp_nl_add_subflow_or_signal_addr(struct net *net) +{ + struct mptcp_sock *msk; + long s_slot =3D 0, s_num =3D 0; + + while ((msk =3D mptcp_token_iter_next(net, &s_slot, &s_num)) !=3D NULL) { + struct sock *sk =3D (struct sock *)msk; + + if (!READ_ONCE(msk->fully_established)) + goto next; + + lock_sock(sk); + spin_lock_bh(&msk->pm.lock); + mptcp_pm_create_subflow_or_signal_addr(msk); + spin_unlock_bh(&msk->pm.lock); + release_sock(sk); + +next: + sock_put(sk); + cond_resched(); + } + + return 0; +} + static int mptcp_nl_cmd_add_addr(struct sk_buff *skb, struct genl_info *in= fo) { struct nlattr *attr =3D info->attrs[MPTCP_PM_ATTR_ADDR]; @@ -875,6 +900,8 @@ static int mptcp_nl_cmd_add_addr(struct sk_buff *skb, s= truct genl_info *info) return ret; } = + mptcp_nl_add_subflow_or_signal_addr(sock_net(skb->sk)); + return 0; } = -- = 2.30.0 --===============6384594268347677133==--