[CRIU] [PATCH v5 04/11] unix: Dump DGRAM packets and sockets senders

Kirill Tkhai ktkhai at virtuozzo.com
Thu Jun 16 06:53:28 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.

v5: Delete USK_EMPTY_Q assignment
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 criu/sk-unix.c |   19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/criu/sk-unix.c b/criu/sk-unix.c
index bbc8bf1..959b30d 100644
--- a/criu/sk-unix.c
+++ b/criu/sk-unix.c
@@ -132,6 +132,16 @@ static struct unix_sk_desc *find_unix_sk_by_name(const char *name, int namelen)
 	return NULL;
 }
 
+static u64 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 : SK_NONAME_SENDER;
+}
+
 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",
@@ -461,9 +471,14 @@ 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))
+				sk->state == TCP_LISTEN)) {
+		u64 (*f)(const char *, int) = NULL;
+
+		if (sk->type == SOCK_DGRAM)
+			f = find_unix_dgram_ino_by_name;
+		if (dump_sk_queue(lfd, id, f))
 			goto err;
+	}
 
 	pr_info("Dumping unix socket at %d\n", p->fd);
 	show_one_unix("Dumping", sk);



More information about the CRIU mailing list