All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mat Martineau <mathew.j.martineau@linux.intel.com>
To: Geliang Tang <geliangtang@gmail.com>
Cc: Paolo Abeni <pabeni@redhat.com>, mptcp@lists.linux.dev
Subject: Re: [MPTCP][PATCH v7 mptcp-next 3/5] mptcp: add add_cached in mptcp_pm_data
Date: Mon, 24 May 2021 17:16:50 -0700 (PDT)	[thread overview]
Message-ID: <b2356854-d4e-5968-582e-b8736aeea04b@linux.intel.com> (raw)
In-Reply-To: <c27772875a9bf14dd336526f48676f368758be97.1621839764.git.geliangtang@gmail.com>

On Mon, 24 May 2021, Geliang Tang wrote:

> This patch added a new member add_cached in struct mptcp_pm_data, to
> track the most recent received ADD_ADDR information. Also invalidate
> it if a matching REMOVE_ADDR is received.
>
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>
> ---
> net/mptcp/pm.c         | 1 +
> net/mptcp/pm_netlink.c | 3 +++
> net/mptcp/protocol.h   | 1 +
> 3 files changed, 5 insertions(+)
>
> diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c
> index 9d00fa6d22e9..edc57ff4c1dd 100644
> --- a/net/mptcp/pm.c
> +++ b/net/mptcp/pm.c
> @@ -316,6 +316,7 @@ void mptcp_pm_data_init(struct mptcp_sock *msk)
> 	msk->pm.subflows = 0;
> 	msk->pm.rm_list_tx.nr = 0;
> 	msk->pm.rm_list_rx.nr = 0;
> +	msk->pm.add_cached.id = 0;
> 	WRITE_ONCE(msk->pm.work_pending, false);
> 	WRITE_ONCE(msk->pm.addr_signal, 0);
> 	WRITE_ONCE(msk->pm.accept_addr, false);
> diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
> index 09722598994d..795f6d84bbfc 100644
> --- a/net/mptcp/pm_netlink.c
> +++ b/net/mptcp/pm_netlink.c
> @@ -515,6 +515,7 @@ static void mptcp_pm_nl_add_addr_received(struct mptcp_sock *msk)
> 		remote.port = sk->sk_dport;
> 	memset(&local, 0, sizeof(local));
> 	local.family = remote.family;
> +	msk->pm.add_cached = remote;
>
> 	spin_unlock_bh(&msk->pm.lock);
> 	__mptcp_subflow_connect(sk, &local, &remote, 0, 0);

I think the above few lines of code show the point Paolo was making in the 
meeting last week (and I didn't get the full implications of it at the 
time). If this is the point where the extra remote address is received and 
cached, then there's already a __mptcp_subflow_connect() here to connect 
to the peer - and the connection code in 
mptcp_pm_create_subflow_or_signal_addr() becomes redundant.

There's a corner case where the pernet limits change after an ADD_ADDR is 
received, but the above caching doesn't work for that because there's an 
optimization in mptcp_pm_add_addr_received() to echo the ADD_ADDR without 
scheduling the worker. So mptcp_pm_nl_add_addr_received() doesn't get 
called when pm->accept_addr is false, and the address information is lost. 
This could be handled by removing the optimization and modifying the 
worker, but that doesn't seem worthwhile.


So, after going on a detour after v4 of this patch set, I see the appeal 
of the simpler logic Paolo suggested in 
https://lore.kernel.org/mptcp/ef31d1b4b0456a02f0e8515c449ea4fd4e7c1611.camel@redhat.com/

Paolo, Geliang, what do you think about using that approach and removing 
the caching? (I'm guessing your first thought is "finally!"...)


-Mat


> @@ -631,6 +632,8 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk,
> 			if (rm_type == MPTCP_MIB_RMADDR) {
> 				msk->pm.add_addr_accepted--;
> 				WRITE_ONCE(msk->pm.accept_addr, true);
> +				if (msk->pm.add_cached.id == id)
> +					msk->pm.add_cached.id = 0;
> 			} else if (rm_type == MPTCP_MIB_RMSUBFLOW) {
> 				msk->pm.local_addr_used--;
> 			}
> diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
> index 1201ab04bcdf..d28f6cdc9798 100644
> --- a/net/mptcp/protocol.h
> +++ b/net/mptcp/protocol.h
> @@ -185,6 +185,7 @@ struct mptcp_pm_data {
> 	struct mptcp_addr_info local;
> 	struct mptcp_addr_info remote;
> 	struct list_head anno_list;
> +	struct mptcp_addr_info add_cached;
>
> 	spinlock_t	lock;		/*protects the whole PM data */
>
> -- 
> 2.31.1
>
>
>

--
Mat Martineau
Intel

      parent reply	other threads:[~2021-05-25  0:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-24  7:07 [MPTCP][PATCH v7 mptcp-next 0/5] add MP_CAPABLE 'C' flag Geliang Tang
2021-05-24  7:07 ` [MPTCP][PATCH v7 mptcp-next 1/5] mptcp: add sysctl allow_join_initial_addr_port Geliang Tang
2021-05-24  7:07   ` [MPTCP][PATCH v7 mptcp-next 2/5] mptcp: add allow_join_id0 in mptcp_out_options Geliang Tang
2021-05-24  7:07     ` [MPTCP][PATCH v7 mptcp-next 3/5] mptcp: add add_cached in mptcp_pm_data Geliang Tang
2021-05-24  7:07       ` [MPTCP][PATCH v7 mptcp-next 4/5] mptcp: add deny_join_id0 in mptcp_options_received Geliang Tang
2021-05-24  7:07         ` [MPTCP][PATCH v7 mptcp-next 5/5] selftests: mptcp: add deny_join_id0 testcases Geliang Tang
2021-05-25  0:16       ` Mat Martineau [this message]

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=b2356854-d4e-5968-582e-b8736aeea04b@linux.intel.com \
    --to=mathew.j.martineau@linux.intel.com \
    --cc=geliangtang@gmail.com \
    --cc=mptcp@lists.linux.dev \
    --cc=pabeni@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.