[CRIU] [PATCH v4 07/12] gc: implement locked tcp connections show
Eugene Batalov
eabatalov89 at gmail.com
Sun Sep 11 10:14:46 PDT 2016
Signed-off-by: Eugene Batalov <eabatalov89 at gmail.com>
---
criu/cr-gc.c | 1 +
criu/sk-tcp.c | 26 ++++++++++++++++++++++++--
2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/criu/cr-gc.c b/criu/cr-gc.c
index afb0f80..74d8d00 100644
--- a/criu/cr-gc.c
+++ b/criu/cr-gc.c
@@ -11,6 +11,7 @@
#include "util.h"
#include "sockets.h"
#include "net.h"
+#include "sk-inet.h"
static int root_mntns = -1;
diff --git a/criu/sk-tcp.c b/criu/sk-tcp.c
index 3b68b7c..456f658 100644
--- a/criu/sk-tcp.c
+++ b/criu/sk-tcp.c
@@ -7,6 +7,7 @@
#include <string.h>
#include <sched.h>
#include <netinet/in.h>
+#include <arpa/inet.h>
#include "cr_options.h"
#include "util.h"
@@ -779,6 +780,23 @@ int restore_one_tcp(int fd, struct inet_sk_info *ii)
return 0;
}
+static int show_tcp_conn(struct inet_sk_info *si)
+{
+ char sip[INET_ADDR_LEN], dip[INET_ADDR_LEN];
+ int family = si->ie->family;
+
+ if (!inet_ntop(family, (void *)si->ie->src_addr, sip, INET_ADDR_LEN) ||
+ !inet_ntop(family, (void *)si->ie->dst_addr, dip, INET_ADDR_LEN)) {
+ pr_perror("nf: Can't translate ip addr");
+ return -1;
+ }
+
+ pr_msg("Locked tcp connection: %s:%d -> %s:%d\n",
+ sip, (int)si->ie->src_port, dip, (int)si->ie->dst_port);
+
+ return 0;
+}
+
void tcp_locked_conn_add(struct inet_sk_info *ii)
{
list_add_tail(&ii->rlist, &rst_tcp_repair_sockets);
@@ -793,9 +811,13 @@ int rst_unlock_tcp_connections(void)
if (root_ns_mask & CLONE_NEWNET)
return 0;
- list_for_each_entry(ii, &rst_tcp_repair_sockets, rlist)
- if (nf_unlock_connection_info(ii))
+ list_for_each_entry(ii, &rst_tcp_repair_sockets, rlist) {
+ if (opts.show) {
+ if (show_tcp_conn(ii))
+ return -1;
+ } else if (nf_unlock_connection_info(ii))
return -1;
+ }
return 0;
}
--
1.9.1
More information about the CRIU
mailing list