diff mbox series

[1/4] ksmbd: off ipv6only for both ipv4/ipv6 binding

Message ID 20240502121425.5123-1-linkinjeon@kernel.org
State New
Headers show
Series [1/4] ksmbd: off ipv6only for both ipv4/ipv6 binding | expand

Commit Message

Namjae Jeon May 2, 2024, 12:14 p.m. UTC
ΕΛΕΝΗ reported that ksmbd binds to the IPV6 wildcard (::) by default for
ipv4 and ipv6 binding. So IPV4 connections are successful only when
the Linux system parameter bindv6only is set to 0 [default value].
If this parameter is set to 1, then the ipv6 wildcard only represents
any IPV6 address. Samba creates different sockets for ipv4 and ipv6
by default. This patch off sk_ipv6only to support IPV4/IPV6 connections
without creating two sockets.

Reported-by: ΕΛΕΝΗ ΤΖΑΒΕΛΛΑ <helentzavellas@yahoo.gr>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
---
 fs/smb/server/transport_tcp.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Stefan Metzmacher May 27, 2024, 4:09 p.m. UTC | #1
Hi Namjae,

> ΕΛΕΝΗ reported that ksmbd binds to the IPV6 wildcard (::) by default for
> ipv4 and ipv6 binding. So IPV4 connections are successful only when
> the Linux system parameter bindv6only is set to 0 [default value].
> If this parameter is set to 1, then the ipv6 wildcard only represents
> any IPV6 address. Samba creates different sockets for ipv4 and ipv6
> by default. This patch off sk_ipv6only to support IPV4/IPV6 connections
> without creating two sockets.

I think having two sockets '::' and '0.0.0.0' would be
better, would that also be possible?

It makes it more explicit and avoids ipv4 mapped addresses
like ::ffff:192.0.2.128, which are really ugly.

metze
diff mbox series

Patch

diff --git a/fs/smb/server/transport_tcp.c b/fs/smb/server/transport_tcp.c
index 002a3f0dc7c5..6633fa78e9b9 100644
--- a/fs/smb/server/transport_tcp.c
+++ b/fs/smb/server/transport_tcp.c
@@ -448,6 +448,10 @@  static int create_socket(struct interface *iface)
 		sin6.sin6_family = PF_INET6;
 		sin6.sin6_addr = in6addr_any;
 		sin6.sin6_port = htons(server_conf.tcp_port);
+
+		lock_sock(ksmbd_socket->sk);
+		ksmbd_socket->sk->sk_ipv6only = false;
+		release_sock(ksmbd_socket->sk);
 	}
 
 	ksmbd_tcp_nodelay(ksmbd_socket);