Skip to content

Commit 107e7be

Browse files
ajstephensdavem330
authored andcommitted
tipc: Add support for "-s" configuration option
Provide initial support for displaying overall TIPC status/statistics information at runtime. Currently, only version info for the TIPC kernel module is displayed. Signed-off-by: Allan Stephens <allan.stephens@windriver.com> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 3aec9cc commit 107e7be

4 files changed

Lines changed: 43 additions & 3 deletions

File tree

‎include/linux/tipc_config.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
#define TIPC_CMD_SHOW_NAME_TABLE 0x0005 /* tx name_tbl_query, rx ultra_string */
7575
#define TIPC_CMD_SHOW_PORTS 0x0006 /* tx none, rx ultra_string */
7676
#define TIPC_CMD_SHOW_LINK_STATS 0x000B /* tx link_name, rx ultra_string */
77+
#define TIPC_CMD_SHOW_STATS 0x000F /* tx unsigned, rx ultra_string */
7778

7879
#if 0
7980
#define TIPC_CMD_SHOW_PORT_STATS 0x0008 /* tx port_ref, rx ultra_string */

‎net/tipc/config.c‎

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,13 +246,48 @@ static void cfg_cmd_event(struct tipc_cmd_msg *msg,
246246
default:
247247
rv = tipc_cfg_cmd(msg, data, sz, (u32 *)&msg_sect[1].iov_len, orig);
248248
}
249-
exit:
249+
exit:
250250
rmsg.result_len = htonl(msg_sect[1].iov_len);
251251
rmsg.retval = htonl(rv);
252252
tipc_cfg_respond(msg_sect, 2u, orig);
253253
}
254254
#endif
255255

256+
#define MAX_STATS_INFO 2000
257+
258+
static struct sk_buff *tipc_show_stats(void)
259+
{
260+
struct sk_buff *buf;
261+
struct tlv_desc *rep_tlv;
262+
struct print_buf pb;
263+
int str_len;
264+
u32 value;
265+
266+
if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_UNSIGNED))
267+
return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
268+
269+
value = ntohl(*(u32 *)TLV_DATA(req_tlv_area));
270+
if (value != 0)
271+
return tipc_cfg_reply_error_string("unsupported argument");
272+
273+
buf = tipc_cfg_reply_alloc(TLV_SPACE(MAX_STATS_INFO));
274+
if (buf == NULL)
275+
return NULL;
276+
277+
rep_tlv = (struct tlv_desc *)buf->data;
278+
tipc_printbuf_init(&pb, (char *)TLV_DATA(rep_tlv), MAX_STATS_INFO);
279+
280+
tipc_printf(&pb, "TIPC version " TIPC_MOD_VER "\n");
281+
282+
/* Use additional tipc_printf()'s to return more info ... */
283+
284+
str_len = tipc_printbuf_validate(&pb);
285+
skb_put(buf, TLV_SPACE(str_len));
286+
TLV_SET(rep_tlv, TIPC_TLV_ULTRA_STRING, NULL, str_len);
287+
288+
return buf;
289+
}
290+
256291
static struct sk_buff *cfg_enable_bearer(void)
257292
{
258293
struct tipc_bearer_config *args;
@@ -536,6 +571,9 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area
536571
case TIPC_CMD_DUMP_LOG:
537572
rep_tlv_buf = tipc_log_dump();
538573
break;
574+
case TIPC_CMD_SHOW_STATS:
575+
rep_tlv_buf = tipc_show_stats();
576+
break;
539577
case TIPC_CMD_SET_LINK_TOL:
540578
case TIPC_CMD_SET_LINK_PRI:
541579
case TIPC_CMD_SET_LINK_WINDOW:

‎net/tipc/core.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@
4949
#include "config.h"
5050

5151

52-
#define TIPC_MOD_VER "2.0.0"
53-
5452
#ifndef CONFIG_TIPC_ZONES
5553
#define CONFIG_TIPC_ZONES 3
5654
#endif

‎net/tipc/core.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@
5959
#include <linux/slab.h>
6060
#include <linux/vmalloc.h>
6161

62+
63+
#define TIPC_MOD_VER "2.0.0"
64+
6265
/*
6366
* TIPC sanity test macros
6467
*/

0 commit comments

Comments
 (0)