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

socket: only issue IPPROTO_IPV6 setsockopt calls on AF_INET6 sockets #4131

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from

Conversation

jengelh
Copy link
Contributor

@jengelh jengelh commented May 4, 2023

When --enable-ipv6-default is on and #define IPV6_DEFAULT is set, setsockopt(... IPPROTO_IPV6 ..) is unconditionally called even if the socket family might be something non-IPv6, which could explain "Protocol not available" error messages seen in #2648 .

Not tested beyond building.

@gluster-ant
Copy link
Collaborator

Can one of the admins verify this patch?

2 similar comments
@gluster-ant
Copy link
Collaborator

Can one of the admins verify this patch?

@gluster-ant
Copy link
Collaborator

Can one of the admins verify this patch?

@gluster-ant
Copy link
Collaborator

CLANG-FORMAT FAILURE:
Before merging the patch, this diff needs to be considered for passing clang-format

index 5b6870e6c..cbba29a18 100644
--- a/rpc/rpc-transport/socket/src/socket.c
+++ b/rpc/rpc-transport/socket/src/socket.c
@@ -56,7 +56,8 @@
 #if !defined(DEFAULT_VERIFY_DEPTH)
 #define DEFAULT_VERIFY_DEPTH 1
 #endif
-#define DEFAULT_CIPHER_LIST "AES128:EECDH:EDH:HIGH:!3DES:!RC4:!DES:!MD5:!aNULL:!eNULL"
+#define DEFAULT_CIPHER_LIST                                                    \
+    "AES128:EECDH:EDH:HIGH:!3DES:!RC4:!DES:!MD5:!aNULL:!eNULL"
 #define DEFAULT_DH_PARAM SSL_CERT_PATH "/dhparam.pem"
 #define DEFAULT_EC_CURVE "prime256v1"
 
@@ -3284,7 +3285,8 @@ socket_connect(rpc_transport_t *this, int port)
         int disable_v6only = 0;
         int fdsock_family = 0;
         socklen_t fdsock_size = sizeof(fdsock_family);
-        if (getsockopt(priv->sock, SOL_SOCKET, SO_DOMAIN, &fdsock_family, &fdsock_size) == 0 &&
+        if (getsockopt(priv->sock, SOL_SOCKET, SO_DOMAIN, &fdsock_family,
+                       &fdsock_size) == 0 &&
             fdsock_family == AF_INET6 &&
             setsockopt(priv->sock, IPPROTO_IPV6, IPV6_V6ONLY,
                        (void *)&disable_v6only, sizeof(disable_v6only)) < 0) {

Copy link

stale bot commented Dec 15, 2023

Thank you for your contributions.
Noticed that this issue is not having any activity in last ~6 months! We are marking this issue as stale because it has not had recent activity.
It will be closed in 2 weeks if no one responds with a comment here.

@stale stale bot added the wontfix Managed by stale[bot] label Dec 15, 2023
@jengelh
Copy link
Contributor Author

jengelh commented Dec 15, 2023

Bad bot, bad bot! Issues don't just go away, automatic closing is wrong most of the time

Meanwhile commit 1e36760 [#3701] appeared whicih also addresses but failed to reference this ticket in any way. Something is really wrong in this project.

@stale stale bot removed the wontfix Managed by stale[bot] label Dec 15, 2023
@gluster-ant
Copy link
Collaborator

CLANG-FORMAT FAILURE:
Before merging the patch, this diff needs to be considered for passing clang-format

index 7b62bea70..d42c97b23 100644
--- a/libglusterfs/src/glusterfs/libglusterfs-messages.h
+++ b/libglusterfs/src/glusterfs/libglusterfs-messages.h
@@ -267,28 +267,17 @@ GLFS_MIG(LIBGLUSTERFS, LG_MSG_INPUT_DATA_NULL, "", 0)
 GLFS_MIG(LIBGLUSTERFS, LG_MSG_OPEN_LOGFILE_FAILED, "", 0)
 
 GLFS_NEW(LIBGLUSTERFS, LG_MSG_IO_CALL_FAILED, "Function call failed", 2,
-    GLFS_FUNC(function),
-    GLFS_RES(error)
-)
+         GLFS_FUNC(function), GLFS_RES(error))
 
 GLFS_NEW(LIBGLUSTERFS, LG_MSG_IO_THREAD_BAD_PRIORITY,
-         "Specified priority is out of bounds", 1,
-    GLFS_I32(priority)
-)
+         "Specified priority is out of bounds", 1, GLFS_I32(priority))
 
 GLFS_NEW(LIBGLUSTERFS, LG_MSG_IO_CBK_SLOW,
-         "Execution of callback took too much time", 5,
-    GLFS_FUNC(name),
-    GLFS_PTR(address),
-    GLFS_STR(file),
-    GLFS_U32(line),
-    GLFS_U64(us)
-)
+         "Execution of callback took too much time", 5, GLFS_FUNC(name),
+         GLFS_PTR(address), GLFS_STR(file), GLFS_U32(line), GLFS_U64(us))
 
 GLFS_NEW(LIBGLUSTERFS, LG_MSG_IO_THREAD_NO_CPU,
-         "Cannot find a suitable CPU for a thread", 1,
-    GLFS_U32(index)
-)
+         "Cannot find a suitable CPU for a thread", 1, GLFS_U32(index))
 
 GLFS_NEW(LIBGLUSTERFS, LG_MSG_IO_THREAD_NAME_INVALID,
          "Tried to construct and invalid name for a thread", 0)
@@ -306,48 +295,35 @@ GLFS_NEW(LIBGLUSTERFS, LG_MSG_IO_URING_MISSING_FEAT,
          0)
 
 GLFS_NEW(LIBGLUSTERFS, LG_MSG_IO_URING_TOO_SMALL,
-         "Maximum allowed SQ size is too small", 1,
-    GLFS_U32(max)
-)
+         "Maximum allowed SQ size is too small", 1, GLFS_U32(max))
 
 GLFS_NEW(LIBGLUSTERFS, LG_MSG_IO_URING_ENTER_FAILED,
          "io_uring_enter() failed with an unrecoverable error. This could "
          "mean a critical bug or a memory corruption. The process cannot "
-         "continue in this state", 1,
-    GLFS_RES(error)
-)
+         "continue in this state",
+         1, GLFS_RES(error))
 
 GLFS_NEW(LIBGLUSTERFS, LG_MSG_IO_SYNC_TIMEOUT,
-         "Time out while waiting for synchronization", 1,
-    GLFS_U32(retries)
-)
+         "Time out while waiting for synchronization", 1, GLFS_U32(retries))
 
 GLFS_NEW(LIBGLUSTERFS, LG_MSG_IO_SYNC_ABORTED,
-         "Synchronization took too much time", 1,
-    GLFS_U32(retries)
-)
+         "Synchronization took too much time", 1, GLFS_U32(retries))
 
 GLFS_NEW(LIBGLUSTERFS, LG_MSG_IO_SYNC_COMPLETED, "Synchronization completed", 1,
-    GLFS_U32(retries)
-)
+         GLFS_U32(retries))
 
 GLFS_NEW(LIBGLUSTERFS, LG_MSG_IO_BAD_ERRNO, "Unexpected errno value", 1,
-    GLFS_I32(err)
-)
+         GLFS_I32(err))
 
 GLFS_NEW(LIBGLUSTERFS, LG_MSG_IO_BAD_RETURN, "Unexpected return value", 1,
-    GLFS_I32(ret)
-)
+         GLFS_I32(ret))
 
 GLFS_NEW(LIBGLUSTERFS, LG_MSG_NOFILE_FAILED,
-    "Failed to set maximum number of open file descriptors", 2,
-    GLFS_I64(low), GLFS_I64(high)
-)
+         "Failed to set maximum number of open file descriptors", 2,
+         GLFS_I64(low), GLFS_I64(high))
 
-GLFS_NEW(LIBGLUSTERFS, LG_MSG_UNLINK_FAILED,
-    "Failed to remove file", 1,
-    GLFS_STR(path)
-)
+GLFS_NEW(LIBGLUSTERFS, LG_MSG_UNLINK_FAILED, "Failed to remove file", 1,
+         GLFS_STR(path))
 
 #define LG_MSG_EPOLL_FD_CREATE_FAILED_STR "epoll fd creation failed"
 #define LG_MSG_INVALID_POLL_IN_STR "invalid poll_in value"
diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c
index afbf4e51c..9a6c1af83 100644
--- a/rpc/rpc-transport/socket/src/socket.c
+++ b/rpc/rpc-transport/socket/src/socket.c
@@ -57,7 +57,7 @@
 #define DEFAULT_VERIFY_DEPTH 1
 #endif
 #define DEFAULT_CIPHER_LIST
-    "AES128:EECDH:EDH:HIGH:!3DES:!RC4:!DES:!MD5:!aNULL:!eNULL"
+"AES128:EECDH:EDH:HIGH:!3DES:!RC4:!DES:!MD5:!aNULL:!eNULL"
 #define DEFAULT_DH_PARAM SSL_CERT_PATH "/dhparam.pem"
 #define DEFAULT_EC_CURVE "prime256v1"
 
@@ -67,8 +67,8 @@
 
 #define IOV_MIN(n) min(IOV_MAX, n)
 
-typedef int
-SSL_unary_func(SSL *);
+    typedef int
+    SSL_unary_func(SSL *);
 typedef int
 SSL_trinary_func(SSL *, void *, int);
 static int
diff --git a/xlators/mgmt/glusterd/src/glusterd-syncop.c b/xlators/mgmt/glusterd/src/glusterd-syncop.c
index 53f36c1ba..3040113a9 100644
--- a/xlators/mgmt/glusterd/src/glusterd-syncop.c
+++ b/xlators/mgmt/glusterd/src/glusterd-syncop.c
@@ -2417,10 +2417,7 @@ gd_get_brick_count(struct cds_list_head *bricks)
 {
     glusterd_pending_node_t *pending_node = NULL;
     int npeers = 0;
-    cds_list_for_each_entry(pending_node, bricks, list)
-    {
-        npeers++;
-    }
+    cds_list_for_each_entry(pending_node, bricks, list) { npeers++; }
     return npeers;
 }
 
diff --git a/xlators/storage/posix/src/posix-inode-fd-ops.c b/xlators/storage/posix/src/posix-inode-fd-ops.c
index 1f311c6fc..4a385e289 100644
--- a/xlators/storage/posix/src/posix-inode-fd-ops.c
+++ b/xlators/storage/posix/src/posix-inode-fd-ops.c
@@ -6020,10 +6020,7 @@ posix_readdirp(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
         if (op_ret >= 0) {
             op_ret = 0;
 
-            list_for_each_entry(entry, &entries.list, list)
-            {
-                op_ret++;
-            }
+            list_for_each_entry(entry, &entries.list, list) { op_ret++; }
         }
 
         STACK_UNWIND_STRICT(readdirp, frame, op_ret, op_errno, &entries, NULL);

@jengelh
Copy link
Contributor Author

jengelh commented Mar 20, 2024

alright this style checker is completely broken if it wants that typedef shifted right 🤦

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

Successfully merging this pull request may close these issues.

None yet

2 participants