fs: dlm: introduce proto values
authorAlexander Aring <aahringo@redhat.com>
Wed, 2 Jun 2021 13:45:19 +0000 (09:45 -0400)
committerDavid Teigland <teigland@redhat.com>
Wed, 2 Jun 2021 16:53:04 +0000 (11:53 -0500)
Currently the dlm protocol values are that TCP is 0 and everything else
is SCTP. This makes it difficult to introduce possible other transport
layers. The only one user space tool dlm_controld, which I am aware of,
handles the protocol value 1 for SCTP. We change it now to handle SCTP
as 1, this will break user space API but it will fix it so we can add
possible other transport layers.

Signed-off-by: Alexander Aring <aahringo@redhat.com>
Signed-off-by: David Teigland <teigland@redhat.com>
fs/dlm/config.c
fs/dlm/config.h
fs/dlm/lowcomms.c

index db717a879537730877bdc4616c8d3f94ebd893c9..c91c1c73ed9d8903b0e0247e691f8de131eed532 100644 (file)
@@ -952,7 +952,7 @@ int dlm_our_addr(struct sockaddr_storage *addr, int num)
 #define DEFAULT_SCAN_SECS          5
 #define DEFAULT_LOG_DEBUG          0
 #define DEFAULT_LOG_INFO           1
-#define DEFAULT_PROTOCOL           0
+#define DEFAULT_PROTOCOL           DLM_PROTO_TCP
 #define DEFAULT_MARK               0
 #define DEFAULT_TIMEWARN_CS      500 /* 5 sec = 500 centiseconds */
 #define DEFAULT_WAITWARN_US       0
index d2cd4bd20313f7244d8f98d6595cc65b394fb308..00374b45c748eeb3c6c3643b17d586bc337cbf80 100644 (file)
@@ -23,6 +23,9 @@ struct dlm_config_node {
 
 #define DLM_MAX_ADDR_COUNT 3
 
+#define DLM_PROTO_TCP  0
+#define DLM_PROTO_SCTP 1
+
 struct dlm_config_info {
        int ci_tcp_port;
        int ci_buffer_size;
index 6b150e3aa30c7a991d83b5aa0ca405af7ad5db33..f2a3b0401b9cf6622f4b61629bf131e429974d76 100644 (file)
@@ -208,12 +208,18 @@ static int dlm_con_init(struct connection *con, int nodeid)
        INIT_WORK(&con->rwork, process_recv_sockets);
        init_waitqueue_head(&con->shutdown_wait);
 
-       if (dlm_config.ci_protocol == 0) {
+       switch (dlm_config.ci_protocol) {
+       case DLM_PROTO_TCP:
                con->connect_action = tcp_connect_to_sock;
                con->shutdown_action = dlm_tcp_shutdown;
                con->eof_condition = tcp_eof_condition;
-       } else {
+               break;
+       case DLM_PROTO_SCTP:
                con->connect_action = sctp_connect_to_sock;
+               break;
+       default:
+               kfree(con->rx_buf);
+               return -EINVAL;
        }
 
        return 0;
@@ -1968,10 +1974,19 @@ int dlm_lowcomms_start(void)
        dlm_allow_conn = 1;
 
        /* Start listening */
-       if (dlm_config.ci_protocol == 0)
+       switch (dlm_config.ci_protocol) {
+       case DLM_PROTO_TCP:
                error = tcp_listen_for_all();
-       else
+               break;
+       case DLM_PROTO_SCTP:
                error = sctp_listen_for_all(&listen_con);
+               break;
+       default:
+               log_print("Invalid protocol identifier %d set",
+                         dlm_config.ci_protocol);
+               error = -EINVAL;
+               break;
+       }
        if (error)
                goto fail_unlisten;