[CRIU] [PATCH 05/12] unix: Dump DGRAM packets and sockets senders

Kirill Tkhai ktkhai at virtuozzo.com
Fri Apr 29 07:36:18 PDT 2016


Add a method to get a DGRAM packet sender. This allows dump_sk_queue()
to dump its inode. If there is the only sender for whole socket's packets,
dump its inode at UnixSkEntry::sender_ino.

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 criu/sk-unix.c |   31 +++++++++++++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/criu/sk-unix.c b/criu/sk-unix.c
index e519d01..d06e2a4 100644
--- a/criu/sk-unix.c
+++ b/criu/sk-unix.c
@@ -115,6 +115,16 @@ static struct unix_sk_desc *find_unix_sk_by_name(const char *name, int namelen)
 	return NULL;
 }
 
+static u32 find_unix_dgram_ino_by_name(const char *name, int namelen)
+{
+	struct unix_sk_desc *sk = find_unix_sk_by_name(name, namelen);
+
+	if (sk && sk->type != SOCK_DGRAM)
+		sk = NULL;
+
+	return sk ? sk->sd.ino : 0;
+}
+
 static void show_one_unix(char *act, const struct unix_sk_desc *sk)
 {
 	pr_debug("\t%s: ino %#x peer_ino %#x family %4d type %4d state %2d name %s\n",
@@ -444,10 +454,27 @@ static int dump_one_unix_fd(int lfd, u32 id, const struct fd_parms *p)
 	 * (i stands for in-flight, cons -- for connections) things.
 	 */
 	if (sk->rqlen != 0 && !(sk->type == SOCK_STREAM &&
-				sk->state == TCP_LISTEN))
-		if (dump_sk_queue(lfd, id, NULL, NULL))
+				sk->state == TCP_LISTEN)) {
+		u32 (*f)(const char *, int) = NULL;
+		u64 sender;
+
+		if (sk->type == SOCK_DGRAM)
+			f = find_unix_dgram_ino_by_name;
+		if (dump_sk_queue(lfd, id, f, &sender))
 			goto err;
 
+		if (sk->type == SOCK_DGRAM && sender) {
+			/* Only sender for all packets */
+			if (sender == SK_NONAME_SENDER)
+				ue->uflags |= USK_NONAME_SND;
+			else {
+				ue->has_sender_ino = true;
+				ue->sender_ino = (u32)sender;
+			}
+		}
+	} else if (sk->rqlen == 0)
+		ue->uflags |= USK_EMPTY_Q;
+
 	pr_info("Dumping unix socket at %d\n", p->fd);
 	show_one_unix("Dumping", sk);
 



More information about the CRIU mailing list