mptcp.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Yonglong Li <liyonglong@chinatelecom.cn>
To: Geliang Tang <geliangtang@gmail.com>,
	mptcp@lists.linux.dev, Paolo Abeni <pabeni@redhat.com>
Subject: Re: [MPTCP][PATCH mptcp-next] Squash to "mptcp: fix ADD_ADDR and RM_ADDR maybe flush addr_signal each other"
Date: Mon, 12 Jul 2021 17:55:19 +0800	[thread overview]
Message-ID: <11cc4e68-8daa-0148-15ef-6b3bbccabc96@chinatelecom.cn> (raw)
In-Reply-To: <5802c6e8aac9d3a6502fd3a8e9cdda01f658dbcf.1626016245.git.geliangtang@gmail.com>



On 2021/7/11 23:15, Geliang Tang wrote:
> Add READ_ONCE() for reading msk->pm.addr_signal.
> 
> Use mptcp_pm_should_add_signal_echo instead of open coding.
> 
> Use '&=' to clear flag.
> 
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>
> ---
>  net/mptcp/pm.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c
> index c9622696716e..be16da2dcb6b 100644
> --- a/net/mptcp/pm.c
> +++ b/net/mptcp/pm.c
> @@ -257,6 +257,7 @@ bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
>  			      struct mptcp_addr_info *saddr, bool *echo, bool *port)
>  {
>  	int ret = false;
> +	u8 add_addr;
>  
>  	spin_lock_bh(&msk->pm.lock);
>  
> @@ -271,10 +272,12 @@ bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
>  		goto out_unlock;
>  
>  	*saddr = msk->pm.local;
> -	if ((msk->pm.addr_signal & BIT(MPTCP_ADD_ADDR_ECHO)))
> -		WRITE_ONCE(msk->pm.addr_signal, msk->pm.addr_signal & ~BIT(MPTCP_ADD_ADDR_ECHO));
> +	add_addr = READ_ONCE(msk->pm.addr_signal);
> +	if (mptcp_pm_should_add_signal_echo(msk))
> +		add_addr &= ~BIT(MPTCP_ADD_ADDR_ECHO);
>  	else
> -		WRITE_ONCE(msk->pm.addr_signal, msk->pm.addr_signal & ~BIT(MPTCP_ADD_ADDR_SIGNAL));
> +		add_addr &= ~BIT(MPTCP_ADD_ADDR_SIGNAL);
> +	WRITE_ONCE(msk->pm.addr_signal, add_addr);
>  	ret = true;
>  
>  out_unlock:
> @@ -294,7 +297,8 @@ bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
>  	if (!mptcp_pm_should_rm_signal(msk))
>  		goto out_unlock;
>  
> -	rm_addr = msk->pm.addr_signal & ~BIT(MPTCP_RM_ADDR_SIGNAL);
> +	rm_addr = READ_ONCE(msk->pm.addr_signal);
> +	rm_addr &= ~BIT(MPTCP_RM_ADDR_SIGNAL);
>  	len = mptcp_rm_addr_len(&msk->pm.rm_list_tx);
>  	if (len < 0) {
>  		WRITE_ONCE(msk->pm.addr_signal, rm_addr);
> 

These chunk of code is under the pm.lock so It is no need to use READ_ONCE() as Paolo saied before.

-- 
Li YongLong

  reply	other threads:[~2021-07-12 10:05 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-11 15:15 [MPTCP][PATCH mptcp-next] Squash to "mptcp: make MPTCP_ADD_ADDR_SIGNAL and MPTCP_ADD_ADDR_ECHO separate" Geliang Tang
2021-07-11 15:15 ` [MPTCP][PATCH mptcp-next] Squash to "mptcp: fix ADD_ADDR and RM_ADDR maybe flush addr_signal each other" Geliang Tang
2021-07-12  9:55   ` Yonglong Li [this message]
2021-07-12 10:34     ` Geliang Tang
2021-07-12 22:27       ` Mat Martineau
2021-07-11 15:15 ` [MPTCP][PATCH mptcp-next] Squash to "mptcp: build ADD_ADDR/echo-ADD_ADDR option according pm.add_signal" Geliang Tang
2021-07-12  1:34   ` Yonglong Li
2021-07-12  7:33     ` Geliang Tang
2021-07-12  8:06       ` Yonglong Li
2021-07-12  8:44         ` Geliang Tang
2021-07-12  9:07           ` Geliang Tang
2021-07-12  9:21             ` Yonglong Li
2021-07-12  9:14           ` Yonglong Li
2021-07-12  9:29             ` Geliang Tang
2021-07-12  9:44               ` Yonglong Li
2021-07-12 10:34                 ` Geliang Tang
2021-07-12 22:10 ` [MPTCP][PATCH mptcp-next] Squash to "mptcp: make MPTCP_ADD_ADDR_SIGNAL and MPTCP_ADD_ADDR_ECHO separate" Mat Martineau

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=11cc4e68-8daa-0148-15ef-6b3bbccabc96@chinatelecom.cn \
    --to=liyonglong@chinatelecom.cn \
    --cc=geliangtang@gmail.com \
    --cc=mptcp@lists.linux.dev \
    --cc=pabeni@redhat.com \
    --subject='Re: [MPTCP][PATCH mptcp-next] Squash to "mptcp: fix ADD_ADDR and RM_ADDR maybe flush addr_signal each other"' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).