@@ -73,7 +73,7 @@ const struct rhashtable_params dlm_rhash_rsb_params = {
73
73
74
74
struct dlm_cluster {
75
75
struct config_group group ;
76
- unsigned int cl_tcp_port ;
76
+ __be16 cl_tcp_port ;
77
77
unsigned int cl_buffer_size ;
78
78
unsigned int cl_rsbtbl_size ;
79
79
unsigned int cl_recover_timer ;
@@ -132,6 +132,45 @@ static ssize_t cluster_cluster_name_store(struct config_item *item,
132
132
133
133
CONFIGFS_ATTR (cluster_ , cluster_name );
134
134
135
+ static ssize_t cluster_tcp_port_show (struct config_item * item , char * buf )
136
+ {
137
+ return sprintf (buf , "%u\n" , be16_to_cpu (dlm_config .ci_tcp_port ));
138
+ }
139
+
140
+ static int dlm_check_zero_and_dlm_running (unsigned int x )
141
+ {
142
+ if (!x )
143
+ return - EINVAL ;
144
+
145
+ if (dlm_lowcomms_is_running ())
146
+ return - EBUSY ;
147
+
148
+ return 0 ;
149
+ }
150
+
151
+ static ssize_t cluster_tcp_port_store (struct config_item * item ,
152
+ const char * buf , size_t len )
153
+ {
154
+ int rc ;
155
+ u16 x ;
156
+
157
+ if (!capable (CAP_SYS_ADMIN ))
158
+ return - EPERM ;
159
+
160
+ rc = kstrtou16 (buf , 0 , & x );
161
+ if (rc )
162
+ return rc ;
163
+
164
+ rc = dlm_check_zero_and_dlm_running (x );
165
+ if (rc )
166
+ return rc ;
167
+
168
+ dlm_config .ci_tcp_port = cpu_to_be16 (x );
169
+ return len ;
170
+ }
171
+
172
+ CONFIGFS_ATTR (cluster_ , tcp_port );
173
+
135
174
static ssize_t cluster_set (struct dlm_cluster * cl , unsigned int * cl_field ,
136
175
int * info_field , int (* check_cb )(unsigned int x ),
137
176
const char * buf , size_t len )
@@ -191,17 +230,6 @@ static int dlm_check_protocol_and_dlm_running(unsigned int x)
191
230
return 0 ;
192
231
}
193
232
194
- static int dlm_check_zero_and_dlm_running (unsigned int x )
195
- {
196
- if (!x )
197
- return - EINVAL ;
198
-
199
- if (dlm_lowcomms_is_running ())
200
- return - EBUSY ;
201
-
202
- return 0 ;
203
- }
204
-
205
233
static int dlm_check_zero (unsigned int x )
206
234
{
207
235
if (!x )
@@ -218,7 +246,6 @@ static int dlm_check_buffer_size(unsigned int x)
218
246
return 0 ;
219
247
}
220
248
221
- CLUSTER_ATTR (tcp_port , dlm_check_zero_and_dlm_running );
222
249
CLUSTER_ATTR (buffer_size , dlm_check_buffer_size );
223
250
CLUSTER_ATTR (rsbtbl_size , dlm_check_zero );
224
251
CLUSTER_ATTR (recover_timer , dlm_check_zero );
@@ -982,7 +1009,7 @@ int dlm_our_addr(struct sockaddr_storage *addr, int num)
982
1009
#define DEFAULT_CLUSTER_NAME ""
983
1010
984
1011
struct dlm_config_info dlm_config = {
985
- .ci_tcp_port = DEFAULT_TCP_PORT ,
1012
+ .ci_tcp_port = cpu_to_be16 ( DEFAULT_TCP_PORT ) ,
986
1013
.ci_buffer_size = DLM_MAX_SOCKET_BUFSIZE ,
987
1014
.ci_rsbtbl_size = DEFAULT_RSBTBL_SIZE ,
988
1015
.ci_recover_timer = DEFAULT_RECOVER_TIMER ,
0 commit comments