aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/config.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/tipc/config.c')
-rw-r--r--net/tipc/config.c118
1 files changed, 18 insertions, 100 deletions
diff --git a/net/tipc/config.c b/net/tipc/config.c
index 50a6133a3668..e16750dcf3c1 100644
--- a/net/tipc/config.c
+++ b/net/tipc/config.c
@@ -35,30 +35,11 @@
35 */ 35 */
36 36
37#include "core.h" 37#include "core.h"
38#include "dbg.h"
39#include "bearer.h"
40#include "port.h" 38#include "port.h"
41#include "link.h"
42#include "zone.h"
43#include "addr.h"
44#include "name_table.h" 39#include "name_table.h"
45#include "node.h"
46#include "config.h" 40#include "config.h"
47#include "discover.h"
48 41
49struct subscr_data { 42static u32 config_port_ref;
50 char usr_handle[8];
51 u32 domain;
52 u32 port_ref;
53 struct list_head subd_list;
54};
55
56struct manager {
57 u32 user_ref;
58 u32 port_ref;
59};
60
61static struct manager mng = { 0};
62 43
63static DEFINE_SPINLOCK(config_lock); 44static DEFINE_SPINLOCK(config_lock);
64 45
@@ -83,10 +64,8 @@ int tipc_cfg_append_tlv(struct sk_buff *buf, int tlv_type,
83 struct tlv_desc *tlv = (struct tlv_desc *)skb_tail_pointer(buf); 64 struct tlv_desc *tlv = (struct tlv_desc *)skb_tail_pointer(buf);
84 int new_tlv_space = TLV_SPACE(tlv_data_size); 65 int new_tlv_space = TLV_SPACE(tlv_data_size);
85 66
86 if (skb_tailroom(buf) < new_tlv_space) { 67 if (skb_tailroom(buf) < new_tlv_space)
87 dbg("tipc_cfg_append_tlv unable to append TLV\n");
88 return 0; 68 return 0;
89 }
90 skb_put(buf, new_tlv_space); 69 skb_put(buf, new_tlv_space);
91 tlv->tlv_type = htons(tlv_type); 70 tlv->tlv_type = htons(tlv_type);
92 tlv->tlv_len = htons(TLV_LENGTH(tlv_data_size)); 71 tlv->tlv_len = htons(TLV_LENGTH(tlv_data_size));
@@ -281,38 +260,6 @@ static struct sk_buff *cfg_set_max_ports(void)
281 return tipc_cfg_reply_none(); 260 return tipc_cfg_reply_none();
282} 261}
283 262
284static struct sk_buff *cfg_set_max_zones(void)
285{
286 u32 value;
287
288 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED))
289 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
290 value = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
291 if (value == tipc_max_zones)
292 return tipc_cfg_reply_none();
293 if (value != delimit(value, 1, 255))
294 return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
295 " (max zones must be 1-255)");
296 if (tipc_mode == TIPC_NET_MODE)
297 return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
298 " (cannot change max zones once TIPC has joined a network)");
299 tipc_max_zones = value;
300 return tipc_cfg_reply_none();
301}
302
303static struct sk_buff *cfg_set_max_clusters(void)
304{
305 u32 value;
306
307 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED))
308 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
309 value = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
310 if (value != delimit(value, 1, 1))
311 return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
312 " (max clusters fixed at 1)");
313 return tipc_cfg_reply_none();
314}
315
316static struct sk_buff *cfg_set_max_nodes(void) 263static struct sk_buff *cfg_set_max_nodes(void)
317{ 264{
318 u32 value; 265 u32 value;
@@ -332,19 +279,6 @@ static struct sk_buff *cfg_set_max_nodes(void)
332 return tipc_cfg_reply_none(); 279 return tipc_cfg_reply_none();
333} 280}
334 281
335static struct sk_buff *cfg_set_max_slaves(void)
336{
337 u32 value;
338
339 if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED))
340 return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
341 value = ntohl(*(__be32 *)TLV_DATA(req_tlv_area));
342 if (value != 0)
343 return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
344 " (max secondary nodes fixed at 0)");
345 return tipc_cfg_reply_none();
346}
347
348static struct sk_buff *cfg_set_netid(void) 282static struct sk_buff *cfg_set_netid(void)
349{ 283{
350 u32 value; 284 u32 value;
@@ -388,8 +322,7 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area
388 } else if (!tipc_remote_management) { 322 } else if (!tipc_remote_management) {
389 rep_tlv_buf = tipc_cfg_reply_error_string(TIPC_CFG_NO_REMOTE); 323 rep_tlv_buf = tipc_cfg_reply_error_string(TIPC_CFG_NO_REMOTE);
390 goto exit; 324 goto exit;
391 } 325 } else if (cmd >= 0x4000) {
392 else if (cmd >= 0x4000) {
393 u32 domain = 0; 326 u32 domain = 0;
394 327
395 if ((tipc_nametbl_translate(TIPC_ZM_SRV, 0, &domain) == 0) || 328 if ((tipc_nametbl_translate(TIPC_ZM_SRV, 0, &domain) == 0) ||
@@ -464,18 +397,9 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area
464 case TIPC_CMD_SET_MAX_SUBSCR: 397 case TIPC_CMD_SET_MAX_SUBSCR:
465 rep_tlv_buf = cfg_set_max_subscriptions(); 398 rep_tlv_buf = cfg_set_max_subscriptions();
466 break; 399 break;
467 case TIPC_CMD_SET_MAX_ZONES:
468 rep_tlv_buf = cfg_set_max_zones();
469 break;
470 case TIPC_CMD_SET_MAX_CLUSTERS:
471 rep_tlv_buf = cfg_set_max_clusters();
472 break;
473 case TIPC_CMD_SET_MAX_NODES: 400 case TIPC_CMD_SET_MAX_NODES:
474 rep_tlv_buf = cfg_set_max_nodes(); 401 rep_tlv_buf = cfg_set_max_nodes();
475 break; 402 break;
476 case TIPC_CMD_SET_MAX_SLAVES:
477 rep_tlv_buf = cfg_set_max_slaves();
478 break;
479 case TIPC_CMD_SET_NETID: 403 case TIPC_CMD_SET_NETID:
480 rep_tlv_buf = cfg_set_netid(); 404 rep_tlv_buf = cfg_set_netid();
481 break; 405 break;
@@ -491,18 +415,9 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area
491 case TIPC_CMD_GET_MAX_SUBSCR: 415 case TIPC_CMD_GET_MAX_SUBSCR:
492 rep_tlv_buf = tipc_cfg_reply_unsigned(tipc_max_subscriptions); 416 rep_tlv_buf = tipc_cfg_reply_unsigned(tipc_max_subscriptions);
493 break; 417 break;
494 case TIPC_CMD_GET_MAX_ZONES:
495 rep_tlv_buf = tipc_cfg_reply_unsigned(tipc_max_zones);
496 break;
497 case TIPC_CMD_GET_MAX_CLUSTERS:
498 rep_tlv_buf = tipc_cfg_reply_unsigned(tipc_max_clusters);
499 break;
500 case TIPC_CMD_GET_MAX_NODES: 418 case TIPC_CMD_GET_MAX_NODES:
501 rep_tlv_buf = tipc_cfg_reply_unsigned(tipc_max_nodes); 419 rep_tlv_buf = tipc_cfg_reply_unsigned(tipc_max_nodes);
502 break; 420 break;
503 case TIPC_CMD_GET_MAX_SLAVES:
504 rep_tlv_buf = tipc_cfg_reply_unsigned(tipc_max_slaves);
505 break;
506 case TIPC_CMD_GET_NETID: 421 case TIPC_CMD_GET_NETID:
507 rep_tlv_buf = tipc_cfg_reply_unsigned(tipc_net_id); 422 rep_tlv_buf = tipc_cfg_reply_unsigned(tipc_net_id);
508 break; 423 break;
@@ -510,6 +425,15 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area
510 rep_tlv_buf = 425 rep_tlv_buf =
511 tipc_cfg_reply_error_string(TIPC_CFG_NOT_NET_ADMIN); 426 tipc_cfg_reply_error_string(TIPC_CFG_NOT_NET_ADMIN);
512 break; 427 break;
428 case TIPC_CMD_SET_MAX_ZONES:
429 case TIPC_CMD_GET_MAX_ZONES:
430 case TIPC_CMD_SET_MAX_SLAVES:
431 case TIPC_CMD_GET_MAX_SLAVES:
432 case TIPC_CMD_SET_MAX_CLUSTERS:
433 case TIPC_CMD_GET_MAX_CLUSTERS:
434 rep_tlv_buf = tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
435 " (obsolete command)");
436 break;
513 default: 437 default:
514 rep_tlv_buf = tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED 438 rep_tlv_buf = tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
515 " (unknown command)"); 439 " (unknown command)");
@@ -572,20 +496,16 @@ int tipc_cfg_init(void)
572 struct tipc_name_seq seq; 496 struct tipc_name_seq seq;
573 int res; 497 int res;
574 498
575 res = tipc_attach(&mng.user_ref, NULL, NULL); 499 res = tipc_createport(NULL, TIPC_CRITICAL_IMPORTANCE,
576 if (res)
577 goto failed;
578
579 res = tipc_createport(mng.user_ref, NULL, TIPC_CRITICAL_IMPORTANCE,
580 NULL, NULL, NULL, 500 NULL, NULL, NULL,
581 NULL, cfg_named_msg_event, NULL, 501 NULL, cfg_named_msg_event, NULL,
582 NULL, &mng.port_ref); 502 NULL, &config_port_ref);
583 if (res) 503 if (res)
584 goto failed; 504 goto failed;
585 505
586 seq.type = TIPC_CFG_SRV; 506 seq.type = TIPC_CFG_SRV;
587 seq.lower = seq.upper = tipc_own_addr; 507 seq.lower = seq.upper = tipc_own_addr;
588 res = tipc_nametbl_publish_rsv(mng.port_ref, TIPC_ZONE_SCOPE, &seq); 508 res = tipc_nametbl_publish_rsv(config_port_ref, TIPC_ZONE_SCOPE, &seq);
589 if (res) 509 if (res)
590 goto failed; 510 goto failed;
591 511
@@ -593,15 +513,13 @@ int tipc_cfg_init(void)
593 513
594failed: 514failed:
595 err("Unable to create configuration service\n"); 515 err("Unable to create configuration service\n");
596 tipc_detach(mng.user_ref);
597 mng.user_ref = 0;
598 return res; 516 return res;
599} 517}
600 518
601void tipc_cfg_stop(void) 519void tipc_cfg_stop(void)
602{ 520{
603 if (mng.user_ref) { 521 if (config_port_ref) {
604 tipc_detach(mng.user_ref); 522 tipc_deleteport(config_port_ref);
605 mng.user_ref = 0; 523 config_port_ref = 0;
606 } 524 }
607} 525}