Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:23
erlang
6391-erts-Refuse-usage-of-SO_REUSEADDR-on-non-U...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 6391-erts-Refuse-usage-of-SO_REUSEADDR-on-non-UDP-sockets.patch of Package erlang
From eda0d1f053bd20993b4d20077053d4a0aa000988 Mon Sep 17 00:00:00 2001 From: Rickard Green <rickard@erlang.org> Date: Wed, 16 Nov 2022 16:09:25 +0100 Subject: [PATCH 1/2] [erts] Refuse usage of SO_REUSEADDR on non-UDP sockets on Windows --- erts/emulator/drivers/common/inet_drv.c | 30 ++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/erts/emulator/drivers/common/inet_drv.c b/erts/emulator/drivers/common/inet_drv.c index 8baf496e44..78daf0a8ed 100644 --- a/erts/emulator/drivers/common/inet_drv.c +++ b/erts/emulator/drivers/common/inet_drv.c @@ -6909,13 +6909,37 @@ static int inet_set_opts(inet_descriptor* desc, char* ptr, int len) desc->delimiter = (char)ival; continue; + case INET_OPT_REUSEADDR: +#ifdef __WIN32__ /* The behaviour changed in Windows Server 2003. * Now it works as the combo of `SO_REUSEADDR` and * `SO_REUSEPORT` does on *BSD. - * This option was "dangerous" only in Windows XP, - * which we don't support anymore! */ - case INET_OPT_REUSEADDR: type = SO_REUSEADDR; + if (desc->stype != SOCK_DGRAM) { + /* + * We refuse usage of SO_REUSEADDR on non-UDP sockets since it + * mostly (perhaps only) opens up for socket collisions and + * probably hasn't got any useful use-cases. There are useful + * use-cases for multicast sockets, though. For more + * information see: + * https://learn.microsoft.com/en-us/windows/win32/winsock/using-so-reuseaddr-and-so-exclusiveaddruse + * + * Prior to OTP 25 we also refused to use SO_REUSEADDR on any + * sockets on Windows. See + * 2a6ac6f3f027fcab6d607599e82714e930d9fde2 + * + * We certainly do not want to use it for the Erlang + * distribution TCP sockets since we can end up reusing our + * own active sockets as demonstrated in the issue: + * https://github.com/erlang/otp/issues/6461 + * + * We probably want to expose the Windows specific + * SO_EXCLUSIVEADDRUSE in the API as well... + */ + continue; + } +#endif + type = SO_REUSEADDR; DDBG(desc, ("INET-DRV-DBG[%d][" SOCKET_FSTR ",%T] " "inet_set_opts(reuseaddr) -> %s\r\n", -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor