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

Failed to bind socket #606

Open
jobsidi opened this issue Nov 21, 2023 · 13 comments
Open

Failed to bind socket #606

jobsidi opened this issue Nov 21, 2023 · 13 comments

Comments

@jobsidi
Copy link

jobsidi commented Nov 21, 2023

Linux 6.2.16-19-pve #1 SMP PREEMPT_DYNAMIC PMX 6.2.16-19 (2023-10-24T12:07Z) x86_64 GNU/Linux
im getting multiply strings
kernel: ksmbd: Failed to bind socket: -98 kernel: ksmbd: Failed to shutdown socket: -107
default config. No additional info in logs. Also unable to bind interfaces, daemon dosnt start if i set it active

@namjaejeon
Copy link
Member

-98 is EADDRINUSE. this address is already used.

If samba is running on your system, Please try to start ksmbd after stopping smbd(samba).

@jobsidi
Copy link
Author

jobsidi commented Nov 22, 2023

smbd was uninstalled automatically when i installed ksmbd. bookworm. Address do you mean ports?

@namjaejeon
Copy link
Member

Yes. tcp port 445.
You can change it by adding "tcp port = " parameter in global section of ksmbd.conf.

@jobsidi
Copy link
Author

jobsidi commented Nov 22, 2023

no result

@namjaejeon
Copy link
Member

Please find the root-cause after getting information from googling. Problem is caused by EADDRINUSE error.

@jobsidi
Copy link
Author

jobsidi commented Nov 22, 2023

Already tried to google. Nothing except string in sources. Also i didnt find any possibility to activate debug log in ksmdb. Also i tested performance with crystalmark and i see absolutely no difference between samba 4 and ksmbd

@oleksandrl5
Copy link

Have the same issue. Cant bind to ipv4 adresses

@namjaejeon
Copy link
Member

@oleksandrl5 Okay, Can you check the code and debug(create_socket() in transport_tcp.c) ?

@namjaejeon
Copy link
Member

@oleksandrl5 Can you show me print log after applying this change ? When I have tested it after turning IPV6 off, ksmbd work fine.

diff --git a/transport_tcp.c b/transport_tcp.c
index 1d3ddba..bd45d29 100644
--- a/transport_tcp.c
+++ b/transport_tcp.c
@@ -459,10 +459,12 @@ static int create_socket(struct interface *iface)
 
        ret = sock_create(PF_INET6, SOCK_STREAM, IPPROTO_TCP, &ksmbd_socket);
        if (ret) {
+               pr_err("ipv6 ret : %d\n", 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);
+               pr_err("ipv4 ret : %d\n", ret);
                if (ret) {
                        pr_err("Can't create socket for ipv4: %d\n", ret);
                        goto out_clear;

@ItsFated
Copy link

ItsFated commented Jun 1, 2024

In my case, after all Docker containers are started. there is a virtual bridge can't bind the port.
root@home:~# netstat -tuln | grep :445
tcp6 0 0 :::445 :::* LISTEN
tcp6 0 0 :::445 :::* LISTEN
tcp6 0 0 :::445 :::* LISTEN

root@home:~# ss -tuln | grep :445
tcp LISTEN 0 16 *%br-7607a822f471:445 :
tcp LISTEN 0 16 *%docker0:445 :
tcp LISTEN 0 16 *%vmbr0:445 :

There are many failue logs in dmesg, KSMBD seems to have always wanted to bind to the network bridge, but failed many times:
[ 266.039590] ksmbd: Failed to bind socket: -98
[ 266.039594] ksmbd: Failed to shutdown socket: -107
[ 266.039690] br-7607a822f471: port 17(veth79c9f3a) entered blocking state
[ 266.039695] br-7607a822f471: port 17(veth79c9f3a) entered forwarding state
[ 266.134517] eth0: renamed from veth8f45087
[ 266.148610] ksmbd: Failed to bind socket: -98
[ 266.148614] ksmbd: Failed to shutdown socket: -107
[ 266.148866] br-7607a822f471: port 18(veth081387e) entered blocking state
[ 266.148870] br-7607a822f471: port 18(veth081387e) entered forwarding state
[ 266.175528] eth0: renamed from vethbddc876
[ 266.191716] ksmbd: Failed to bind socket: -98
[ 266.191722] ksmbd: Failed to shutdown socket: -107
[ 266.191815] br-7607a822f471: port 19(veth6617f43) entered blocking state
[ 266.191820] br-7607a822f471: port 19(veth6617f43) entered forwarding state
[ 266.208499] eth0: renamed from vethc05cc5b
[ 266.219605] ksmbd: Failed to bind socket: -98
[ 266.219613] ksmbd: Failed to shutdown socket: -107
[ 266.219939] br-7607a822f471: port 20(veth9b1952d) entered blocking state
[ 266.219944] br-7607a822f471: port 20(veth9b1952d) entered forwarding state
[ 266.299417] br-7607a822f471: port 21(veth4f2dede) entered blocking state
[ 266.299425] br-7607a822f471: port 21(veth4f2dede) entered disabled state
[ 266.299441] veth4f2dede: entered allmulticast mode
[ 266.299514] veth4f2dede: entered promiscuous mode
[ 266.771485] eth0: renamed from vethbde197d
[ 266.779617] ksmbd: Failed to bind socket: -98
[ 266.779621] ksmbd: Failed to shutdown socket: -107
[ 266.779872] br-7607a822f471: port 21(veth4f2dede) entered blocking state
[ 266.779876] br-7607a822f471: port 21(veth4f2dede) entered forwarding state

how to fix it, or i can ignore the failue? can ksmbd only to bind one bridge?

@namjaejeon
Copy link
Member

@ItsFated Can you share how to reproduce it on ubuntu ?

@ItsFated
Copy link

ItsFated commented Jun 8, 2024

My system is proxmox.
Simply create a virtual bridge with Docker and attach a container (in my case there are many containers) to it, the state of the bridge will change and the fault log will be displayed. Here is a part of my compose configs, one docker network bridge and one container:

name: all_containers
services:
    qbittorrent:
        image: lscr.io/linuxserver/qbittorrent:latest
        container_name: qbittorrent
        environment:
            - PUID=1000
            - PGID=1000
            - WEBUI_PORT=8080
            - TORRENTING_PORT=6881
        volumes:
            - /home/jason/Downloads:/downloads
        ports:
            - 8080:8080
            - 6881:6881
            - 6881:6881/udp
        networks:
          - all
        restart: unless-stopped
networks:
  all:
    ipam:
      driver: default
      config:
        - subnet: 172.28.0.0/24
          ip_range: 172.28.0.0/24
          gateway: 172.28.0.1

@mmakassikis
Copy link

can you try binding to specific interfaces only and check if the issue is still present ?
In the global section of the config file, add a "interfaces =" parameter. For example:

[global]
interfaces = br0 br1
bind interfaces only = yes

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

5 participants