netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kuniyuki Iwashima <kuniyu@amazon.com>
To: <wenjia@linux.ibm.com>
Cc: <alibuda@linux.alibaba.com>, <allison.henderson@oracle.com>,
	<chuck.lever@oracle.com>, <davem@davemloft.net>,
	<edumazet@google.com>, <horms@kernel.org>, <jaka@linux.ibm.com>,
	<jlayton@kernel.org>, <kuba@kernel.org>, <kuni1840@gmail.com>,
	<kuniyu@amazon.com>, <matttbe@kernel.org>,
	<netdev@vger.kernel.org>, <pabeni@redhat.com>,
	<sfrench@samba.org>
Subject: Re: [PATCH v3 net-next 11/15] socket: Remove kernel socket conversion.
Date: Fri, 13 Dec 2024 22:54:37 +0900	[thread overview]
Message-ID: <20241213135437.44216-1-kuniyu@amazon.com> (raw)
In-Reply-To: <919d9910-a405-40f0-ad0b-fa3e8b908013@linux.ibm.com>

From: Wenjia Zhang <wenjia@linux.ibm.com>
Date: Fri, 13 Dec 2024 14:45:20 +0100
> > diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
> > index 6e93f188a908..7b0de80b3aca 100644
> > --- a/net/smc/af_smc.c
> > +++ b/net/smc/af_smc.c
> > @@ -3310,25 +3310,8 @@ static const struct proto_ops smc_sock_ops = {
> >   
> >   int smc_create_clcsk(struct net *net, struct sock *sk, int family)
> >   {
> > -	struct smc_sock *smc = smc_sk(sk);
> > -	int rc;
> > -
> > -	rc = sock_create_kern(net, family, SOCK_STREAM, IPPROTO_TCP,
> > -			      &smc->clcsock);
> > -	if (rc)
> > -		return rc;
> > -
> > -	/* smc_clcsock_release() does not wait smc->clcsock->sk's
> > -	 * destruction;  its sk_state might not be TCP_CLOSE after
> > -	 * smc->sk is close()d, and TCP timers can be fired later,
> > -	 * which need net ref.
> > -	 */
> > -	sk = smc->clcsock->sk;
> > -	__netns_tracker_free(net, &sk->ns_tracker, false);
> > -	sk->sk_net_refcnt = 1;
> > -	get_net_track(net, &sk->ns_tracker, GFP_KERNEL);
> > -	sock_inuse_add(net, 1);
> I don't think this line shoud be removed. Otherwise, the popurse here to 
> manage the per namespace statistics in the case of network namespace 
> isolation would be lost.

Now it's counted in sk_alloc().

sock_create_net() below passes hold_net=true to sk_alloc() and if
sk->sk_netns_refcnt (== hold_net) is true, sock_inuse_add() is
called there.

See patch 9 and 10:
https://lore.kernel.org/netdev/20241213092152.14057-10-kuniyu@amazon.com/
https://lore.kernel.org/netdev/20241213092152.14057-11-kuniyu@amazon.com/


> @D. Wythe, could you please check it again? Maybe you have some good 
> testing on this case.
> 
> > -	return 0;
> > +	return sock_create_net(net, family, SOCK_STREAM, IPPROTO_TCP,
> > +			       &smc_sk(sk)->clcsock);
> >   }

  reply	other threads:[~2024-12-13 13:54 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-13  9:21 [PATCH v3 net-next 00/15] treewide: socket: Clean up sock_create() and friends Kuniyuki Iwashima
2024-12-13  9:21 ` [PATCH v3 net-next 01/15] socket: Un-export __sock_create() Kuniyuki Iwashima
2024-12-13  9:21 ` [PATCH v3 net-next 02/15] socket: Pass hold_net flag to __sock_create() Kuniyuki Iwashima
2024-12-13  9:21 ` [PATCH v3 net-next 03/15] smc: Pass kern to smc_sock_alloc() Kuniyuki Iwashima
2024-12-13 13:46   ` Wenjia Zhang
2024-12-13  9:21 ` [PATCH v3 net-next 04/15] socket: Pass hold_net to struct net_proto_family.create() Kuniyuki Iwashima
2024-12-13 13:46   ` Wenjia Zhang
2024-12-17 10:24   ` Paolo Abeni
2024-12-13  9:21 ` [PATCH v3 net-next 05/15] ppp: Pass hold_net to struct pppox_proto.create() Kuniyuki Iwashima
2024-12-13  9:21 ` [PATCH v3 net-next 06/15] nfc: Pass hold_net to struct nfc_protocol.create() Kuniyuki Iwashima
2024-12-13  9:21 ` [PATCH v3 net-next 07/15] socket: Add hold_net flag to struct proto_accept_arg Kuniyuki Iwashima
2024-12-13  9:21 ` [PATCH v3 net-next 08/15] socket: Pass hold_net to sk_alloc() Kuniyuki Iwashima
2024-12-13 13:45   ` Wenjia Zhang
2024-12-13  9:21 ` [PATCH v3 net-next 09/15] socket: Respect hold_net in sk_alloc() Kuniyuki Iwashima
2024-12-13  9:21 ` [PATCH v3 net-next 10/15] socket: Introduce sock_create_net() Kuniyuki Iwashima
2024-12-13  9:21 ` [PATCH v3 net-next 11/15] socket: Remove kernel socket conversion Kuniyuki Iwashima
2024-12-13 13:45   ` Wenjia Zhang
2024-12-13 13:54     ` Kuniyuki Iwashima [this message]
2024-12-13 15:15       ` Wenjia Zhang
2024-12-13 14:15   ` Chuck Lever
2024-12-13 23:29   ` Allison Henderson
2024-12-13  9:21 ` [PATCH v3 net-next 12/15] socket: Move sock_inuse_add() to sock.c Kuniyuki Iwashima
2024-12-13  9:21 ` [PATCH v3 net-next 13/15] socket: Use sock_create_net() instead of sock_create() Kuniyuki Iwashima
2024-12-13  9:21 ` [PATCH v3 net-next 14/15] socket: Rename sock_create() to sock_create_user() Kuniyuki Iwashima
2024-12-13  9:21 ` [PATCH v3 net-next 15/15] socket: Rename sock_create_kern() to sock_create_net_noref() Kuniyuki Iwashima
2024-12-13 13:46   ` Wenjia Zhang
2024-12-17 10:32   ` 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=20241213135437.44216-1-kuniyu@amazon.com \
    --to=kuniyu@amazon.com \
    --cc=alibuda@linux.alibaba.com \
    --cc=allison.henderson@oracle.com \
    --cc=chuck.lever@oracle.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jaka@linux.ibm.com \
    --cc=jlayton@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuni1840@gmail.com \
    --cc=matttbe@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sfrench@samba.org \
    --cc=wenjia@linux.ibm.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 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).