aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/node.c
diff options
context:
space:
mode:
authorTuong Lien <tuong.t.lien@dektech.com.au>2018-12-18 21:17:56 -0500
committerDavid S. Miller <davem@davemloft.net>2018-12-19 14:49:24 -0500
commitb4b9771bcbbd5839b0f77aba55e2f85989ed6779 (patch)
tree4ff4e950e174540191a45b5b2cbfc5ef649f6baa /net/tipc/node.c
parent4a54877ee767fe70a6966352c788fc5f405aa3c6 (diff)
tipc: enable tracepoints in tipc
As for the sake of debugging/tracing, the commit enables tracepoints in TIPC along with some general trace_events as shown below. It also defines some 'tipc_*_dump()' functions that allow to dump TIPC object data whenever needed, that is, for general debug purposes, ie. not just for the trace_events. The following trace_events are now available: - trace_tipc_skb_dump(): allows to trace and dump TIPC msg & skb data, e.g. message type, user, droppable, skb truesize, cloned skb, etc. - trace_tipc_list_dump(): allows to trace and dump any TIPC buffers or queues, e.g. TIPC link transmq, socket receive queue, etc. - trace_tipc_sk_dump(): allows to trace and dump TIPC socket data, e.g. sk state, sk type, connection type, rmem_alloc, socket queues, etc. - trace_tipc_link_dump(): allows to trace and dump TIPC link data, e.g. link state, silent_intv_cnt, gap, bc_gap, link queues, etc. - trace_tipc_node_dump(): allows to trace and dump TIPC node data, e.g. node state, active links, capabilities, link entries, etc. How to use: Put the trace functions at any places where we want to dump TIPC data or events. Note: a) The dump functions will generate raw data only, that is, to offload the trace event's processing, it can require a tool or script to parse the data but this should be simple. b) The trace_tipc_*_dump() should be reserved for a failure cases only (e.g. the retransmission failure case) or where we do not expect to happen too often, then we can consider enabling these events by default since they will almost not take any effects under normal conditions, but once the rare condition or failure occurs, we get the dumped data fully for post-analysis. For other trace purposes, we can reuse these trace classes as template but different events. c) A trace_event is only effective when we enable it. To enable the TIPC trace_events, echo 1 to 'enable' files in the events/tipc/ directory in the 'debugfs' file system. Normally, they are located at: /sys/kernel/debug/tracing/events/tipc/ For example: To enable the tipc_link_dump event: echo 1 > /sys/kernel/debug/tracing/events/tipc/tipc_link_dump/enable To enable all the TIPC trace_events: echo 1 > /sys/kernel/debug/tracing/events/tipc/enable To collect the trace data: cat trace or cat trace_pipe > /trace.out & To disable all the TIPC trace_events: echo 0 > /sys/kernel/debug/tracing/events/tipc/enable To clear the trace buffer: echo > trace d) Like the other trace_events, the feature like 'filter' or 'trigger' is also usable for the tipc trace_events. For more details, have a look at: Documentation/trace/ftrace.txt MAINTAINERS | add two new files 'trace.h' & 'trace.c' in tipc Acked-by: Ying Xue <ying.xue@windriver.com> Tested-by: Ying Xue <ying.xue@windriver.com> Acked-by: Jon Maloy <jon.maloy@ericsson.com> Signed-off-by: Tuong Lien <tuong.t.lien@dektech.com.au> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/node.c')
-rw-r--r--net/tipc/node.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/net/tipc/node.c b/net/tipc/node.c
index 5980abb7839b..4fd6e2887818 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -43,6 +43,7 @@
43#include "monitor.h" 43#include "monitor.h"
44#include "discover.h" 44#include "discover.h"
45#include "netlink.h" 45#include "netlink.h"
46#include "trace.h"
46 47
47#define INVALID_NODE_SIG 0x10000 48#define INVALID_NODE_SIG 0x10000
48#define NODE_CLEANUP_AFTER 300000 49#define NODE_CLEANUP_AFTER 300000
@@ -2435,3 +2436,65 @@ int tipc_nl_node_dump_monitor_peer(struct sk_buff *skb,
2435 2436
2436 return skb->len; 2437 return skb->len;
2437} 2438}
2439
2440u32 tipc_node_get_addr(struct tipc_node *node)
2441{
2442 return (node) ? node->addr : 0;
2443}
2444
2445/**
2446 * tipc_node_dump - dump TIPC node data
2447 * @n: tipc node to be dumped
2448 * @more: dump more?
2449 * - false: dump only tipc node data
2450 * - true: dump node link data as well
2451 * @buf: returned buffer of dump data in format
2452 */
2453int tipc_node_dump(struct tipc_node *n, bool more, char *buf)
2454{
2455 int i = 0;
2456 size_t sz = (more) ? NODE_LMAX : NODE_LMIN;
2457
2458 if (!n) {
2459 i += scnprintf(buf, sz, "node data: (null)\n");
2460 return i;
2461 }
2462
2463 i += scnprintf(buf, sz, "node data: %x", n->addr);
2464 i += scnprintf(buf + i, sz - i, " %x", n->state);
2465 i += scnprintf(buf + i, sz - i, " %d", n->active_links[0]);
2466 i += scnprintf(buf + i, sz - i, " %d", n->active_links[1]);
2467 i += scnprintf(buf + i, sz - i, " %x", n->action_flags);
2468 i += scnprintf(buf + i, sz - i, " %u", n->failover_sent);
2469 i += scnprintf(buf + i, sz - i, " %u", n->sync_point);
2470 i += scnprintf(buf + i, sz - i, " %d", n->link_cnt);
2471 i += scnprintf(buf + i, sz - i, " %u", n->working_links);
2472 i += scnprintf(buf + i, sz - i, " %x", n->capabilities);
2473 i += scnprintf(buf + i, sz - i, " %lu\n", n->keepalive_intv);
2474
2475 if (!more)
2476 return i;
2477
2478 i += scnprintf(buf + i, sz - i, "link_entry[0]:\n");
2479 i += scnprintf(buf + i, sz - i, " mtu: %u\n", n->links[0].mtu);
2480 i += scnprintf(buf + i, sz - i, " media: ");
2481 i += tipc_media_addr_printf(buf + i, sz - i, &n->links[0].maddr);
2482 i += scnprintf(buf + i, sz - i, "\n");
2483 i += tipc_link_dump(n->links[0].link, TIPC_DUMP_NONE, buf + i);
2484 i += scnprintf(buf + i, sz - i, " inputq: ");
2485 i += tipc_list_dump(&n->links[0].inputq, false, buf + i);
2486
2487 i += scnprintf(buf + i, sz - i, "link_entry[1]:\n");
2488 i += scnprintf(buf + i, sz - i, " mtu: %u\n", n->links[1].mtu);
2489 i += scnprintf(buf + i, sz - i, " media: ");
2490 i += tipc_media_addr_printf(buf + i, sz - i, &n->links[1].maddr);
2491 i += scnprintf(buf + i, sz - i, "\n");
2492 i += tipc_link_dump(n->links[1].link, TIPC_DUMP_NONE, buf + i);
2493 i += scnprintf(buf + i, sz - i, " inputq: ");
2494 i += tipc_list_dump(&n->links[1].inputq, false, buf + i);
2495
2496 i += scnprintf(buf + i, sz - i, "bclink:\n ");
2497 i += tipc_link_dump(n->bc_entry.link, TIPC_DUMP_NONE, buf + i);
2498
2499 return i;
2500}