This patch adds support to set the skb mark value for the DLM listen
tcp and sctp sockets. The mark value will be offered as cluster
configuration. At creation time of the listen socket it will be set as
socket option.

Signed-off-by: Alexander Aring <[email protected]>
---
 fs/dlm/config.c   |  6 ++++++
 fs/dlm/config.h   |  1 +
 fs/dlm/lowcomms.c | 16 ++++++++++++++++
 3 files changed, 23 insertions(+)

diff --git a/fs/dlm/config.c b/fs/dlm/config.c
index 3b21082e1b55..d74655cd6cd3 100644
--- a/fs/dlm/config.c
+++ b/fs/dlm/config.c
@@ -73,6 +73,7 @@ struct dlm_cluster {
        unsigned int cl_log_debug;
        unsigned int cl_log_info;
        unsigned int cl_protocol;
+       unsigned int cl_mark;
        unsigned int cl_timewarn_cs;
        unsigned int cl_waitwarn_us;
        unsigned int cl_new_rsb_count;
@@ -96,6 +97,7 @@ enum {
        CLUSTER_ATTR_LOG_DEBUG,
        CLUSTER_ATTR_LOG_INFO,
        CLUSTER_ATTR_PROTOCOL,
+       CLUSTER_ATTR_MARK,
        CLUSTER_ATTR_TIMEWARN_CS,
        CLUSTER_ATTR_WAITWARN_US,
        CLUSTER_ATTR_NEW_RSB_COUNT,
@@ -168,6 +170,7 @@ CLUSTER_ATTR(scan_secs, 1);
 CLUSTER_ATTR(log_debug, 0);
 CLUSTER_ATTR(log_info, 0);
 CLUSTER_ATTR(protocol, 0);
+CLUSTER_ATTR(mark, 0);
 CLUSTER_ATTR(timewarn_cs, 1);
 CLUSTER_ATTR(waitwarn_us, 0);
 CLUSTER_ATTR(new_rsb_count, 0);
@@ -183,6 +186,7 @@ static struct configfs_attribute *cluster_attrs[] = {
        [CLUSTER_ATTR_LOG_DEBUG] = &cluster_attr_log_debug,
        [CLUSTER_ATTR_LOG_INFO] = &cluster_attr_log_info,
        [CLUSTER_ATTR_PROTOCOL] = &cluster_attr_protocol,
+       [CLUSTER_ATTR_MARK] = &cluster_attr_mark,
        [CLUSTER_ATTR_TIMEWARN_CS] = &cluster_attr_timewarn_cs,
        [CLUSTER_ATTR_WAITWARN_US] = &cluster_attr_waitwarn_us,
        [CLUSTER_ATTR_NEW_RSB_COUNT] = &cluster_attr_new_rsb_count,
@@ -855,6 +859,7 @@ int dlm_our_addr(struct sockaddr_storage *addr, int num)
 #define DEFAULT_LOG_DEBUG          0
 #define DEFAULT_LOG_INFO           1
 #define DEFAULT_PROTOCOL           0
+#define DEFAULT_MARK               0
 #define DEFAULT_TIMEWARN_CS      500 /* 5 sec = 500 centiseconds */
 #define DEFAULT_WAITWARN_US       0
 #define DEFAULT_NEW_RSB_COUNT    128
@@ -871,6 +876,7 @@ struct dlm_config_info dlm_config = {
        .ci_log_debug = DEFAULT_LOG_DEBUG,
        .ci_log_info = DEFAULT_LOG_INFO,
        .ci_protocol = DEFAULT_PROTOCOL,
+       .ci_mark = DEFAULT_MARK,
        .ci_timewarn_cs = DEFAULT_TIMEWARN_CS,
        .ci_waitwarn_us = DEFAULT_WAITWARN_US,
        .ci_new_rsb_count = DEFAULT_NEW_RSB_COUNT,
diff --git a/fs/dlm/config.h b/fs/dlm/config.h
index 2b471aae4e61..13508ec3ff5e 100644
--- a/fs/dlm/config.h
+++ b/fs/dlm/config.h
@@ -31,6 +31,7 @@ struct dlm_config_info {
        int ci_log_debug;
        int ci_log_info;
        int ci_protocol;
+       int ci_mark;
        int ci_timewarn_cs;
        int ci_waitwarn_us;
        int ci_new_rsb_count;
diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c
index cdfaf4f0e11a..1bc32e728ba4 100644
--- a/fs/dlm/lowcomms.c
+++ b/fs/dlm/lowcomms.c
@@ -1240,6 +1240,14 @@ static struct socket *tcp_create_listen_sock(struct 
connection *con,
                goto create_out;
        }
 
+       /* set skb mark */
+       result = kernel_setsockopt(sock, SOL_SOCKET, SO_MARK,
+                                  (char *)&dlm_config.ci_mark,
+                                  sizeof(dlm_config.ci_mark));
+       if (result < 0)
+               log_print("Failed to set SO_MARK value to %u",
+                         dlm_config.ci_mark);
+
        /* Turn off Nagle's algorithm */
        kernel_setsockopt(sock, SOL_TCP, TCP_NODELAY, (char *)&one,
                          sizeof(one));
@@ -1324,6 +1332,14 @@ static int sctp_listen_for_all(void)
                goto out;
        }
 
+       /* set skb mark */
+       result = kernel_setsockopt(sock, SOL_SOCKET, SO_MARK,
+                                  (char *)&dlm_config.ci_mark,
+                                  sizeof(dlm_config.ci_mark));
+       if (result < 0)
+               log_print("Failed to set SO_MARK value to %u",
+                         dlm_config.ci_mark);
+
        result = kernel_setsockopt(sock, SOL_SOCKET, SO_RCVBUFFORCE,
                                 (char *)&bufsize, sizeof(bufsize));
        if (result)
-- 
2.26.2

Reply via email to