Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't listen ipv4 address #454

Open
CCCAUCHY opened this issue Oct 9, 2023 · 11 comments
Open

can't listen ipv4 address #454

CCCAUCHY opened this issue Oct 9, 2023 · 11 comments

Comments

@CCCAUCHY
Copy link

CCCAUCHY commented Oct 9, 2023

what ever net.ipv6.bindv6only is 1 or 0, I can't access ksmbd server over ipv4

@namjaejeon
Copy link
Owner

@CCCAUCHY Can you fix this after checking source code ?

@CCCAUCHY
Copy link
Author

CCCAUCHY commented Oct 11, 2023

@CCCAUCHY Can you fix this after checking source code ?

Sorry, I'm not good at linux kernel development

And ksmbd made my amazon linux auto reboot always, maybe I should try samba.

@namjaejeon
Copy link
Owner

Can you describe how to reproduce this ? Because ksmbd try to create ipv4 socket if ipv6 fail.

@CCCAUCHY
Copy link
Author

CCCAUCHY commented Oct 11, 2023

Can you describe how to reproduce this ? Because ksmbd try to create ipv4 socket if ipv6 fail.

I install ksmbd on aws(amazon linux), then I intall tools and configure it, after ksmbd.mountd and netstat -nlpt, no ipv4 port listening, also can't access over ipv4.

I try it on Ubuntu just now, it listen two ports 445 this time.

root@nfs:/home/ubuntu# ksmbd.control -s
root@nfs:/home/ubuntu# ksmbd.mountd
root@nfs:/home/ubuntu# netstat -nlpt|grep 445
tcp6       0      0 :::445                  :::*                    LISTEN      -
tcp6       0      0 :::445                  :::*                    LISTEN      -

If you can not reproduce this, I will share my cloud instance to you, then I will delete the instance after you find out the reason.

@oleksandrl5
Copy link

I have the same issue on alpine 3.19

@namjaejeon
Copy link
Owner

@oleksandrl5 Please share error prints on dmesg at least.

@namjaejeon
Copy link
Owner

@CCCAUCHY @oleksandrl5 Okay, I understood what is problem. I will check it. Thanks.

@namjaejeon
Copy link
Owner

@CCCAUCHY Even when net.ipv6.bindv6only is 0, IPv4 connection is not possible? I received another report that IPv4 connection was not possible only when net.ipv6.bindv6only was 1. i.e. they said there is no problem when the value is 0.

@CCCAUCHY
Copy link
Author

@CCCAUCHY Even when net.ipv6.bindv6only is 0, IPv4 connection is not possible? I received another report that IPv4 connection was not possible only when net.ipv6.bindv6only was 1. i.e. they said there is no problem when the value is 0.

It works on Ubuntu indeed. My problem is on Amazon Linux. And I have given up building NAS.

@namjaejeon
Copy link
Owner

@CCCAUCHY Thanks for checking it on Ubuntu.

Can you check if this change fixes your issue on Amazon Linux ?

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);

@CCCAUCHY
Copy link
Author

@CCCAUCHY Thanks for checking it on Ubuntu.

Can you check if this change fixes your issue on Amazon Linux ?

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);

Sorry, I am not good at compile. I just install ksmbd by yum.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants