From: Al Viro <viro@zeniv.linux.org.uk>
To: Allison Henderson <allison.henderson@oracle.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: [RFC][PATCH] don't open-code kernel_accept() in rds_tcp_accept_one()
Date: Mon, 14 Jul 2025 05:47:26 +0100 [thread overview]
Message-ID: <20250714044726.GD1880847@ZenIV> (raw)
In-Reply-To: <2eb0df2c5dd8b16b5103f0e2859690519c4f2dad.camel@oracle.com>
On Mon, Jul 14, 2025 at 04:36:32AM +0000, Allison Henderson wrote:
> > if (!sock) /* module unload or netns delete in progress */
> > return -ENETUNREACH;
> >
> > - ret = sock_create_lite(sock->sk->sk_family,
> > - sock->sk->sk_type, sock->sk->sk_protocol,
> > - &new_sock);
> > + ret = kernel_accept(sock, &new_sock, O_NONBLOCK);
> > if (ret)
> > - goto out;
> > -
> > - ret = sock->ops->accept(sock, new_sock, &arg);
> > - if (ret < 0)
> > - goto out;
> > -
> > - /* sock_create_lite() does not get a hold on the owner module so we
> > - * need to do it here. Note that sock_release() uses sock->ops to
> > - * determine if it needs to decrement the reference count. So set
> > - * sock->ops after calling accept() in case that fails. And there's
> > - * no need to do try_module_get() as the listener should have a hold
> > - * already.
> > - */
> > - new_sock->ops = sock->ops;
> > - __module_get(new_sock->ops->owner);
> > + return ret;
> I think we need the "goto out" here, or we will miss the mutex unlock. Otherwise kernel_accept looks like a pretty
> synonymous wrapper.
What mutex_unlock()?
if (rs_tcp)
mutex_unlock(&rs_tcp->t_conn_path_lock);
won't be triggered, since rs_tcp remains NULL until
rs_tcp = rds_tcp_accept_one_path(conn);
well after any of the affected code...
No, return is perfectly fine here - failing kernel_accept() has no side
effects and we have
if (!sock) /* module unload or netns delete in progress */
return -ENETUNREACH;
just prior to it. So if we needed to unlock anything on kernel_accept()
failure, the same would apply for the failure exit just before it...
next prev parent reply other threads:[~2025-07-14 4:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-13 18:01 [RFC][PATCH] don't open-code kernel_accept() in rds_tcp_accept_one() Al Viro
2025-07-14 4:36 ` Allison Henderson
2025-07-14 4:47 ` Al Viro [this message]
2025-07-14 5:06 ` Allison Henderson
2025-07-15 23:40 ` patchwork-bot+netdevbpf
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=20250714044726.GD1880847@ZenIV \
--to=viro@zeniv.linux.org.uk \
--cc=allison.henderson@oracle.com \
--cc=netdev@vger.kernel.org \
/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