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 mptcp-next 3/5] mptcp: deal with MPTCP_PM_ADDR_FLAG_BACKUP in PM netlink
Date: Fri, 20 Nov 2020 17:17:15 -0800	[thread overview]
Message-ID: <a42e6599-d722-656a-78dd-a2737a9a2913@linux.intel.com> (raw)
In-Reply-To: 07602c6f5da430c0adabdd775380572427a16306.1605855783.git.geliangtang@gmail.com

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

On Fri, 20 Nov 2020, Geliang Tang wrote:

> This patch added the MP_PRIO support for PM netlink:
>
> When PM netlink adds an address, check whether the
> MPTCP_PM_ADDR_FLAG_BACKUP flag is set. If it is, check whether this
> address had been added in the local address list. If it had been, then
> call mptcp_nl_addr_backup to deal with this address.
>
> In mptcp_nl_addr_backup, we traverse all the existing msk sockets to find
> the relevant sockets, and get the backup value according to whether the
> MPTCP_PM_ADDR_FLAG_BACKUP flag is set, then call
> mptcp_pm_nl_mp_prio_send_ack to send out a MP_PRIO ACK packet.
>
> In mptcp_pm_nl_mp_prio_send_ack, we set or clear the
> MPTCP_PM_ADDR_FLAG_BACKUP flag.
>
> Signed-off-by: Geliang Tang <geliangtang(a)gmail.com>
> ---
> net/mptcp/pm_netlink.c | 41 +++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 41 insertions(+)
>
> diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
> index dd48af3c5ed5..58960e1cdc32 100644
> --- a/net/mptcp/pm_netlink.c
> +++ b/net/mptcp/pm_netlink.c
> @@ -535,6 +535,11 @@ void mptcp_pm_nl_mp_prio_send_ack(struct mptcp_sock *msk,
> 			return;
> 		}
>
> +		if (addr->flags & MPTCP_PM_ADDR_FLAG_BACKUP)
> +			addr->flags &= ~MPTCP_PM_ADDR_FLAG_BACKUP;
> +		else
> +			addr->flags |= MPTCP_PM_ADDR_FLAG_BACKUP;
> +

Why is the backup bit inverted here? It's not clear why it's changed, and 
why bkup is passed in based on the value of the bit when read by the 
calling function.

> 		subflow->backup = bkup;
> 		mptcp_schedule_work(sk);
>
> @@ -847,17 +852,53 @@ static struct pm_nl_pernet *genl_info_pm_nl(struct genl_info *info)
> 	return net_generic(genl_info_net(info), pm_nl_pernet_id);
> }
>
> +static int mptcp_nl_addr_backup(struct net *net,
> +				struct mptcp_addr_info *addr)
> +{
> +	long s_slot = 0, s_num = 0;
> +	struct mptcp_sock *msk;
> +
> +	while ((msk = mptcp_token_iter_next(net, &s_slot, &s_num)) != NULL) {
> +		u8 bkup = !(addr->flags & MPTCP_PM_ADDR_FLAG_BACKUP);
> +		struct sock *sk = (struct sock *)msk;
> +
> +		if (list_empty(&msk->conn_list))
> +			goto next;
> +
> +		lock_sock(sk);
> +		spin_lock_bh(&msk->pm.lock);
> +		mptcp_pm_nl_mp_prio_send_ack(msk, addr, bkup);
> +		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 *info)
> {
> 	struct nlattr *attr = info->attrs[MPTCP_PM_ATTR_ADDR];
> 	struct pm_nl_pernet *pernet = genl_info_pm_nl(info);
> 	struct mptcp_pm_addr_entry addr, *entry;
> +	struct net *net = sock_net(skb->sk);
> 	int ret;
>
> 	ret = mptcp_pm_parse_addr(attr, info, true, &addr);
> 	if (ret < 0)
> 		return ret;
>
> +	if (addr.addr.flags & MPTCP_PM_ADDR_FLAG_BACKUP) {
> +		list_for_each_entry(entry, &pernet->local_addr_list, list) {
> +			if (addresses_equal(&entry->addr, &addr.addr, false))
> +				mptcp_nl_addr_backup(net, &entry->addr);

I think a more strict match should be required here that includes the 
'id' as well. There may be multiple endpoints with the same address but 
different port numbers.

> +		}
> +		return 0;
> +	}
> +
> 	entry = kmalloc(sizeof(*entry), GFP_KERNEL);
> 	if (!entry) {
> 		GENL_SET_ERR_MSG(info, "can't allocate addr");
> -- 
> 2.26.2

--
Mat Martineau
Intel

             reply	other threads:[~2020-11-21  1:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-21  1:17 Mat Martineau [this message]
  -- strict thread matches above, loose matches on Subject: below --
2020-11-30  2:37 [MPTCP] Re: [MPTCP][PATCH mptcp-next 3/5] mptcp: deal with MPTCP_PM_ADDR_FLAG_BACKUP in PM netlink Geliang Tang
2020-12-02  0:40 Mat Martineau
2020-12-02  4:35 Geliang Tang
2020-12-04 10:54 Paolo Abeni

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=a42e6599-d722-656a-78dd-a2737a9a2913@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