All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kishen Maloor <kishen.maloor@intel.com>
To: Paolo Abeni <pabeni@redhat.com>, <mptcp@lists.linux.dev>
Subject: Re: [PATCH mptcp-next v3 6/8] mptcp: netlink: store lsk ref in mptcp_pm_addr_entry
Date: Tue, 1 Feb 2022 13:19:41 -0800	[thread overview]
Message-ID: <ef8fb4a3-2005-92af-1d13-393254d7c60e@intel.com> (raw)
In-Reply-To: <95b6d470ba9cda9da853ff1f4f649f597934ca9c.camel@redhat.com>

On 2/1/22 3:31 AM, Paolo Abeni wrote:
> Hello,
> 
> On Thu, 2022-01-27 at 19:38 -0500, Kishen Maloor wrote:
>> @@ -157,6 +157,33 @@ static void lsk_list_release(struct pm_nl_pernet *pernet,
>>  	}
>>  }
>>  
>> +static struct mptcp_local_lsk *lsk_list_find_or_create(struct net *net,
>> +						       struct pm_nl_pernet *pernet,
>> +						       struct mptcp_pm_addr_entry *entry,
>> +						       int *createlsk_err)
>> +{
>> +	struct mptcp_local_lsk *lsk_ref;
>> +	struct socket *lsk;
>> +	int err;
>> +
>> +	lsk_ref = lsk_list_find(pernet, &entry->addr);
>> +
>> +	if (!lsk_ref) {
>> +		err = mptcp_pm_nl_create_listen_socket(net, entry, &lsk);
> 
> What happens if multiple cores call 'lsk_list_find_or_create'
> simultaneously? Is that possible/expected?
> 

That is technically possible, yes.

> I think the expected behaviour in that scenario is creating a single
> new lsk, and have all the callers fetching such instances. If the race
> happens on mptcp_pm_nl_create_listen_socket() it looks like only one
> caller will get a valid lsk reference, all the others will get back an
> error.
> 

That's right, there will be at most one socket created per addr+port.
I think there shouldn't be a problem with simultaneous calls for
different addresses.

But for a scenario where the simultaneous calls refer to the same addr+port,
I could (as you suggest below) add another lsk_list_find() following a failed
lsk_list_find_or_create() to then either a) obtain a lsk_ref to a
recently created lsk (by the parallel call), or b) fail more definitively.

> Possibly calling again lsk_list_find() in case of failure could address
> the above.
> 
> If the race is not possible, it should be at least documented in a
> comment why it can't happen.
> 
> Side note: using:
> 
> 	if (lsk_ref)
> 		return lsk_ref;
> 
> instead of:
> 	if (!lsk_ref) { //...
> 
> will reduce the indentation level.
> 
> /P
> 


  reply	other threads:[~2022-02-01 21:19 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-28  0:38 [PATCH mptcp-next v3 0/8] mptcp: fixes and enhancements related to path management Kishen Maloor
2022-01-28  0:38 ` [PATCH mptcp-next v3 1/8] mptcp: do not restrict subflows with non-kernel PMs Kishen Maloor
2022-01-28  0:38 ` [PATCH mptcp-next v3 2/8] mptcp: store remote id from MP_JOIN SYN/ACK in local ctx Kishen Maloor
2022-01-28  0:38 ` [PATCH mptcp-next v3 3/8] mptcp: reflect remote port (not 0) in ANNOUNCED events Kishen Maloor
2022-01-28  4:07   ` Geliang Tang
2022-01-31 22:22     ` Kishen Maloor
2022-01-28  0:38 ` [PATCH mptcp-next v3 4/8] mptcp: establish subflows from either end of connection Kishen Maloor
2022-01-28  0:38 ` [PATCH mptcp-next v3 5/8] mptcp: netlink: store per namespace list of refcounted listen socks Kishen Maloor
2022-01-28  0:38 ` [PATCH mptcp-next v3 6/8] mptcp: netlink: store lsk ref in mptcp_pm_addr_entry Kishen Maloor
2022-02-01 11:31   ` Paolo Abeni
2022-02-01 21:19     ` Kishen Maloor [this message]
2022-01-28  0:38 ` [PATCH mptcp-next v3 7/8] mptcp: attempt to add listening sockets for announced addrs Kishen Maloor
2022-02-01 11:42   ` Paolo Abeni
2022-02-01 17:25     ` Matthieu Baerts
2022-02-01 21:21       ` Kishen Maloor
2022-02-02  1:18         ` Mat Martineau
2022-01-28  0:38 ` [PATCH mptcp-next v3 8/8] mptcp: expose server_side attribute in MPTCP netlink events Kishen Maloor

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=ef8fb4a3-2005-92af-1d13-393254d7c60e@intel.com \
    --to=kishen.maloor@intel.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.