MPTCP Linux Development
 help / color / mirror / Atom feed
From: Mat Martineau <mathew.j.martineau at linux.intel.com>
To: mptcp at lists.01.org
Subject: [MPTCP] Re: [MPTCP][PATCH v3 mptcp-next 7/9] mptcp: remove multi addresses and subflows in PM
Date: Thu, 04 Feb 2021 17:56:49 -0800	[thread overview]
Message-ID: <75d0c38d-af16-7638-df23-3cd4ae07411@linux.intel.com> (raw)
In-Reply-To: 4b5492b0234a4d53c9e8bf93a561cd13b5d5d403.1612250255.git.geliangtang@gmail.com

[-- Attachment #1: Type: text/plain, Size: 4229 bytes --]

On Tue, 2 Feb 2021, Geliang Tang wrote:

> This patch implemented the function to remove a list of addresses and
> subflows, named mptcp_nl_remove_addrs_and_subflows, which had a input
> parameter rm_ids as an ids array.
>
> If the msk->conn_list is empty, only invoke mptcp_pm_remove_anno_addrs
> to remove the announced addresses. If it's not empty, invoke
> mptcp_pm_remove_anno_addrs_and_subflows to remove the announced
> addresses and the subflows.
>
> Signed-off-by: Geliang Tang <geliangtang(a)gmail.com>
> ---
> net/mptcp/pm_netlink.c | 89 ++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 89 insertions(+)
>
> diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
> index c11d36bb172c..e942b4ccaa76 100644
> --- a/net/mptcp/pm_netlink.c
> +++ b/net/mptcp/pm_netlink.c
> @@ -1198,6 +1198,95 @@ static int mptcp_nl_cmd_del_addr(struct sk_buff *skb, struct genl_info *info)
> 	return ret;
> }
>
> +static void mptcp_pm_remove_anno_addrs(struct mptcp_sock *msk, u8 rm_ids[])
> +{
> +	u8 active_ids[MPTCP_RM_IDS_MAX] = { 0 }, i;
> +	struct sock *sk = (struct sock *)msk;
> +	struct net *net = sock_net(sk);
> +	struct pm_nl_pernet *pernet;
> +
> +	pernet = net_generic(net, pm_nl_pernet_id);
> +	spin_lock_bh(&pernet->lock);
> +	for (i = 0; i < MPTCP_RM_IDS_MAX && rm_ids[i]; i++) {
> +		struct mptcp_pm_addr_entry *entry;
> +
> +		entry = __lookup_addr_by_id(pernet, rm_ids[i]);
> +		if (entry && remove_anno_list_by_saddr(msk, &entry->addr))
> +			active_ids[i] = rm_ids[i];
> +	}
> +	spin_unlock_bh(&pernet->lock);
> +
> +	if (!mptcp_get_rm_ids_nr(active_ids))
> +		return;
> +
> +	spin_lock_bh(&msk->pm.lock);
> +	mptcp_pm_remove_addr(msk, active_ids);
> +	spin_unlock_bh(&msk->pm.lock);
> +}

It seems like this function is a subset of 
mptcp_pm_remove_anno_addrs_and_subflows(), could both cases be handled by 
one function?

(but be sure to read reply to patch 8 first).

Mat


> +
> +static void mptcp_pm_remove_anno_addrs_and_subflows(struct mptcp_sock *msk, u8 local_ids[])
> +{
> +	u8 subflow_ids[MPTCP_RM_IDS_MAX] = { 0 };
> +	u8 address_ids[MPTCP_RM_IDS_MAX] = { 0 };
> +	struct sock *sk = (struct sock *)msk;
> +	struct net *net = sock_net(sk);
> +	struct pm_nl_pernet *pernet;
> +	int i;
> +
> +	pernet = net_generic(net, pm_nl_pernet_id);
> +	spin_lock_bh(&pernet->lock);
> +	for (i = 0; i < MPTCP_RM_IDS_MAX && local_ids[i]; i++) {
> +		struct mptcp_pm_addr_entry *entry;
> +
> +		entry = __lookup_addr_by_id(pernet, local_ids[i]);
> +		if (entry && lookup_subflow_by_saddr(&msk->conn_list, &entry->addr))
> +			subflow_ids[i] = local_ids[i];
> +		else if (entry && remove_anno_list_by_saddr(msk, &entry->addr))
> +			address_ids[i] = local_ids[i];
> +	}
> +	spin_unlock_bh(&pernet->lock);
> +
> +	if (mptcp_get_rm_ids_nr(subflow_ids)) {
> +		spin_lock_bh(&msk->pm.lock);
> +		mptcp_pm_remove_addr(msk, subflow_ids);
> +		spin_unlock_bh(&msk->pm.lock);
> +		mptcp_pm_remove_subflow(msk, subflow_ids);
> +	}
> +	if (mptcp_get_rm_ids_nr(address_ids)) {
> +		spin_lock_bh(&msk->pm.lock);
> +		mptcp_pm_remove_addr(msk, address_ids);
> +		spin_unlock_bh(&msk->pm.lock);
> +	}
> +}
> +
> +static void mptcp_nl_remove_addrs_and_subflows(struct net *net, u8 rm_ids[])
> +{
> +	long s_slot = 0, s_num = 0;
> +	struct mptcp_sock *msk;
> +
> +	pr_debug("rm_ids_nr=%d", mptcp_get_rm_ids_nr(rm_ids));
> +
> +	if (!mptcp_get_rm_ids_nr(rm_ids))
> +		return;
> +
> +	while ((msk = mptcp_token_iter_next(net, &s_slot, &s_num)) != NULL) {
> +		struct sock *sk = (struct sock *)msk;
> +
> +		if (list_empty(&msk->conn_list)) {
> +			mptcp_pm_remove_anno_addrs(msk, rm_ids);
> +			goto next;
> +		}
> +
> +		lock_sock(sk);
> +		mptcp_pm_remove_anno_addrs_and_subflows(msk, rm_ids);
> +		release_sock(sk);
> +
> +next:
> +		sock_put(sk);
> +		cond_resched();
> +	}
> +}
> +
> static void __flush_addrs(struct net *net, struct list_head *list)
> {
> 	while (!list_empty(list)) {
> -- 
> 2.29.2
> _______________________________________________
> mptcp mailing list -- mptcp(a)lists.01.org
> To unsubscribe send an email to mptcp-leave(a)lists.01.org
>

--
Mat Martineau
Intel

                 reply	other threads:[~2021-02-05  1:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=75d0c38d-af16-7638-df23-3cd4ae07411@linux.intel.com \
    --to=mptcp@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox