Bug 15149 - Failure to set socket option SO_REUSEPORT should not stop socket from being created
Summary: Failure to set socket option SO_REUSEPORT should not stop socket from being c...
Status: NEW
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: File services (show other bugs)
Version: 4.16.4
Hardware: All Linux
: P5 minor (vote)
Target Milestone: ---
Assignee: Samba QA Contact
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-08-18 02:21 UTC by Berto Furth
Modified: 2022-08-18 02:21 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Berto Furth 2022-08-18 02:21:50 UTC
In Samba v4.15 or later releases, when smbd starts up on Linux earlier than v3.9 that does not support the SO_REUSEPORT socket option, the server will fail to start. Log messages similar to the following are generated.

../../source3/lib/util_sock.c:294(open_socket_in)  open_socket_in: setsockopt(SO_REUSEPORT) failed: Protocol not available
../../source3/smbd/server.c:1097(smbd_open_one_socket)  smbd_open_one_socket: open_socket_in failed: Protocol not available
../../source3/smbd/server.c:1264(open_sockets_smbd)  open_sockets_smbd: No sockets available to bind to.
INTERNAL ERROR: open_sockets_smbd() failed in pid 12523 (4.16.3)

Samba v4.14 and earlier do not have this problem. Earlier versions of samba would continue to create a socket even if the SO_REUSEPORT option could not be set.

This problem appears to be introduced by 

"lib: Properly return errno from open_socket_in()" (Commit : 72540222c2290dc041fb01018de7febe44a4ac0d )

The problem could be fixed by modifying open_socket_in() and removing the "goto fail" statement in the "#ifdef SO_REUSEPORT" block. I have tested this using v4.16.3 and it seems to resolve the issue.