diff options
Diffstat (limited to 'net/tipc/config.c')
-rw-r--r-- | net/tipc/config.c | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/net/tipc/config.c b/net/tipc/config.c index c5712a343810..a056a3852f71 100644 --- a/net/tipc/config.c +++ b/net/tipc/config.c | |||
@@ -39,6 +39,8 @@ | |||
39 | #include "name_table.h" | 39 | #include "name_table.h" |
40 | #include "config.h" | 40 | #include "config.h" |
41 | 41 | ||
42 | #define REPLY_TRUNCATED "<truncated>\n" | ||
43 | |||
42 | static u32 config_port_ref; | 44 | static u32 config_port_ref; |
43 | 45 | ||
44 | static DEFINE_SPINLOCK(config_lock); | 46 | static DEFINE_SPINLOCK(config_lock); |
@@ -104,13 +106,12 @@ struct sk_buff *tipc_cfg_reply_string_type(u16 tlv_type, char *string) | |||
104 | return buf; | 106 | return buf; |
105 | } | 107 | } |
106 | 108 | ||
107 | #define MAX_STATS_INFO 2000 | ||
108 | |||
109 | static struct sk_buff *tipc_show_stats(void) | 109 | static struct sk_buff *tipc_show_stats(void) |
110 | { | 110 | { |
111 | struct sk_buff *buf; | 111 | struct sk_buff *buf; |
112 | struct tlv_desc *rep_tlv; | 112 | struct tlv_desc *rep_tlv; |
113 | struct print_buf pb; | 113 | char *pb; |
114 | int pb_len; | ||
114 | int str_len; | 115 | int str_len; |
115 | u32 value; | 116 | u32 value; |
116 | 117 | ||
@@ -121,17 +122,16 @@ static struct sk_buff *tipc_show_stats(void) | |||
121 | if (value != 0) | 122 | if (value != 0) |
122 | return tipc_cfg_reply_error_string("unsupported argument"); | 123 | return tipc_cfg_reply_error_string("unsupported argument"); |
123 | 124 | ||
124 | buf = tipc_cfg_reply_alloc(TLV_SPACE(MAX_STATS_INFO)); | 125 | buf = tipc_cfg_reply_alloc(TLV_SPACE(ULTRA_STRING_MAX_LEN)); |
125 | if (buf == NULL) | 126 | if (buf == NULL) |
126 | return NULL; | 127 | return NULL; |
127 | 128 | ||
128 | rep_tlv = (struct tlv_desc *)buf->data; | 129 | rep_tlv = (struct tlv_desc *)buf->data; |
129 | tipc_printbuf_init(&pb, (char *)TLV_DATA(rep_tlv), MAX_STATS_INFO); | 130 | pb = TLV_DATA(rep_tlv); |
130 | 131 | pb_len = ULTRA_STRING_MAX_LEN; | |
131 | tipc_printf(&pb, "TIPC version " TIPC_MOD_VER "\n"); | ||
132 | 132 | ||
133 | /* Use additional tipc_printf()'s to return more info ... */ | 133 | str_len = tipc_snprintf(pb, pb_len, "TIPC version " TIPC_MOD_VER "\n"); |
134 | str_len = tipc_printbuf_validate(&pb); | 134 | str_len += 1; /* for "\0" */ |
135 | skb_put(buf, TLV_SPACE(str_len)); | 135 | skb_put(buf, TLV_SPACE(str_len)); |
136 | TLV_SET(rep_tlv, TIPC_TLV_ULTRA_STRING, NULL, str_len); | 136 | TLV_SET(rep_tlv, TIPC_TLV_ULTRA_STRING, NULL, str_len); |
137 | 137 | ||
@@ -334,12 +334,6 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area | |||
334 | case TIPC_CMD_SHOW_PORTS: | 334 | case TIPC_CMD_SHOW_PORTS: |
335 | rep_tlv_buf = tipc_port_get_ports(); | 335 | rep_tlv_buf = tipc_port_get_ports(); |
336 | break; | 336 | break; |
337 | case TIPC_CMD_SET_LOG_SIZE: | ||
338 | rep_tlv_buf = tipc_log_resize_cmd(req_tlv_area, req_tlv_space); | ||
339 | break; | ||
340 | case TIPC_CMD_DUMP_LOG: | ||
341 | rep_tlv_buf = tipc_log_dump(); | ||
342 | break; | ||
343 | case TIPC_CMD_SHOW_STATS: | 337 | case TIPC_CMD_SHOW_STATS: |
344 | rep_tlv_buf = tipc_show_stats(); | 338 | rep_tlv_buf = tipc_show_stats(); |
345 | break; | 339 | break; |
@@ -399,6 +393,8 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area | |||
399 | case TIPC_CMD_GET_MAX_CLUSTERS: | 393 | case TIPC_CMD_GET_MAX_CLUSTERS: |
400 | case TIPC_CMD_SET_MAX_NODES: | 394 | case TIPC_CMD_SET_MAX_NODES: |
401 | case TIPC_CMD_GET_MAX_NODES: | 395 | case TIPC_CMD_GET_MAX_NODES: |
396 | case TIPC_CMD_SET_LOG_SIZE: | ||
397 | case TIPC_CMD_DUMP_LOG: | ||
402 | rep_tlv_buf = tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED | 398 | rep_tlv_buf = tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED |
403 | " (obsolete command)"); | 399 | " (obsolete command)"); |
404 | break; | 400 | break; |
@@ -408,6 +404,15 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area | |||
408 | break; | 404 | break; |
409 | } | 405 | } |
410 | 406 | ||
407 | WARN_ON(rep_tlv_buf->len > TLV_SPACE(ULTRA_STRING_MAX_LEN)); | ||
408 | |||
409 | /* Append an error message if we cannot return all requested data */ | ||
410 | if (rep_tlv_buf->len == TLV_SPACE(ULTRA_STRING_MAX_LEN)) { | ||
411 | if (*(rep_tlv_buf->data + ULTRA_STRING_MAX_LEN) != '\0') | ||
412 | sprintf(rep_tlv_buf->data + rep_tlv_buf->len - | ||
413 | sizeof(REPLY_TRUNCATED) - 1, REPLY_TRUNCATED); | ||
414 | } | ||
415 | |||
411 | /* Return reply buffer */ | 416 | /* Return reply buffer */ |
412 | exit: | 417 | exit: |
413 | spin_unlock_bh(&config_lock); | 418 | spin_unlock_bh(&config_lock); |
@@ -432,7 +437,7 @@ static void cfg_named_msg_event(void *userdata, | |||
432 | if ((size < sizeof(*req_hdr)) || | 437 | if ((size < sizeof(*req_hdr)) || |
433 | (size != TCM_ALIGN(ntohl(req_hdr->tcm_len))) || | 438 | (size != TCM_ALIGN(ntohl(req_hdr->tcm_len))) || |
434 | (ntohs(req_hdr->tcm_flags) != TCM_F_REQUEST)) { | 439 | (ntohs(req_hdr->tcm_flags) != TCM_F_REQUEST)) { |
435 | warn("Invalid configuration message discarded\n"); | 440 | pr_warn("Invalid configuration message discarded\n"); |
436 | return; | 441 | return; |
437 | } | 442 | } |
438 | 443 | ||
@@ -478,7 +483,7 @@ int tipc_cfg_init(void) | |||
478 | return 0; | 483 | return 0; |
479 | 484 | ||
480 | failed: | 485 | failed: |
481 | err("Unable to create configuration service\n"); | 486 | pr_err("Unable to create configuration service\n"); |
482 | return res; | 487 | return res; |
483 | } | 488 | } |
484 | 489 | ||
@@ -494,7 +499,7 @@ void tipc_cfg_reinit(void) | |||
494 | seq.lower = seq.upper = tipc_own_addr; | 499 | seq.lower = seq.upper = tipc_own_addr; |
495 | res = tipc_publish(config_port_ref, TIPC_ZONE_SCOPE, &seq); | 500 | res = tipc_publish(config_port_ref, TIPC_ZONE_SCOPE, &seq); |
496 | if (res) | 501 | if (res) |
497 | err("Unable to reinitialize configuration service\n"); | 502 | pr_err("Unable to reinitialize configuration service\n"); |
498 | } | 503 | } |
499 | 504 | ||
500 | void tipc_cfg_stop(void) | 505 | void tipc_cfg_stop(void) |