diff options
author | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2011-05-10 14:52:07 -0400 |
---|---|---|
committer | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2011-05-10 16:50:41 -0400 |
commit | 020abf03cd659388f94cb328e1e1df0656e0d7ff (patch) | |
tree | 40d05011708ad1b4a05928d167eb120420581aa6 /net/tipc/config.c | |
parent | 0ff8fbc61727c926883eec381fbd3d32d1fab504 (diff) | |
parent | 693d92a1bbc9e42681c42ed190bd42b636ca876f (diff) |
Merge tag 'v2.6.39-rc7'
in order to pull in changes in drivers/media/dvb/firewire/ and
sound/firewire/.
Diffstat (limited to 'net/tipc/config.c')
-rw-r--r-- | net/tipc/config.c | 149 |
1 files changed, 22 insertions, 127 deletions
diff --git a/net/tipc/config.c b/net/tipc/config.c index 50a6133a3668..b25a396b7e1e 100644 --- a/net/tipc/config.c +++ b/net/tipc/config.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * net/tipc/config.c: TIPC configuration management code | 2 | * net/tipc/config.c: TIPC configuration management code |
3 | * | 3 | * |
4 | * Copyright (c) 2002-2006, Ericsson AB | 4 | * Copyright (c) 2002-2006, Ericsson AB |
5 | * Copyright (c) 2004-2007, Wind River Systems | 5 | * Copyright (c) 2004-2007, 2010-2011, Wind River Systems |
6 | * All rights reserved. | 6 | * All rights reserved. |
7 | * | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without |
@@ -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 | ||
49 | struct subscr_data { | 42 | static u32 config_port_ref; |
50 | char usr_handle[8]; | ||
51 | u32 domain; | ||
52 | u32 port_ref; | ||
53 | struct list_head subd_list; | ||
54 | }; | ||
55 | |||
56 | struct manager { | ||
57 | u32 user_ref; | ||
58 | u32 port_ref; | ||
59 | }; | ||
60 | |||
61 | static struct manager mng = { 0}; | ||
62 | 43 | ||
63 | static DEFINE_SPINLOCK(config_lock); | 44 | static 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)); |
@@ -169,7 +148,7 @@ static struct sk_buff *cfg_enable_bearer(void) | |||
169 | 148 | ||
170 | args = (struct tipc_bearer_config *)TLV_DATA(req_tlv_area); | 149 | args = (struct tipc_bearer_config *)TLV_DATA(req_tlv_area); |
171 | if (tipc_enable_bearer(args->name, | 150 | if (tipc_enable_bearer(args->name, |
172 | ntohl(args->detect_scope), | 151 | ntohl(args->disc_domain), |
173 | ntohl(args->priority))) | 152 | ntohl(args->priority))) |
174 | return tipc_cfg_reply_error_string("unable to enable bearer"); | 153 | return tipc_cfg_reply_error_string("unable to enable bearer"); |
175 | 154 | ||
@@ -281,70 +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 | ||
284 | static 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 | |||
303 | static 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 | |||
316 | static struct sk_buff *cfg_set_max_nodes(void) | ||
317 | { | ||
318 | u32 value; | ||
319 | |||
320 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED)) | ||
321 | return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); | ||
322 | value = ntohl(*(__be32 *)TLV_DATA(req_tlv_area)); | ||
323 | if (value == tipc_max_nodes) | ||
324 | return tipc_cfg_reply_none(); | ||
325 | if (value != delimit(value, 8, 2047)) | ||
326 | return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE | ||
327 | " (max nodes must be 8-2047)"); | ||
328 | if (tipc_mode == TIPC_NET_MODE) | ||
329 | return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED | ||
330 | " (cannot change max nodes once TIPC has joined a network)"); | ||
331 | tipc_max_nodes = value; | ||
332 | return tipc_cfg_reply_none(); | ||
333 | } | ||
334 | |||
335 | static 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 | |||
348 | static struct sk_buff *cfg_set_netid(void) | 263 | static struct sk_buff *cfg_set_netid(void) |
349 | { | 264 | { |
350 | u32 value; | 265 | u32 value; |
@@ -388,8 +303,7 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area | |||
388 | } else if (!tipc_remote_management) { | 303 | } else if (!tipc_remote_management) { |
389 | rep_tlv_buf = tipc_cfg_reply_error_string(TIPC_CFG_NO_REMOTE); | 304 | rep_tlv_buf = tipc_cfg_reply_error_string(TIPC_CFG_NO_REMOTE); |
390 | goto exit; | 305 | goto exit; |
391 | } | 306 | } else if (cmd >= 0x4000) { |
392 | else if (cmd >= 0x4000) { | ||
393 | u32 domain = 0; | 307 | u32 domain = 0; |
394 | 308 | ||
395 | if ((tipc_nametbl_translate(TIPC_ZM_SRV, 0, &domain) == 0) || | 309 | if ((tipc_nametbl_translate(TIPC_ZM_SRV, 0, &domain) == 0) || |
@@ -464,18 +378,6 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area | |||
464 | case TIPC_CMD_SET_MAX_SUBSCR: | 378 | case TIPC_CMD_SET_MAX_SUBSCR: |
465 | rep_tlv_buf = cfg_set_max_subscriptions(); | 379 | rep_tlv_buf = cfg_set_max_subscriptions(); |
466 | break; | 380 | 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: | ||
474 | rep_tlv_buf = cfg_set_max_nodes(); | ||
475 | break; | ||
476 | case TIPC_CMD_SET_MAX_SLAVES: | ||
477 | rep_tlv_buf = cfg_set_max_slaves(); | ||
478 | break; | ||
479 | case TIPC_CMD_SET_NETID: | 381 | case TIPC_CMD_SET_NETID: |
480 | rep_tlv_buf = cfg_set_netid(); | 382 | rep_tlv_buf = cfg_set_netid(); |
481 | break; | 383 | break; |
@@ -491,18 +393,6 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area | |||
491 | case TIPC_CMD_GET_MAX_SUBSCR: | 393 | case TIPC_CMD_GET_MAX_SUBSCR: |
492 | rep_tlv_buf = tipc_cfg_reply_unsigned(tipc_max_subscriptions); | 394 | rep_tlv_buf = tipc_cfg_reply_unsigned(tipc_max_subscriptions); |
493 | break; | 395 | 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: | ||
501 | rep_tlv_buf = tipc_cfg_reply_unsigned(tipc_max_nodes); | ||
502 | 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: | 396 | case TIPC_CMD_GET_NETID: |
507 | rep_tlv_buf = tipc_cfg_reply_unsigned(tipc_net_id); | 397 | rep_tlv_buf = tipc_cfg_reply_unsigned(tipc_net_id); |
508 | break; | 398 | break; |
@@ -510,6 +400,17 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area | |||
510 | rep_tlv_buf = | 400 | rep_tlv_buf = |
511 | tipc_cfg_reply_error_string(TIPC_CFG_NOT_NET_ADMIN); | 401 | tipc_cfg_reply_error_string(TIPC_CFG_NOT_NET_ADMIN); |
512 | break; | 402 | break; |
403 | case TIPC_CMD_SET_MAX_ZONES: | ||
404 | case TIPC_CMD_GET_MAX_ZONES: | ||
405 | case TIPC_CMD_SET_MAX_SLAVES: | ||
406 | case TIPC_CMD_GET_MAX_SLAVES: | ||
407 | case TIPC_CMD_SET_MAX_CLUSTERS: | ||
408 | case TIPC_CMD_GET_MAX_CLUSTERS: | ||
409 | case TIPC_CMD_SET_MAX_NODES: | ||
410 | case TIPC_CMD_GET_MAX_NODES: | ||
411 | rep_tlv_buf = tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED | ||
412 | " (obsolete command)"); | ||
413 | break; | ||
513 | default: | 414 | default: |
514 | rep_tlv_buf = tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED | 415 | rep_tlv_buf = tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED |
515 | " (unknown command)"); | 416 | " (unknown command)"); |
@@ -572,20 +473,16 @@ int tipc_cfg_init(void) | |||
572 | struct tipc_name_seq seq; | 473 | struct tipc_name_seq seq; |
573 | int res; | 474 | int res; |
574 | 475 | ||
575 | res = tipc_attach(&mng.user_ref, NULL, NULL); | 476 | 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, | 477 | NULL, NULL, NULL, |
581 | NULL, cfg_named_msg_event, NULL, | 478 | NULL, cfg_named_msg_event, NULL, |
582 | NULL, &mng.port_ref); | 479 | NULL, &config_port_ref); |
583 | if (res) | 480 | if (res) |
584 | goto failed; | 481 | goto failed; |
585 | 482 | ||
586 | seq.type = TIPC_CFG_SRV; | 483 | seq.type = TIPC_CFG_SRV; |
587 | seq.lower = seq.upper = tipc_own_addr; | 484 | seq.lower = seq.upper = tipc_own_addr; |
588 | res = tipc_nametbl_publish_rsv(mng.port_ref, TIPC_ZONE_SCOPE, &seq); | 485 | res = tipc_nametbl_publish_rsv(config_port_ref, TIPC_ZONE_SCOPE, &seq); |
589 | if (res) | 486 | if (res) |
590 | goto failed; | 487 | goto failed; |
591 | 488 | ||
@@ -593,15 +490,13 @@ int tipc_cfg_init(void) | |||
593 | 490 | ||
594 | failed: | 491 | failed: |
595 | err("Unable to create configuration service\n"); | 492 | err("Unable to create configuration service\n"); |
596 | tipc_detach(mng.user_ref); | ||
597 | mng.user_ref = 0; | ||
598 | return res; | 493 | return res; |
599 | } | 494 | } |
600 | 495 | ||
601 | void tipc_cfg_stop(void) | 496 | void tipc_cfg_stop(void) |
602 | { | 497 | { |
603 | if (mng.user_ref) { | 498 | if (config_port_ref) { |
604 | tipc_detach(mng.user_ref); | 499 | tipc_deleteport(config_port_ref); |
605 | mng.user_ref = 0; | 500 | config_port_ref = 0; |
606 | } | 501 | } |
607 | } | 502 | } |