Is it possible to increase TCP listen backlog for smbd?

Solution Unverified - Updated

Environment

  • Red Hat Enterprise Linux 7, 8, 9
  • samba

Issue

  • Is it possible to increase TCP listen backlog for smbd?

Resolution

  • No, the backlog argument of listen() is a hardcoded value with a macro definition, SMBD_LISTEN_BACKLOG.

samba-4.15.5-108.el9_0.src.rpm(RHEL9)
source3/include/local.h:

/* size of listen() backlog in smbd */
#define SMBD_LISTEN_BACKLOG 50

source3/smbd/server.c:

static bool smbd_open_one_socket(struct smbd_parent_context *parent,
                                 struct tevent_context *ev_ctx,
                                 const struct sockaddr_storage *ifss,
                                 uint16_t port)
{
...

        if (listen(s->fd, SMBD_LISTEN_BACKLOG) == -1) {
                DEBUG(0,("smbd_open_one_socket: listen: "
                        "%s\n", strerror(errno)));
                        close(s->fd);
                TALLOC_FREE(s);
                return false;
        }

Diagnostic Steps

$ ss -npl src :445
Netid          State           Recv-Q          Send-Q                   Local Address:Port                    Peer Address:Port          Process          
tcp            LISTEN          0               50                             0.0.0.0:445                          0.0.0.0:*                              
tcp            LISTEN          0               50                                [::]:445                             [::]:*                              
$ ss -npl src :139
Netid          State           Recv-Q          Send-Q                   Local Address:Port                    Peer Address:Port          Process          
tcp            LISTEN          0               50                             0.0.0.0:139                          0.0.0.0:*                              
tcp            LISTEN          0               50                                [::]:139                             [::]:*                              
$ sysctl net.core.somaxconn
net.core.somaxconn = 4096
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.