From fb43d1a3163f224873196a4317a95aa4ed85d753 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20PORTAY?= Date: Thu, 25 Apr 2024 11:18:16 +0200 Subject: [PATCH] [Inet] Fix setting for SOCK_CLOEXEC The linux kernel allows to set the flag SOCK_CLOEXEC through the parameter type[1]. The implementation sets the flag through the parameter protocol and causes the call to socket()[2] to return -1 with EINVAL. This fixes the behaviour by OR-ing the flag SOCK_CLOEXEC to type instead of protocol. [1]: https://github.com/torvalds/linux/blob/v6.8/net/socket.c#L1655 [2]: https://man7.org/linux/man-pages/man2/socket.2.html --- src/inet/InetInterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/inet/InetInterface.cpp b/src/inet/InetInterface.cpp index db10bdba3ed769..ad186aec1dbf6a 100644 --- a/src/inet/InetInterface.cpp +++ b/src/inet/InetInterface.cpp @@ -500,7 +500,7 @@ int GetIOCTLSocket() { int s; #ifdef SOCK_CLOEXEC - s = socket(AF_INET, SOCK_STREAM, SOCK_CLOEXEC); + s = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0); if (s < 0) #endif {