[CRIU] [PATCH 15/15] inet: More readable content in show methods

Cyrill Gorcunov gorcunov at gmail.com
Thu Sep 13 22:57:58 MSK 2018


This generates more readable data in logs.

 | (00.002930) inet:       Collected: ino 0xc3f15b family AF_INET    type SOCK_DGRAM     port     8081 state TCP_CLOSE       src_addr 127.0.0.10
 | (00.002980) inet:       Collected: ino 0xc3f159 family AF_INET    type SOCK_RAW       port        1 state TCP_CLOSE       src_addr 127.0.0.14
 | (00.002984) inet:       Collected: ino 0xc3f158 family AF_INET    type SOCK_RAW       port       17 state TCP_CLOSE       src_addr 127.0.0.12
 | (00.002988) inet:       Collected: ino 0xc3f156 family AF_INET    type SOCK_RAW       port      255 state TCP_CLOSE       src_addr 0.0.0.0
 | (00.003439) inet:       Collected: ino 0xc3f15a family AF_INET6   type SOCK_RAW       port       58 state TCP_CLOSE       src_addr ::
 | (00.003449) inet:       Collected: ino 0xc3f157 family AF_INET6   type SOCK_RAW       port      255 state TCP_CLOSE       src_addr ::

Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
---
 criu/sk-inet.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/criu/sk-inet.c b/criu/sk-inet.c
index d9fb06b1eab7..813492220455 100644
--- a/criu/sk-inet.c
+++ b/criu/sk-inet.c
@@ -86,10 +86,11 @@ static void show_one_inet(const char *act, const struct inet_sk_desc *sk)
 		pr_perror("Failed to translate address");
 	}
 
-	pr_debug("\t%s: ino %#8x family %4d type %4d port %8d "
-		"state %2d src_addr %s\n",
-		act, sk->sd.ino, sk->sd.family, sk->type, sk->src_port,
-		sk->state, src_addr);
+	pr_debug("\t%s: ino %#8x family %-10s type %-14s port %8d "
+		"state %-16s src_addr %s\n", act, sk->sd.ino,
+		___socket_family_name(sk->sd.family),
+		___socket_type_name(sk->type), sk->src_port,
+		___tcp_state_name(sk->state), src_addr);
 }
 
 static void show_one_inet_img(const char *act, const InetSkEntry *e)
@@ -101,10 +102,13 @@ static void show_one_inet_img(const char *act, const InetSkEntry *e)
 		pr_perror("Failed to translate address");
 	}
 
-	pr_debug("\t%s: family %d type %d proto %d port %d "
-		"state %d src_addr %s\n",
-		act, e->family, e->type, e->proto, e->src_port,
-		e->state, src_addr);
+	pr_debug("\t%s: family %-10s type %-14s proto %-16s port %d "
+		"state %-16s src_addr %s\n", act,
+		___socket_family_name(e->family),
+		___socket_type_name(e->type),
+		___socket_proto_name(e->proto),
+		e->src_port, ___tcp_state_name(e->state),
+		src_addr);
 }
 
 static int can_dump_ipproto(int ino, int proto, int type)
-- 
2.17.1



More information about the CRIU mailing list