Skip to content

Commit 9c9f168

Browse files
Alexander Aringteigland
authored andcommitted
fs: dlm: set skb mark per peer socket
This patch adds support to set the skb mark value for the DLM tcp and sctp socket per peer. The mark value will be offered as per comm value of configfs. At creation time of the peer socket it will be set as socket option. Signed-off-by: Alexander Aring <aahringo@redhat.com> Signed-off-by: David Teigland <teigland@redhat.com>
1 parent a5b7ab6 commit 9c9f168

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

fs/dlm/config.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ enum {
200200
COMM_ATTR_LOCAL,
201201
COMM_ATTR_ADDR,
202202
COMM_ATTR_ADDR_LIST,
203+
COMM_ATTR_MARK,
203204
};
204205

205206
enum {
@@ -232,6 +233,7 @@ struct dlm_comm {
232233
int nodeid;
233234
int local;
234235
int addr_count;
236+
unsigned int mark;
235237
struct sockaddr_storage *addr[DLM_MAX_ADDR_COUNT];
236238
};
237239

@@ -469,6 +471,7 @@ static struct config_item *make_comm(struct config_group *g, const char *name)
469471
cm->nodeid = -1;
470472
cm->local = 0;
471473
cm->addr_count = 0;
474+
cm->mark = 0;
472475
return &cm->item;
473476
}
474477

@@ -664,8 +667,28 @@ static ssize_t comm_addr_list_show(struct config_item *item, char *buf)
664667
return 4096 - allowance;
665668
}
666669

670+
static ssize_t comm_mark_show(struct config_item *item, char *buf)
671+
{
672+
return sprintf(buf, "%u\n", config_item_to_comm(item)->mark);
673+
}
674+
675+
static ssize_t comm_mark_store(struct config_item *item, const char *buf,
676+
size_t len)
677+
{
678+
unsigned int mark;
679+
int rc;
680+
681+
rc = kstrtouint(buf, 0, &mark);
682+
if (rc)
683+
return rc;
684+
685+
config_item_to_comm(item)->mark = mark;
686+
return len;
687+
}
688+
667689
CONFIGFS_ATTR(comm_, nodeid);
668690
CONFIGFS_ATTR(comm_, local);
691+
CONFIGFS_ATTR(comm_, mark);
669692
CONFIGFS_ATTR_WO(comm_, addr);
670693
CONFIGFS_ATTR_RO(comm_, addr_list);
671694

@@ -674,6 +697,7 @@ static struct configfs_attribute *comm_attrs[] = {
674697
[COMM_ATTR_LOCAL] = &comm_attr_local,
675698
[COMM_ATTR_ADDR] = &comm_attr_addr,
676699
[COMM_ATTR_ADDR_LIST] = &comm_attr_addr_list,
700+
[COMM_ATTR_MARK] = &comm_attr_mark,
677701
NULL,
678702
};
679703

@@ -833,6 +857,20 @@ int dlm_comm_seq(int nodeid, uint32_t *seq)
833857
return 0;
834858
}
835859

860+
int dlm_comm_mark(int nodeid, unsigned int *mark)
861+
{
862+
struct dlm_comm *cm;
863+
864+
cm = get_comm(nodeid);
865+
if (!cm)
866+
return -ENOENT;
867+
868+
*mark = cm->mark;
869+
put_comm(cm);
870+
871+
return 0;
872+
}
873+
836874
int dlm_our_nodeid(void)
837875
{
838876
return local_comm ? local_comm->nodeid : 0;

fs/dlm/config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ void dlm_config_exit(void);
4646
int dlm_config_nodes(char *lsname, struct dlm_config_node **nodes_out,
4747
int *count_out);
4848
int dlm_comm_seq(int nodeid, uint32_t *seq);
49+
int dlm_comm_mark(int nodeid, unsigned int *mark);
4950
int dlm_our_nodeid(void);
5051
int dlm_our_addr(struct sockaddr_storage *addr, int num);
5152

fs/dlm/lowcomms.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,7 @@ static void sctp_connect_to_sock(struct connection *con)
914914
int result;
915915
int addr_len;
916916
struct socket *sock;
917+
unsigned int mark;
917918

918919
if (con->nodeid == 0) {
919920
log_print("attempt to connect sock 0 foiled");
@@ -944,6 +945,13 @@ static void sctp_connect_to_sock(struct connection *con)
944945
if (result < 0)
945946
goto socket_err;
946947

948+
/* set skb mark */
949+
result = dlm_comm_mark(con->nodeid, &mark);
950+
if (result < 0)
951+
goto bind_err;
952+
953+
sock_set_mark(sock->sk, mark);
954+
947955
con->rx_action = receive_from_sock;
948956
con->connect_action = sctp_connect_to_sock;
949957
add_sock(sock, con);
@@ -1006,6 +1014,7 @@ static void tcp_connect_to_sock(struct connection *con)
10061014
struct sockaddr_storage saddr, src_addr;
10071015
int addr_len;
10081016
struct socket *sock = NULL;
1017+
unsigned int mark;
10091018
int result;
10101019

10111020
if (con->nodeid == 0) {
@@ -1027,6 +1036,13 @@ static void tcp_connect_to_sock(struct connection *con)
10271036
if (result < 0)
10281037
goto out_err;
10291038

1039+
/* set skb mark */
1040+
result = dlm_comm_mark(con->nodeid, &mark);
1041+
if (result < 0)
1042+
goto out_err;
1043+
1044+
sock_set_mark(sock->sk, mark);
1045+
10301046
memset(&saddr, 0, sizeof(saddr));
10311047
result = nodeid_to_addr(con->nodeid, &saddr, NULL, false);
10321048
if (result < 0) {

0 commit comments

Comments
 (0)