From 360c1c13b2a13d8a577a72d15c1c77e05fdfc20b Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Thu, 19 Sep 2013 12:16:07 +0400 Subject: [PATCH] tcp: Show tcp queues contents when requested Signed-off-by: Pavel Emelyanov --- cr-show.c | 3 ++- include/cr-show.h | 1 + sk-tcp.c | 12 ++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/cr-show.c b/cr-show.c index 76693a432..342505d50 100644 --- a/cr-show.c +++ b/cr-show.c @@ -23,6 +23,7 @@ #include "uts_ns.h" #include "ipc_ns.h" #include "pstree.h" +#include "cr-show.h" #include "protobuf.h" #include "protobuf/pstree.pb-c.h" @@ -300,7 +301,7 @@ static struct show_image_info show_infos[] = { SHOW_PLAIN(RLIMIT), SHOW_PLAIN(TUNFILE), - { TCP_STREAM_MAGIC, PB_TCP_STREAM, true, NULL, "1:%u 2:%u 3:%u 4:%u", }, + { TCP_STREAM_MAGIC, PB_TCP_STREAM, true, show_tcp_stream, "1:%u 2:%u 3:%u 4:%u", }, { STATS_MAGIC, PB_STATS, true, NULL, "1.1:%u 1.2:%u 1.3:%u 1.4:%u 1.5:%Lu 1.6:%Lu 1.7:%Lu", }, { FDINFO_MAGIC, PB_FDINFO, false, NULL, "flags:%#o fd:%d", }, { UNIXSK_MAGIC, PB_UNIX_SK, false, NULL, "1:%#x 2:%#x 3:%d 4:%d 5:%d 6:%d 7:%d 8:%#x 11:S", }, diff --git a/include/cr-show.h b/include/cr-show.h index efbe9bce6..5a36693f6 100644 --- a/include/cr-show.h +++ b/include/cr-show.h @@ -16,4 +16,5 @@ extern void ipc_shm_handler(int fd, void *obj); extern void ipc_msg_handler(int fd, void *obj); extern void ipc_sem_handler(int fd, void *obj); extern int cr_parse_fd(int fd, u32 magic); +extern void show_tcp_stream(int fd, void *obj); #endif /* __CR_SHOW_H__ */ diff --git a/sk-tcp.c b/sk-tcp.c index bc9cf854e..a0985c761 100644 --- a/sk-tcp.c +++ b/sk-tcp.c @@ -20,6 +20,7 @@ #include "namespaces.h" #include "xmalloc.h" #include "config.h" +#include "cr-show.h" #include "protobuf.h" #include "protobuf/tcp-stream.pb-c.h" @@ -635,3 +636,14 @@ out: return ret; } + +void show_tcp_stream(int fd, void *obj) +{ + TcpStreamEntry *e = obj; + if (opts.show_pages_content) { + pr_msg("In-queue:"); + print_image_data(fd, e->inq_len, 1); + pr_msg("Out-queue:"); + print_image_data(fd, e->outq_len, 1); + } +}