summaryrefslogtreecommitdiffstats
path: root/net/tipc/config.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/tipc/config.c')
-rw-r--r--net/tipc/config.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/net/tipc/config.c b/net/tipc/config.c
index 7978fdd99299..96cfbf834a10 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
42static u32 config_port_ref; 44static u32 config_port_ref;
43 45
44static DEFINE_SPINLOCK(config_lock); 46static 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
109static struct sk_buff *tipc_show_stats(void) 109static 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
@@ -408,6 +408,15 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area
408 break; 408 break;
409 } 409 }
410 410
411 WARN_ON(rep_tlv_buf->len > TLV_SPACE(ULTRA_STRING_MAX_LEN));
412
413 /* Append an error message if we cannot return all requested data */
414 if (rep_tlv_buf->len == TLV_SPACE(ULTRA_STRING_MAX_LEN)) {
415 if (*(rep_tlv_buf->data + ULTRA_STRING_MAX_LEN) != '\0')
416 sprintf(rep_tlv_buf->data + rep_tlv_buf->len -
417 sizeof(REPLY_TRUNCATED) - 1, REPLY_TRUNCATED);
418 }
419
411 /* Return reply buffer */ 420 /* Return reply buffer */
412exit: 421exit:
413 spin_unlock_bh(&config_lock); 422 spin_unlock_bh(&config_lock);