Commit a53aa45b authored by Pavel Emelyanov's avatar Pavel Emelyanov

tcp: Initial image description

Introduce the image file for tcp info, its entry and the show method.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 64c64e4f
......@@ -40,6 +40,7 @@ OBJS += log.o
OBJS += libnetlink.o
OBJS += sockets.o
OBJS += sk-inet.o
OBJS += sk-tcp.o
OBJS += sk-unix.o
OBJS += sk-queue.o
OBJS += files.o
......
......@@ -196,6 +196,12 @@ struct cr_fd_desc_tmpl fdset_template[CR_FD_MAX] = {
.magic = GHOST_FILE_MAGIC,
.show = show_ghost_file,
},
[CR_FD_TCP_STREAM] = {
.fmt = FMT_FNAME_TCP_STREAM,
.magic = TCP_STREAM_MAGIC,
.show = show_tcp_stream,
},
};
static struct cr_fdset *alloc_cr_fdset(int nr)
......
......@@ -45,6 +45,7 @@ enum {
CR_FD_PSTREE,
CR_FD_SHMEM_PAGES,
CR_FD_GHOST_FILE,
CR_FD_TCP_STREAM,
_CR_FD_GLOB_FROM,
CR_FD_SK_QUEUES,
......@@ -129,6 +130,7 @@ extern struct cr_fd_desc_tmpl fdset_template[CR_FD_MAX];
#define FMT_FNAME_FS "fs-%d.img"
#define FMT_FNAME_REMAP_FPATH "remap-fpath.img"
#define FMT_FNAME_GHOST_FILE "ghost-file-%x.img"
#define FMT_FNAME_TCP_STREAM "tcp-stream-%x.img"
extern int open_image_dir(void);
extern void close_image_dir(void);
......
......@@ -32,6 +32,7 @@
#define MM_MAGIC 0x57492820 /* Pskov */
#define REMAP_FPATH_MAGIC 0x59133954 /* Vologda */
#define GHOST_FILE_MAGIC 0x52583605 /* Oryol */
#define TCP_STREAM_MAGIC 0x51465506 /* Orenburg */
#define PIPEFS_MAGIC 0x50495045
......@@ -155,6 +156,17 @@ struct inet_sk_entry {
u32 dst_addr[4];
} __packed;
struct tcp_stream_entry {
u32 inq_len;
u32 inq_seq;
u32 outq_len;
u32 outq_seq;
u8 opt_mask; /* TCPI_OPT_ bits */
u8 snd_wscale;
u16 mss_clamp;
} __packed;
struct sk_packet_entry {
u32 id_for;
u32 length;
......
......@@ -35,4 +35,7 @@ static inline int restore_one_tcp(int sk, struct inet_sk_info *si)
}
#define SK_EST_PARAM "tcp-established"
struct cr_options;
void show_tcp_stream(int fd, struct cr_options *);
#endif
#include <netinet/tcp.h>
#include "types.h"
#include "sockets.h"
#include "files.h"
#include "sk-inet.h"
void show_tcp_stream(int fd, struct cr_options *opt)
{
struct tcp_stream_entry tse;
pr_img_head(CR_FD_TCP_STREAM);
if (read_img(fd, &tse) > 0) {
pr_msg("IN: seq %10u len %10u\n", tse.inq_seq, tse.inq_len);
pr_msg("OUT: seq %10u len %10u\n", tse.outq_seq, tse.outq_len);
pr_msg("OPTS: %#x\n", (int)tse.opt_mask);
pr_msg("\tmss_clamp %u\n", (int)tse.mss_clamp);
if (tse.opt_mask & TCPI_OPT_WSCALE)
pr_msg("\twscale %u\n", (int)tse.snd_wscale);
if (tse.opt_mask & TCPI_OPT_TIMESTAMPS)
pr_msg("\ttimestamps\n");
if (tse.opt_mask & TCPI_OPT_SACK)
pr_msg("\tsack\n");
}
pr_img_tail(CR_FD_TCP_STREAM);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment