netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Laight <david.laight.linux@gmail.com>
To: chenxiaosong@chenxiaosong.com
Cc: linkinjeon@kernel.org, sfrench@samba.org,
	senozhatsky@chromium.org, tom@talpey.com,
	linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org,
	ChenXiaoSong <chenxiaosong@kylinos.cn>,
	netdev@vger.kernel.org
Subject: Re: [PATCH] smb/server: use sock_create_kern() in create_socket()
Date: Mon, 24 Mar 2025 21:07:47 +0000	[thread overview]
Message-ID: <20250324210747.3dc899b9@pumpkin> (raw)
In-Reply-To: <20250324065155.665290-1-chenxiaosong@chenxiaosong.com>

On Mon, 24 Mar 2025 06:51:55 +0000
chenxiaosong@chenxiaosong.com wrote:

> From: ChenXiaoSong <chenxiaosong@kylinos.cn>
> 
> The socket resides in kernel space, so use sock_create_kern()
> instead of sock_create().

As in the other patches you need to worry about whether the socket
holds a reference to the network namespace.

	David

> 
> Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
> ---
>  fs/smb/server/transport_tcp.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/smb/server/transport_tcp.c b/fs/smb/server/transport_tcp.c
> index 7f38a3c3f5bd..e5f46a91c3fc 100644
> --- a/fs/smb/server/transport_tcp.c
> +++ b/fs/smb/server/transport_tcp.c
> @@ -429,12 +429,13 @@ static int create_socket(struct interface *iface)
>  	struct socket *ksmbd_socket;
>  	bool ipv4 = false;
>  
> -	ret = sock_create(PF_INET6, SOCK_STREAM, IPPROTO_TCP, &ksmbd_socket);
> +	ret = sock_create_kern(current->nsproxy->net_ns, PF_INET6, SOCK_STREAM,
> +			       IPPROTO_TCP, &ksmbd_socket);
>  	if (ret) {
>  		if (ret != -EAFNOSUPPORT)
>  			pr_err("Can't create socket for ipv6, fallback to ipv4: %d\n", ret);
> -		ret = sock_create(PF_INET, SOCK_STREAM, IPPROTO_TCP,
> -				  &ksmbd_socket);
> +		ret = sock_create_kern(current->nsproxy->net_ns, PF_INET,
> +				       SOCK_STREAM, IPPROTO_TCP, &ksmbd_socket);
>  		if (ret) {
>  			pr_err("Can't create socket for ipv4: %d\n", ret);
>  			goto out_clear;


       reply	other threads:[~2025-03-24 21:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20250324065155.665290-1-chenxiaosong@chenxiaosong.com>
2025-03-24 21:07 ` David Laight [this message]
2025-03-24 22:11   ` [PATCH] smb/server: use sock_create_kern() in create_socket() Kuniyuki Iwashima

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=20250324210747.3dc899b9@pumpkin \
    --to=david.laight.linux@gmail.com \
    --cc=chenxiaosong@chenxiaosong.com \
    --cc=chenxiaosong@kylinos.cn \
    --cc=linkinjeon@kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=senozhatsky@chromium.org \
    --cc=sfrench@samba.org \
    --cc=tom@talpey.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).