summaryrefslogtreecommitdiffstats
path: root/net/tipc/socket.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/socket.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/socket.c')
-rw-r--r--net/tipc/socket.c90
1 files changed, 90 insertions, 0 deletions
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index b57b1be7252b..b6b2a94eb54e 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -46,6 +46,7 @@
46#include "bcast.h" 46#include "bcast.h"
47#include "netlink.h" 47#include "netlink.h"
48#include "group.h" 48#include "group.h"
49#include "trace.h"
49 50
50#define CONN_TIMEOUT_DEFAULT 8000 /* default connect timeout = 8s */ 51#define CONN_TIMEOUT_DEFAULT 8000 /* default connect timeout = 8s */
51#define CONN_PROBING_INTV msecs_to_jiffies(3600000) /* [ms] => 1 h */ 52#define CONN_PROBING_INTV msecs_to_jiffies(3600000) /* [ms] => 1 h */
@@ -3564,3 +3565,92 @@ int tipc_nl_publ_dump(struct sk_buff *skb, struct netlink_callback *cb)
3564 3565
3565 return skb->len; 3566 return skb->len;
3566} 3567}
3568
3569u32 tipc_sock_get_portid(struct sock *sk)
3570{
3571 return (sk) ? (tipc_sk(sk))->portid : 0;
3572}
3573
3574/**
3575 * tipc_sk_dump - dump TIPC socket
3576 * @sk: tipc sk to be dumped
3577 * @dqueues: bitmask to decide if any socket queue to be dumped?
3578 * - TIPC_DUMP_NONE: don't dump socket queues
3579 * - TIPC_DUMP_SK_SNDQ: dump socket send queue
3580 * - TIPC_DUMP_SK_RCVQ: dump socket rcv queue
3581 * - TIPC_DUMP_SK_BKLGQ: dump socket backlog queue
3582 * - TIPC_DUMP_ALL: dump all the socket queues above
3583 * @buf: returned buffer of dump data in format
3584 */
3585int tipc_sk_dump(struct sock *sk, u16 dqueues, char *buf)
3586{
3587 int i = 0;
3588 size_t sz = (dqueues) ? SK_LMAX : SK_LMIN;
3589 struct tipc_sock *tsk;
3590 struct publication *p;
3591 bool tsk_connected;
3592
3593 if (!sk) {
3594 i += scnprintf(buf, sz, "sk data: (null)\n");
3595 return i;
3596 }
3597
3598 tsk = tipc_sk(sk);
3599 tsk_connected = !tipc_sk_type_connectionless(sk);
3600
3601 i += scnprintf(buf, sz, "sk data: %u", sk->sk_type);
3602 i += scnprintf(buf + i, sz - i, " %d", sk->sk_state);
3603 i += scnprintf(buf + i, sz - i, " %x", tsk_own_node(tsk));
3604 i += scnprintf(buf + i, sz - i, " %u", tsk->portid);
3605 i += scnprintf(buf + i, sz - i, " | %u", tsk_connected);
3606 if (tsk_connected) {
3607 i += scnprintf(buf + i, sz - i, " %x", tsk_peer_node(tsk));
3608 i += scnprintf(buf + i, sz - i, " %u", tsk_peer_port(tsk));
3609 i += scnprintf(buf + i, sz - i, " %u", tsk->conn_type);
3610 i += scnprintf(buf + i, sz - i, " %u", tsk->conn_instance);
3611 }
3612 i += scnprintf(buf + i, sz - i, " | %u", tsk->published);
3613 if (tsk->published) {
3614 p = list_first_entry_or_null(&tsk->publications,
3615 struct publication, binding_sock);
3616 i += scnprintf(buf + i, sz - i, " %u", (p) ? p->type : 0);
3617 i += scnprintf(buf + i, sz - i, " %u", (p) ? p->lower : 0);
3618 i += scnprintf(buf + i, sz - i, " %u", (p) ? p->upper : 0);
3619 }
3620 i += scnprintf(buf + i, sz - i, " | %u", tsk->snd_win);
3621 i += scnprintf(buf + i, sz - i, " %u", tsk->rcv_win);
3622 i += scnprintf(buf + i, sz - i, " %u", tsk->max_pkt);
3623 i += scnprintf(buf + i, sz - i, " %x", tsk->peer_caps);
3624 i += scnprintf(buf + i, sz - i, " %u", tsk->cong_link_cnt);
3625 i += scnprintf(buf + i, sz - i, " %u", tsk->snt_unacked);
3626 i += scnprintf(buf + i, sz - i, " %u", tsk->rcv_unacked);
3627 i += scnprintf(buf + i, sz - i, " %u", atomic_read(&tsk->dupl_rcvcnt));
3628 i += scnprintf(buf + i, sz - i, " %u", sk->sk_shutdown);
3629 i += scnprintf(buf + i, sz - i, " | %d", sk_wmem_alloc_get(sk));
3630 i += scnprintf(buf + i, sz - i, " %d", sk->sk_sndbuf);
3631 i += scnprintf(buf + i, sz - i, " | %d", sk_rmem_alloc_get(sk));
3632 i += scnprintf(buf + i, sz - i, " %d", sk->sk_rcvbuf);
3633 i += scnprintf(buf + i, sz - i, " | %d\n", sk->sk_backlog.len);
3634
3635 if (dqueues & TIPC_DUMP_SK_SNDQ) {
3636 i += scnprintf(buf + i, sz - i, "sk_write_queue: ");
3637 i += tipc_list_dump(&sk->sk_write_queue, false, buf + i);
3638 }
3639
3640 if (dqueues & TIPC_DUMP_SK_RCVQ) {
3641 i += scnprintf(buf + i, sz - i, "sk_receive_queue: ");
3642 i += tipc_list_dump(&sk->sk_receive_queue, false, buf + i);
3643 }
3644
3645 if (dqueues & TIPC_DUMP_SK_BKLGQ) {
3646 i += scnprintf(buf + i, sz - i, "sk_backlog:\n head ");
3647 i += tipc_skb_dump(sk->sk_backlog.head, false, buf + i);
3648 if (sk->sk_backlog.tail != sk->sk_backlog.head) {
3649 i += scnprintf(buf + i, sz - i, " tail ");
3650 i += tipc_skb_dump(sk->sk_backlog.tail, false,
3651 buf + i);
3652 }
3653 }
3654
3655 return i;
3656}